From 2b84ac45bc150eee657040ee91d3333c18885f78 Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Sat, 22 May 2021 18:08:49 +0200 Subject: [PATCH] add support for labels, fixes #246 (#249) --- third-party-solutions/openshift/prepare.py | 4 ++++ third-party-solutions/openshift/tf/bootstrap.tf | 1 + third-party-solutions/openshift/tf/masters.tf | 1 + third-party-solutions/openshift/tf/variables.tf | 2 ++ 4 files changed, 8 insertions(+) diff --git a/third-party-solutions/openshift/prepare.py b/third-party-solutions/openshift/prepare.py index 632e88d5..fd9a6588 100755 --- a/third-party-solutions/openshift/prepare.py +++ b/third-party-solutions/openshift/prepare.py @@ -244,6 +244,10 @@ def manifests_edit(ctx=None): data_v['projectID'] = tfvars['service_project']['project_id'] if not 'ocp-worker' in data_v['tags']: data_v['tags'].append('ocp-worker') + if tfvars['install_config_params']['labels']: + data_v['labels'] = tfvars['install_config_params']['labels'].copy() + for i, d in enumerate(data_v['disks']): + d['labels'] = tfvars['install_config_params']['labels'].copy() data_n = data_v['networkInterfaces'][0] data_n['network'] = tfvars['host_project']['vpc_name'] data_n['subnetwork'] = tfvars['host_project']['workers_subnet_name'] diff --git a/third-party-solutions/openshift/tf/bootstrap.tf b/third-party-solutions/openshift/tf/bootstrap.tf index 70f0c3ce..e5ae8cf6 100644 --- a/third-party-solutions/openshift/tf/bootstrap.tf +++ b/third-party-solutions/openshift/tf/bootstrap.tf @@ -75,6 +75,7 @@ resource "google_compute_instance" "bootstrap" { }) VmDnsSetting = "GlobalDefault" } + labels = var.install_config_params.labels } resource "google_compute_instance_group" "bootstrap" { diff --git a/third-party-solutions/openshift/tf/masters.tf b/third-party-solutions/openshift/tf/masters.tf index 7e0172e4..82fbc789 100644 --- a/third-party-solutions/openshift/tf/masters.tf +++ b/third-party-solutions/openshift/tf/masters.tf @@ -45,6 +45,7 @@ resource "google_compute_instance" "master" { user-data = file("${local.fs_paths.config_dir}/master.ign"), VmDnsSetting = "GlobalDefault" } + labels = var.install_config_params.labels } resource "google_compute_instance_group" "master" { diff --git a/third-party-solutions/openshift/tf/variables.tf b/third-party-solutions/openshift/tf/variables.tf index ce18ae3d..5af9f7e5 100644 --- a/third-party-solutions/openshift/tf/variables.tf +++ b/third-party-solutions/openshift/tf/variables.tf @@ -58,6 +58,7 @@ variable "install_config_params" { description = "OpenShift cluster configuration." type = object({ disk_size = number + labels = map(string) network = object({ cluster = string host_prefix = number @@ -72,6 +73,7 @@ variable "install_config_params" { }) default = { disk_size = 16 + labels = {} network = { cluster = "10.128.0.0/14" host_prefix = 23