-
Notifications
You must be signed in to change notification settings - Fork 84
/
talos_cluster.tf
43 lines (37 loc) · 1.33 KB
/
talos_cluster.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
locals {
controlplane_nodes = [for i in range(1, var.controlplane_num + 1) : "${var.controlplane_ip_prefix}${i}"]
worker_nodes = [for i in range(1, var.workernode_num + 1) : "${var.workernode_ip_prefix}${i}"]
}
resource "talos_machine_secrets" "this" {
talos_version = var.talos_version
}
data "talos_client_configuration" "this" {
cluster_name = var.kubernetes_cluster_name
client_configuration = talos_machine_secrets.this.client_configuration
endpoints = [for node in local.controlplane_nodes : node]
}
data "talos_cluster_kubeconfig" "this" {
depends_on = [
talos_machine_bootstrap.this
]
client_configuration = talos_machine_secrets.this.client_configuration
endpoint = local.controlplane_nodes[0]
node = local.controlplane_nodes[0]
}
resource "talos_machine_bootstrap" "this" {
count = var.controlplane_num
depends_on = [
talos_machine_configuration_apply.controlplane
]
endpoint = local.controlplane_nodes[0]
node = local.controlplane_nodes[0]
client_configuration = talos_machine_secrets.this.client_configuration
}
output "kubeconfig" {
value = data.talos_cluster_kubeconfig.this.kubeconfig_raw
sensitive = true
}
output "talosconfig" {
value = data.talos_client_configuration.this.talos_config
sensitive = true
}