From 4cc4718ce44e90548ed70a8467fd8d5a135bff9f Mon Sep 17 00:00:00 2001 From: Roman Hros Date: Fri, 14 Jun 2024 10:36:50 +0200 Subject: [PATCH] Add server metadata Signed-off-by: Roman Hros --- terraform/files/template/cluster-template.yaml | 2 ++ terraform/files/template/clusterctl.yaml.tmpl | 4 ++++ terraform/mgmtcluster.tf | 4 +++- terraform/variables.tf | 12 ++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/terraform/files/template/cluster-template.yaml b/terraform/files/template/cluster-template.yaml index b0373d6e..37787162 100644 --- a/terraform/files/template/cluster-template.yaml +++ b/terraform/files/template/cluster-template.yaml @@ -320,6 +320,7 @@ spec: template: spec: flavor: ${OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR} + serverMetadata: ${OPENSTACK_CONTROL_PLANE_MACHINE_METADATA} serverGroupID: ${OPENSTACK_SRVGRP_CONTROLLER} image: ${OPENSTACK_IMAGE_NAME} sshKeyName: ${OPENSTACK_SSH_KEY_NAME} @@ -345,6 +346,7 @@ spec: name: ${CLUSTER_NAME}-cloud-config kind: Secret flavor: ${OPENSTACK_NODE_MACHINE_FLAVOR} + serverMetadata: ${OPENSTACK_NODE_MACHINE_METADATA} serverGroupID: ${OPENSTACK_SRVGRP_WORKER} image: ${OPENSTACK_IMAGE_NAME} sshKeyName: ${OPENSTACK_SSH_KEY_NAME} diff --git a/terraform/files/template/clusterctl.yaml.tmpl b/terraform/files/template/clusterctl.yaml.tmpl index b38bfd7e..a28433ed 100644 --- a/terraform/files/template/clusterctl.yaml.tmpl +++ b/terraform/files/template/clusterctl.yaml.tmpl @@ -37,6 +37,10 @@ DEPLOY_FLUX: ${deploy_flux} # deploy metrics service DEPLOY_METRICS: ${deploy_metrics} +# OpenStack instance additional metadata +OPENSTACK_CONTROL_PLANE_MACHINE_METADATA: "{ %{ for metadata_key, metadata_value in controller_metadata ~} ${metadata_key}: ${metadata_value}, %{ endfor ~} }" +OPENSTACK_NODE_MACHINE_METADATA: "{ %{ for metadata_key, metadata_value in worker_metadata ~} ${metadata_key}: ${metadata_value}, %{ endfor ~} }" + # OpenStack flavors and machine count OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR: ${controller_flavor} CONTROL_PLANE_MACHINE_COUNT: ${controller_count} diff --git a/terraform/mgmtcluster.tf b/terraform/mgmtcluster.tf index 07ccef00..401e9916 100644 --- a/terraform/mgmtcluster.tf +++ b/terraform/mgmtcluster.tf @@ -318,6 +318,7 @@ resource "terraform_data" "mgmtcluster_bootstrap_files" { cloud_provider = var.cloud_provider, controller_count = var.controller_count, controller_flavor = var.controller_flavor, + controller_metadata = var.controller_metadata, deploy_cert_manager = var.deploy_cert_manager, deploy_cindercsi = var.deploy_cindercsi, deploy_flux = var.deploy_flux, @@ -340,7 +341,8 @@ resource "terraform_data" "mgmtcluster_bootstrap_files" { calico_version = var.calico_version, use_ovn_lb_provider = var.use_ovn_lb_provider, worker_count = var.worker_count, - worker_flavor = var.worker_flavor + worker_flavor = var.worker_flavor, + worker_metadata = var.worker_metadata }) destination = "/home/${var.ssh_username}/cluster-defaults/clusterctl.yaml" } diff --git a/terraform/variables.tf b/terraform/variables.tf index c250d61a..882c1b02 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -33,6 +33,18 @@ variable "worker_flavor" { default = "SCS-2V-4-20s" } +variable "controller_metadata" { + description = "additional metadata for instances running the k8s management nodes" + type = map(string) + default = {} +} + +variable "worker_metadata" { + description = "additional metadata for instances running the k8s worker nodes" + type = map(string) + default = {} +} + variable "availability_zone" { description = "availability zone for openstack resources" type = string