Testing out talos provider for config patches
This commit is contained in:
parent
ee03c3b5b7
commit
5d6d21108f
2 changed files with 50 additions and 14 deletions
|
|
@ -8,6 +8,9 @@ terraform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider "talos" {
|
||||||
|
# Configuration options
|
||||||
|
}
|
||||||
|
|
||||||
# Load variables from a .tfvars file
|
# Load variables from a .tfvars file
|
||||||
variable "cluster_name" {
|
variable "cluster_name" {
|
||||||
|
|
@ -91,21 +94,54 @@ resource "null_resource" "talos_cluster" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "null_resource" "talos_cluster_patches" {
|
resource "talos_machine_secrets" "this" {}
|
||||||
depends_on = [null_resource.talos_cluster]
|
|
||||||
triggers = {
|
data "talos_machine_configuration" "this" {
|
||||||
patches_hash = filesha1("${path.module}/patches/controlplane-patch.yaml")
|
cluster_name = "${var.cluster_name}"
|
||||||
|
machine_type = "controlplane"
|
||||||
|
cluster_endpoint = "https://10.5.0.0:6443"
|
||||||
|
machine_secrets = talos_machine_secrets.this.machine_secrets
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "local-exec" {
|
data "talos_client_configuration" "this" {
|
||||||
command = <<EOT
|
cluster_name = "example-cluster"
|
||||||
# Apply ONLY your custom patches (not the full config)
|
client_configuration = talos_machine_secrets.this.client_configuration
|
||||||
talosctl patch machineconfig \
|
nodes = ["10.5.0.2"]
|
||||||
--patch-file patches/controlplane-patch.yaml \
|
}
|
||||||
--nodes 10.5.0.2
|
|
||||||
EOT
|
resource "talos_machine_configuration_apply" "this" {
|
||||||
|
client_configuration = talos_machine_secrets.this.client_configuration
|
||||||
|
machine_configuration_input = data.talos_machine_configuration.this.machine_configuration
|
||||||
|
node = "10.5.0.2"
|
||||||
|
config_patches = [
|
||||||
|
yamlencode({
|
||||||
|
cluster = {
|
||||||
|
apiServer = {
|
||||||
|
certSANs = [
|
||||||
|
"- 10.5.0.1"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# resource "null_resource" "talos_cluster_patches" {
|
||||||
|
# depends_on = [null_resource.talos_cluster]
|
||||||
|
# triggers = {
|
||||||
|
# patches_hash = filesha1("${path.module}/patches/controlplane-patch.yaml")
|
||||||
|
# }
|
||||||
|
|
||||||
|
# provisioner "local-exec" {
|
||||||
|
# command = <<EOT
|
||||||
|
# # Apply ONLY your custom patches (not the full config)
|
||||||
|
# talosctl patch machineconfig \
|
||||||
|
# --patch-file patches/controlplane-patch.yaml \
|
||||||
|
# --nodes 10.5.0.2 \
|
||||||
|
# --mode reboot
|
||||||
|
# EOT
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
output "next_steps" {
|
output "next_steps" {
|
||||||
value = <<EOT
|
value = <<EOT
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
cluster:
|
cluster:
|
||||||
apiServer:
|
apiServer:
|
||||||
certSANs:
|
certSANs:
|
||||||
- 10.5.0.1
|
- 10.5.0.2
|
||||||
Loading…
Add table
Reference in a new issue