Added Kubernetes config
This commit is contained in:
63
proxmox/talos_linux.tf
Normal file
63
proxmox/talos_linux.tf
Normal file
@@ -0,0 +1,63 @@
|
||||
resource "talos_machine_secrets" "this" {}
|
||||
|
||||
data "talos_machine_configuration" "controlplane" {
|
||||
cluster_name = var.cluster_name
|
||||
cluster_endpoint = var.cluster_endpoint
|
||||
machine_type = "controlplane"
|
||||
machine_secrets = talos_machine_secrets.this.machine_secrets
|
||||
}
|
||||
|
||||
data "talos_machine_configuration" "worker" {
|
||||
cluster_name = var.cluster_name
|
||||
cluster_endpoint = var.cluster_endpoint
|
||||
machine_type = "worker"
|
||||
machine_secrets = talos_machine_secrets.this.machine_secrets
|
||||
}
|
||||
|
||||
data "talos_client_configuration" "this" {
|
||||
cluster_name = var.cluster_name
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
endpoints = [for k, v in var.node_data.controlplanes : k]
|
||||
}
|
||||
|
||||
resource "talos_machine_configuration_apply" "controlplane" {
|
||||
depends_on = [proxmox_vm_qemu.k8s_control_plane]
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
machine_configuration_input = data.talos_machine_configuration.controlplane.machine_configuration
|
||||
for_each = var.node_data.controlplanes
|
||||
node = each.key
|
||||
config_patches = [
|
||||
templatefile("${path.module}/templates/machine_disk_and_hostname.yaml.tftmpl", {
|
||||
hostname = each.value.hostname == null ? format("%s-cp-%s", var.cluster_name, index(keys(var.node_data.controlplanes), each.key)) : each.value.hostname
|
||||
install_disk = each.value.install_disk
|
||||
}),
|
||||
file("${path.module}/files/cp-scheduling.yaml"),
|
||||
]
|
||||
}
|
||||
|
||||
resource "talos_machine_configuration_apply" "worker" {
|
||||
depends_on = [proxmox_vm_qemu.k8s_worker_1, proxmox_vm_qemu.k8s_worker_2]
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
machine_configuration_input = data.talos_machine_configuration.worker.machine_configuration
|
||||
for_each = var.node_data.workers
|
||||
node = each.key
|
||||
config_patches = [
|
||||
templatefile("${path.module}/templates/machine_disk_and_hostname.yaml.tftmpl", {
|
||||
hostname = each.value.hostname == null ? format("%s-worker-%s", var.cluster_name, index(keys(var.node_data.workers), each.key)) : each.value.hostname
|
||||
install_disk = each.value.install_disk
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
resource "talos_machine_bootstrap" "this" {
|
||||
depends_on = [talos_machine_configuration_apply.controlplane]
|
||||
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
node = [for k, v in var.node_data.controlplanes : k][0]
|
||||
}
|
||||
|
||||
resource "talos_cluster_kubeconfig" "this" {
|
||||
depends_on = [talos_machine_bootstrap.this]
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
node = [for k, v in var.node_data.controlplanes : k][0]
|
||||
}
|
||||
Reference in New Issue
Block a user