Skip to content

Commit d802e49

Browse files
feat: expose use_existing_context variable in WI module (#1295)
exposing use_existing_context variable to allow kubectl wrapper to run kubectl using local kube config context Co-authored-by: Bharath KKB <[email protected]>
1 parent 59ca09e commit d802e49

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

modules/workload-identity/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ already bear the `"iam.gke.io/gcp-service-account"` annotation.
109109
| namespace | Namespace for the Kubernetes service account | `string` | `"default"` | no |
110110
| project\_id | GCP project ID | `string` | n/a | yes |
111111
| roles | A list of roles to be added to the created service account | `list(string)` | `[]` | no |
112+
| use\_existing\_context | An optional flag to use local kubectl config context. | `bool` | `false` | no |
112113
| use\_existing\_gcp\_sa | Use an existing Google service account instead of creating one | `bool` | `false` | no |
113114
| use\_existing\_k8s\_sa | Use an existing kubernetes service account instead of creating one | `bool` | `false` | no |
114115

modules/workload-identity/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module "annotate-sa" {
6868
cluster_location = var.location
6969
project_id = local.k8s_sa_project_id
7070
impersonate_service_account = var.impersonate_service_account
71+
use_existing_context = var.use_existing_context
7172

7273
kubectl_create_command = "kubectl annotate --overwrite sa -n ${local.output_k8s_namespace} ${local.k8s_given_name} iam.gke.io/gcp-service-account=${local.gcp_sa_email}"
7374
kubectl_destroy_command = "kubectl annotate sa -n ${local.output_k8s_namespace} ${local.k8s_given_name} iam.gke.io/gcp-service-account-"

modules/workload-identity/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,9 @@ variable "impersonate_service_account" {
9595
type = string
9696
default = ""
9797
}
98+
99+
variable "use_existing_context" {
100+
description = "An optional flag to use local kubectl config context."
101+
type = bool
102+
default = false
103+
}

0 commit comments

Comments
 (0)