Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: refine talos terraform script #2172

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions test_framework/terraform/aws/talos/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,10 @@ data "talos_machine_configuration" "controlplane" {

depends_on = [ aws_instance.lh_aws_instance_controlplane ]

count = var.lh_aws_instance_count_controlplane

cluster_name = "lh-tests-cluster"
cluster_endpoint = "https://${aws_instance.lh_aws_instance_controlplane[0].public_ip}:6443"
machine_type = "controlplane"
machine_secrets = talos_machine_secrets.machine_secrets.machine_secrets
kubernetes_version = var.k8s_distro_version
talos_version = "v${var.os_distro_version}"
docs = false
examples = false
config_patches = [
Expand All @@ -208,26 +204,22 @@ data "talos_machine_configuration" "worker" {

depends_on = [ aws_instance.lh_aws_instance_controlplane ]

count = var.lh_aws_instance_count_worker

cluster_name = "lh-tests-cluster"
cluster_endpoint = "https://${aws_instance.lh_aws_instance_controlplane[0].public_ip}:6443"
machine_type = "worker"
machine_secrets = talos_machine_secrets.machine_secrets.machine_secrets
kubernetes_version = var.k8s_distro_version
talos_version = "v${var.os_distro_version}"
docs = false
examples = false
config_patches = [
file("${path.module}/talos-patch.yaml")
file("${path.module}/talos-patch-worker.yaml")
]
}

resource "talos_machine_configuration_apply" "controlplane" {
count = var.lh_aws_instance_count_controlplane

client_configuration = talos_machine_secrets.machine_secrets.client_configuration
machine_configuration_input = data.talos_machine_configuration.controlplane[count.index].machine_configuration
machine_configuration_input = data.talos_machine_configuration.controlplane.machine_configuration
endpoint = aws_instance.lh_aws_instance_controlplane[count.index].public_ip
node = aws_instance.lh_aws_instance_controlplane[count.index].private_ip
}
Expand All @@ -236,7 +228,7 @@ resource "talos_machine_configuration_apply" "worker" {
count = var.lh_aws_instance_count_worker

client_configuration = talos_machine_secrets.machine_secrets.client_configuration
machine_configuration_input = data.talos_machine_configuration.worker[count.index].machine_configuration
machine_configuration_input = data.talos_machine_configuration.worker.machine_configuration
endpoint = aws_instance.lh_aws_instance_worker[count.index].public_ip
node = aws_instance.lh_aws_instance_worker[count.index].private_ip
}
Expand All @@ -260,15 +252,28 @@ resource "local_file" "talosconfig" {
filename = "talos_k8s_config"
}

data "talos_cluster_kubeconfig" "this" {
resource "talos_cluster_kubeconfig" "this" {
depends_on = [talos_machine_bootstrap.this]

client_configuration = talos_machine_secrets.machine_secrets.client_configuration
endpoint = aws_instance.lh_aws_instance_controlplane[0].public_ip
endpoint = aws_instance.lh_aws_instance_controlplane.0.public_ip
node = aws_instance.lh_aws_instance_controlplane.0.private_ip
}

resource "local_file" "kubeconfig" {
content = nonsensitive(data.talos_cluster_kubeconfig.this.kubeconfig_raw)
content = nonsensitive(talos_cluster_kubeconfig.this.kubeconfig_raw)
filename = "kubeconfig"
}

data "talos_cluster_health" "this" {
depends_on = [
talos_machine_configuration_apply.controlplane,
talos_machine_configuration_apply.worker,
talos_cluster_kubeconfig.this
]

client_configuration = talos_machine_secrets.machine_secrets.client_configuration
endpoints = aws_instance.lh_aws_instance_controlplane.*.public_ip
control_plane_nodes = aws_instance.lh_aws_instance_controlplane.*.private_ip
worker_nodes = aws_instance.lh_aws_instance_worker.*.private_ip
}
2 changes: 1 addition & 1 deletion test_framework/terraform/aws/talos/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ variable "arch" {

variable "os_distro_version" {
type = string
default = "1.7.6"
default = "1.8.3"
}

variable "aws_ami_talos_account_number" {
Expand Down