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

Support service account impersonation for wait-for-cluster script #729

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Then perform the following commands on the root folder:
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
Expand Down
7 changes: 3 additions & 4 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade
upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
3 changes: 2 additions & 1 deletion autogen/main/scripts/wait-for-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ fi

PROJECT=$1
CLUSTER_NAME=$2
IMPERSONATE_SERVICE_ACCOUNT=$3

echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."

while
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)")
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
[[ "${current_status}" != "RUNNING" ]]
do printf ".";sleep 5; done

Expand Down
6 changes: 6 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,9 @@ variable "disable_default_snat" {
default = false
}
{% endif %}

variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}
5 changes: 2 additions & 3 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ Then perform the following commands on the root folder:
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
Expand Down
5 changes: 2 additions & 3 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ fi

PROJECT=$1
CLUSTER_NAME=$2
IMPERSONATE_SERVICE_ACCOUNT=$3

echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."

while
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)")
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
[[ "${current_status}" != "RUNNING" ]]
do printf ".";sleep 5; done

Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,9 @@ variable "disable_default_snat" {
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
default = false
}

variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Then perform the following commands on the root folder:
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
Expand Down
5 changes: 2 additions & 3 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
3 changes: 2 additions & 1 deletion modules/beta-private-cluster/scripts/wait-for-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ fi

PROJECT=$1
CLUSTER_NAME=$2
IMPERSONATE_SERVICE_ACCOUNT=$3

echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."

while
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)")
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
[[ "${current_status}" != "RUNNING" ]]
do printf ".";sleep 5; done

Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,9 @@ variable "disable_default_snat" {
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
default = false
}

variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}
1 change: 1 addition & 0 deletions modules/beta-public-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Then perform the following commands on the root folder:
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
Expand Down
5 changes: 2 additions & 3 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ fi

PROJECT=$1
CLUSTER_NAME=$2
IMPERSONATE_SERVICE_ACCOUNT=$3

echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."

while
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)")
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
[[ "${current_status}" != "RUNNING" ]]
do printf ".";sleep 5; done

Expand Down
6 changes: 6 additions & 0 deletions modules/beta-public-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,9 @@ variable "disable_default_snat" {
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
default = false
}

variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}
1 change: 1 addition & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Then perform the following commands on the root folder:
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
Expand Down
5 changes: 2 additions & 3 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
3 changes: 2 additions & 1 deletion modules/beta-public-cluster/scripts/wait-for-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ fi

PROJECT=$1
CLUSTER_NAME=$2
IMPERSONATE_SERVICE_ACCOUNT=$3

echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."

while
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)")
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
[[ "${current_status}" != "RUNNING" ]]
do printf ".";sleep 5; done

Expand Down
6 changes: 6 additions & 0 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,9 @@ variable "disable_default_snat" {
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
default = false
}

variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}
1 change: 1 addition & 0 deletions modules/private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Then perform the following commands on the root folder:
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
Expand Down
5 changes: 2 additions & 3 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ fi

PROJECT=$1
CLUSTER_NAME=$2
IMPERSONATE_SERVICE_ACCOUNT=$3

echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."

while
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)")
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
[[ "${current_status}" != "RUNNING" ]]
do printf ".";sleep 5; done

Expand Down
6 changes: 6 additions & 0 deletions modules/private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,9 @@ variable "gcloud_upgrade" {
default = false
}


variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}
1 change: 1 addition & 0 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Then perform the following commands on the root folder:
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
| identity\_namespace | Workload Identity namespace. (Default value of `enabled` automatically sets project based namespace `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
Expand Down
5 changes: 2 additions & 3 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,12 @@ module "gcloud_wait_for_cluster" {
source = "terraform-google-modules/gcloud/google"
version = "~> 2.0.2"
enabled = ! var.skip_provisioners

upgrade = var.gcloud_upgrade

create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
create_cmd_body = "${var.project_id} ${var.name}"
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
destroy_cmd_body = "${var.project_id} ${var.name}"
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"

module_depends_on = concat(
[google_container_cluster.primary.master_version],
Expand Down
3 changes: 2 additions & 1 deletion modules/private-cluster/scripts/wait-for-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ fi

PROJECT=$1
CLUSTER_NAME=$2
IMPERSONATE_SERVICE_ACCOUNT=$3

echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."

while
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)")
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
[[ "${current_status}" != "RUNNING" ]]
do printf ".";sleep 5; done

Expand Down
6 changes: 6 additions & 0 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,9 @@ variable "gcloud_upgrade" {
default = false
}


variable "impersonate_service_account" {
type = string
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}
Loading