Skip to content

Commit

Permalink
GCP: Added user specified tags on control plane instances
Browse files Browse the repository at this point in the history
This is the second step to enabling an IPI cluster using Shared VPC where the service account does not have sufficient permissions to create firewall rules in the Host Project while maintaining cluster-specific firewall rules.
Depends on openshift#6185
  • Loading branch information
AnnaZivkovic committed Aug 4, 2022
1 parent a6bc4df commit cec7441
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/data/gcp/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module "master" {
root_volume_type = var.gcp_master_root_volume_type
root_volume_kms_key_link = var.gcp_root_volume_kms_key_link

tags = var.gcp_control_plane_tags
labels = local.labels
}

Expand Down
5 changes: 4 additions & 1 deletion data/data/gcp/cluster/master/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ resource "google_compute_instance" "master" {
user-data = var.ignition
}

tags = ["${var.cluster_id}-master"]
tags = concat(
["${var.cluster_id}-master"],
var.tags,
)

labels = var.labels

Expand Down
5 changes: 5 additions & 0 deletions data/data/gcp/cluster/master/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ variable "subnet" {
description = "The subnetwork the master instances will be added to."
}

variable "tags" {
type = list(string)
description = "The list of network tags which will be added to the control plane instances."
}

variable "root_volume_size" {
type = string
description = "The size of the volume in gigabytes for the root block device."
Expand Down
7 changes: 7 additions & 0 deletions data/data/gcp/variables-gcp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,10 @@ variable "gcp_root_volume_kms_key_link" {
description = "The GCP self link of KMS key to encrypt the volume."
default = null
}

variable "gcp_control_plane_tags" {
type = list(string)
description = "The list of network tags which will be added to the control plane instances."

}

2 changes: 2 additions & 0 deletions pkg/tfvars/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type config struct {
ClusterNetwork string `json:"gcp_cluster_network,omitempty"`
ControlPlaneSubnet string `json:"gcp_control_plane_subnet,omitempty"`
ComputeSubnet string `json:"gcp_compute_subnet,omitempty"`
ControlPLaneTags []string `json:"gcp_control_plane_tags,omitempty"`
}

// TFVarsSources contains the parameters to be converted into Terraform variables
Expand Down Expand Up @@ -78,6 +79,7 @@ func TFVars(sources TFVarsSources) ([]byte, error) {
ControlPlaneSubnet: masterConfig.NetworkInterfaces[0].Subnetwork,
ComputeSubnet: workerConfig.NetworkInterfaces[0].Subnetwork,
PreexistingNetwork: sources.PreexistingNetwork,
ControlPLaneTags: masterConfig.Tags,
}
cfg.PreexistingImage = true
if len(sources.ImageLicenses) > 0 {
Expand Down

0 comments on commit cec7441

Please sign in to comment.