Skip to content

Commit 3fceb2b

Browse files
committed
Updates droplets.tf, outputs.tf, templates/ to add TLS SANS for cluster to include all control plane node addresses, VIP and clean up outputs to be more organized and reflect centralization on the LB IP.
Signed-off-by: Joseph D. Marhee <[email protected]>
1 parent 5398fbd commit 3fceb2b

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

droplets.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ data "template_file" "control-plane-replica" {
2424
depends_on = [digitalocean_database_cluster.rancherdb, digitalocean_droplet.control-plane-init]
2525
template = file("${path.module}/templates/control-plane-replica.tpl")
2626
vars = {
27-
RANCHER_DATA_SOURCE = "postgres://doadmin:${nonsensitive(digitalocean_database_cluster.rancherdb.password)}@${digitalocean_database_cluster.rancherdb.host}:${digitalocean_database_cluster.rancherdb.port}/defaultdb?sslmode=require"
28-
GENERATED_K3S_TOKEN = random_string.k3s_token.result
27+
RANCHER_DATA_SOURCE = "postgres://doadmin:${nonsensitive(digitalocean_database_cluster.rancherdb.password)}@${digitalocean_database_cluster.rancherdb.host}:${digitalocean_database_cluster.rancherdb.port}/defaultdb?sslmode=require"
28+
GENERATED_K3S_TOKEN = random_string.k3s_token.result
29+
LOAD_BALANCER_VIP = digitalocean_loadbalancer.kubernetes_lb.ip
30+
CONTROL_PLANE_INIT_IP = digitalocean_droplet.control-plane-init.ipv4_address
2931
}
3032
}
3133

outputs.tf

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
output "controller_addresses" {
2-
description = "Kubernetes Controller IP Addresses"
3-
value = "${digitalocean_droplet.control-plane-init.ipv4_address}\n"
4-
}
5-
6-
output "controller_peers" {
7-
description = "Control Plane Nodes"
8-
value = digitalocean_droplet.control-plane-replica.*.ipv4_address
9-
}
10-
11-
output "worker_nodes" {
12-
description = "Worker Nodes"
13-
value = digitalocean_droplet.node.*.ipv4_address
1+
output "kubeconfig_base64" {
2+
description = "Base64 encoded kubeconfig string"
3+
value = data.external.k3s_config.result.kubeconfig
144
}
155

16-
output "kubeconfig" {
6+
output "kubeconfig_location" {
177
description = "Your Kubeconfig"
188
value = "${path.module}/${pathexpand(format("%s-config", var.cluster_name))}"
199
}
2010

21-
output "kubeconfig_base64" {
22-
description = "Base64 encoded kubeconfig string"
23-
value = data.external.k3s_config.result.kubeconfig
11+
output "control_plane_lb_address" {
12+
description = "K3s Control Plane Load Balancer Address"
13+
value = digitalocean_loadbalancer.kubernetes_lb.ip
2414
}
2515

26-
output "cluster_lb_address" {
27-
description = "K3s Cluster LB Address"
28-
value = digitalocean_loadbalancer.kubernetes_lb.ip
16+
output "control_plane_nodes" {
17+
description = "K3s Control Plane Node IP Addresses"
18+
value = "${digitalocean_droplet.control-plane-init.ipv4_address}, ${join(", ", digitalocean_droplet.control-plane-replica.*.ipv4_address)}"
19+
}
20+
21+
output "worker_nodes" {
22+
description = "K3s Worker Nodes"
23+
value = digitalocean_droplet.node.*.ipv4_address
2924
}

templates/control-plane-init.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
curl -sfL https://get.k3s.io | \
44
INSTALL_K3S_CHANNEL=latest K3S_TOKEN="${GENERATED_K3S_TOKEN}" \
55
sh -s - server --datastore-endpoint="${RANCHER_DATA_SOURCE}" \
6-
--tls-san "${LOAD_BALANCER_VIP}"
6+
--tls-san "${LOAD_BALANCER_VIP}" \
7+
--tls-san "$(curl http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)"

templates/control-plane-replica.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
curl -sfL https://get.k3s.io | \
44
INSTALL_K3S_CHANNEL=latest K3S_TOKEN="${GENERATED_K3S_TOKEN}" \
5-
sh -s - server --datastore-endpoint="${RANCHER_DATA_SOURCE}"
5+
sh -s - server --datastore-endpoint="${RANCHER_DATA_SOURCE}" \
6+
--tls-san "${LOAD_BALANCER_VIP}" \
7+
--tls-san "${CONTROL_PLANE_INIT_IP}" \
8+
--tls-san "$(curl http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)"

0 commit comments

Comments
 (0)