Skip to content

Commit 0f0d39d

Browse files
committed
Add WI/Google Groups RBAC
1 parent 0ac165a commit 0f0d39d

File tree

17 files changed

+197
-0
lines changed

17 files changed

+197
-0
lines changed

autogen/cluster_regional.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ resource "google_container_cluster" "primary" {
7171
}
7272
}
7373

74+
dynamic "workload_identity_config" {
75+
for_each = var.workload_identity_config
76+
content {
77+
identity_namespace = "${var.project_id}.svc.id.goog"
78+
}
79+
}
80+
81+
dynamic "authenticator_groups_config" {
82+
for_each = var.authenticator_groups_config
83+
content {
84+
security_group = "${authenticator_groups_config.value.security_group}"
85+
}
86+
}
87+
7488
{% endif %}
7589
dynamic "master_authorized_networks_config" {
7690
for_each = var.master_authorized_networks_config

autogen/cluster_zonal.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ resource "google_container_cluster" "zonal_primary" {
6767
}
6868
}
6969

70+
dynamic "workload_identity_config" {
71+
for_each = var.workload_identity_config
72+
content {
73+
identity_namespace = "${var.project_id}.svc.id.goog"
74+
}
75+
}
76+
77+
dynamic "authenticator_groups_config" {
78+
for_each = var.authenticator_groups_config
79+
content {
80+
security_group = "${authenticator_groups_config.value.security_group}"
81+
}
82+
}
83+
7084
{% endif %}
7185
dynamic "master_authorized_networks_config" {
7286
for_each = var.master_authorized_networks_config

autogen/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ locals {
261261
regional = element(concat(google_container_cluster.primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
262262
zonal = element(concat(google_container_cluster.zonal_primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
263263
}
264+
265+
cluster_type_workload_identity_namespace = {
266+
regional = element(concat(google_container_cluster.primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
267+
zonal = element(concat(google_container_cluster.zonal_primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
268+
}
269+
270+
cluster_type_authenticator_security_group = {
271+
regional = element(concat(google_container_cluster.primary.*.authenticator_groups_config.0.security_group, [""]), 0)
272+
zonal = element(concat(google_container_cluster.zonal_primary.*.authenticator_groups_config.0.security_group, [""]), 0)
273+
}
274+
264275
# /BETA features
265276
{% endif %}
266277

@@ -301,6 +312,8 @@ locals {
301312
cluster_pod_security_policy_enabled = local.cluster_type_output_pod_security_policy_enabled[local.cluster_type]
302313
cluster_intranode_visibility_enabled = local.cluster_type_output_intranode_visbility_enabled[local.cluster_type]
303314
cluster_vertical_pod_autoscaling_enabled = local.cluster_type_output_vertical_pod_autoscaling_enabled[local.cluster_type]
315+
cluster_workload_identity_namespace = local.cluster_type_workload_identity_namespace[local.cluster_type]
316+
cluster_authenticator_security_group = local.cluster_type_authenticator_security_group[local.cluster_type]
304317
# /BETA features
305318
{% endif %}
306319
}

autogen/outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,15 @@ output "vertical_pod_autoscaling_enabled" {
152152
value = local.cluster_vertical_pod_autoscaling_enabled
153153
}
154154

155+
156+
output "workload_identity_namespace" {
157+
description = "Workload Identity Namespace"
158+
value = local.cluster_workload_identity_namespace
159+
}
160+
161+
162+
output "authenticator_security_group" {
163+
description = "Whether veritical pod autoscaling is enabled"
164+
value = local.cluster_authenticator_security_group
165+
}
155166
{% endif %}

autogen/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,15 @@ variable "enable_intranode_visibility" {
365365
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
366366
default = false
367367
}
368+
369+
variable "workload_identity_config" {
370+
description = "Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account."
371+
default = []
372+
}
373+
374+
variable "authenticator_groups_config" {
375+
type = list(map(string))
376+
description = "security_group - The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected]"
377+
default = []
378+
}
368379
{% endif %}

modules/beta-private-cluster/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
133133

134134
| Name | Description | Type | Default | Required |
135135
|------|-------------|:----:|:-----:|:-----:|
136+
| authenticator\_groups\_config | security_group - The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | list(map(string)) | `<list>` | no |
136137
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
137138
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
138139
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
@@ -187,12 +188,14 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
187188
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |
188189
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
189190
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |
191+
| workload\_identity\_config | Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account. | list | `<list>` | no |
190192
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) | `<list>` | no |
191193

192194
## Outputs
193195

194196
| Name | Description |
195197
|------|-------------|
198+
| authenticator\_security\_group | Whether veritical pod autoscaling is enabled |
196199
| ca\_certificate | Cluster ca certificate (base64 encoded) |
197200
| cloudrun\_enabled | Whether CloudRun enabled |
198201
| endpoint | Cluster endpoint |
@@ -216,6 +219,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
216219
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
217220
| type | Cluster type (regional / zonal) |
218221
| vertical\_pod\_autoscaling\_enabled | Whether veritical pod autoscaling is enabled |
222+
| workload\_identity\_namespace | Workload Identity Namespace |
219223
| zones | List of zones in which the cluster resides |
220224

221225
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/beta-private-cluster/cluster_regional.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ resource "google_container_cluster" "primary" {
6666
}
6767
}
6868

69+
dynamic "workload_identity_config" {
70+
for_each = var.workload_identity_config
71+
content {
72+
identity_namespace = "${var.project_id}.svc.id.goog"
73+
}
74+
}
75+
76+
dynamic "authenticator_groups_config" {
77+
for_each = var.authenticator_groups_config
78+
content {
79+
security_group = "${authenticator_groups_config.value.security_group}"
80+
}
81+
}
82+
6983
dynamic "master_authorized_networks_config" {
7084
for_each = var.master_authorized_networks_config
7185
content {

modules/beta-private-cluster/cluster_zonal.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ resource "google_container_cluster" "zonal_primary" {
6262
}
6363
}
6464

65+
dynamic "workload_identity_config" {
66+
for_each = var.workload_identity_config
67+
content {
68+
identity_namespace = "${var.project_id}.svc.id.goog"
69+
}
70+
}
71+
72+
dynamic "authenticator_groups_config" {
73+
for_each = var.authenticator_groups_config
74+
content {
75+
security_group = "${authenticator_groups_config.value.security_group}"
76+
}
77+
}
78+
6579
dynamic "master_authorized_networks_config" {
6680
for_each = var.master_authorized_networks_config
6781
content {

modules/beta-private-cluster/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ locals {
244244
regional = element(concat(google_container_cluster.primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
245245
zonal = element(concat(google_container_cluster.zonal_primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
246246
}
247+
248+
cluster_type_workload_identity_namespace = {
249+
regional = element(concat(google_container_cluster.primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
250+
zonal = element(concat(google_container_cluster.zonal_primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
251+
}
252+
253+
cluster_type_authenticator_security_group = {
254+
regional = element(concat(google_container_cluster.primary.*.authenticator_groups_config.0.security_group, [""]), 0)
255+
zonal = element(concat(google_container_cluster.zonal_primary.*.authenticator_groups_config.0.security_group, [""]), 0)
256+
}
257+
247258
# /BETA features
248259

249260
cluster_type_output_node_pools_names = {
@@ -282,6 +293,8 @@ locals {
282293
cluster_pod_security_policy_enabled = local.cluster_type_output_pod_security_policy_enabled[local.cluster_type]
283294
cluster_intranode_visibility_enabled = local.cluster_type_output_intranode_visbility_enabled[local.cluster_type]
284295
cluster_vertical_pod_autoscaling_enabled = local.cluster_type_output_vertical_pod_autoscaling_enabled[local.cluster_type]
296+
cluster_workload_identity_namespace = local.cluster_type_workload_identity_namespace[local.cluster_type]
297+
cluster_authenticator_security_group = local.cluster_type_authenticator_security_group[local.cluster_type]
285298
# /BETA features
286299
}
287300

modules/beta-private-cluster/outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,14 @@ output "vertical_pod_autoscaling_enabled" {
151151
value = local.cluster_vertical_pod_autoscaling_enabled
152152
}
153153

154+
155+
output "workload_identity_namespace" {
156+
description = "Workload Identity Namespace"
157+
value = local.cluster_workload_identity_namespace
158+
}
159+
160+
161+
output "authenticator_security_group" {
162+
description = "Whether veritical pod autoscaling is enabled"
163+
value = local.cluster_authenticator_security_group
164+
}

modules/beta-private-cluster/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,14 @@ variable "enable_vertical_pod_autoscaling" {
362362
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
363363
default = false
364364
}
365+
366+
variable "workload_identity_config" {
367+
description = "Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account."
368+
default = []
369+
}
370+
371+
variable "authenticator_groups_config" {
372+
type = list(map(string))
373+
description = "security_group - The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected]"
374+
default = []
375+
}

modules/beta-public-cluster/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
128128

129129
| Name | Description | Type | Default | Required |
130130
|------|-------------|:----:|:-----:|:-----:|
131+
| authenticator\_groups\_config | security_group - The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | list(map(string)) | `<list>` | no |
131132
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
132133
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
133134
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
@@ -178,12 +179,14 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
178179
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map(list(string)) | `<map>` | no |
179180
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
180181
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |
182+
| workload\_identity\_config | Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account. | list | `<list>` | no |
181183
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) | `<list>` | no |
182184

183185
## Outputs
184186

185187
| Name | Description |
186188
|------|-------------|
189+
| authenticator\_security\_group | Whether veritical pod autoscaling is enabled |
187190
| ca\_certificate | Cluster ca certificate (base64 encoded) |
188191
| cloudrun\_enabled | Whether CloudRun enabled |
189192
| endpoint | Cluster endpoint |
@@ -207,6 +210,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
207210
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
208211
| type | Cluster type (regional / zonal) |
209212
| vertical\_pod\_autoscaling\_enabled | Whether veritical pod autoscaling is enabled |
213+
| workload\_identity\_namespace | Workload Identity Namespace |
210214
| zones | List of zones in which the cluster resides |
211215

212216
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/beta-public-cluster/cluster_regional.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ resource "google_container_cluster" "primary" {
6666
}
6767
}
6868

69+
dynamic "workload_identity_config" {
70+
for_each = var.workload_identity_config
71+
content {
72+
identity_namespace = "${var.project_id}.svc.id.goog"
73+
}
74+
}
75+
76+
dynamic "authenticator_groups_config" {
77+
for_each = var.authenticator_groups_config
78+
content {
79+
security_group = "${authenticator_groups_config.value.security_group}"
80+
}
81+
}
82+
6983
dynamic "master_authorized_networks_config" {
7084
for_each = var.master_authorized_networks_config
7185
content {

modules/beta-public-cluster/cluster_zonal.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ resource "google_container_cluster" "zonal_primary" {
6262
}
6363
}
6464

65+
dynamic "workload_identity_config" {
66+
for_each = var.workload_identity_config
67+
content {
68+
identity_namespace = "${var.project_id}.svc.id.goog"
69+
}
70+
}
71+
72+
dynamic "authenticator_groups_config" {
73+
for_each = var.authenticator_groups_config
74+
content {
75+
security_group = "${authenticator_groups_config.value.security_group}"
76+
}
77+
}
78+
6579
dynamic "master_authorized_networks_config" {
6680
for_each = var.master_authorized_networks_config
6781
content {

modules/beta-public-cluster/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ locals {
246246
regional = element(concat(google_container_cluster.primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
247247
zonal = element(concat(google_container_cluster.zonal_primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
248248
}
249+
250+
cluster_type_workload_identity_namespace = {
251+
regional = element(concat(google_container_cluster.primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
252+
zonal = element(concat(google_container_cluster.zonal_primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
253+
}
254+
255+
cluster_type_authenticator_security_group = {
256+
regional = element(concat(google_container_cluster.primary.*.authenticator_groups_config.0.security_group, [""]), 0)
257+
zonal = element(concat(google_container_cluster.zonal_primary.*.authenticator_groups_config.0.security_group, [""]), 0)
258+
}
259+
249260
# /BETA features
250261

251262
cluster_type_output_node_pools_names = {
@@ -284,6 +295,8 @@ locals {
284295
cluster_pod_security_policy_enabled = local.cluster_type_output_pod_security_policy_enabled[local.cluster_type]
285296
cluster_intranode_visibility_enabled = local.cluster_type_output_intranode_visbility_enabled[local.cluster_type]
286297
cluster_vertical_pod_autoscaling_enabled = local.cluster_type_output_vertical_pod_autoscaling_enabled[local.cluster_type]
298+
cluster_workload_identity_namespace = local.cluster_type_workload_identity_namespace[local.cluster_type]
299+
cluster_authenticator_security_group = local.cluster_type_authenticator_security_group[local.cluster_type]
287300
# /BETA features
288301
}
289302

modules/beta-public-cluster/outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,14 @@ output "vertical_pod_autoscaling_enabled" {
151151
value = local.cluster_vertical_pod_autoscaling_enabled
152152
}
153153

154+
155+
output "workload_identity_namespace" {
156+
description = "Workload Identity Namespace"
157+
value = local.cluster_workload_identity_namespace
158+
}
159+
160+
161+
output "authenticator_security_group" {
162+
description = "Whether veritical pod autoscaling is enabled"
163+
value = local.cluster_authenticator_security_group
164+
}

modules/beta-public-cluster/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,14 @@ variable "enable_vertical_pod_autoscaling" {
338338
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
339339
default = false
340340
}
341+
342+
variable "workload_identity_config" {
343+
description = "Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account."
344+
default = []
345+
}
346+
347+
variable "authenticator_groups_config" {
348+
type = list(map(string))
349+
description = "security_group - The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected]"
350+
default = []
351+
}

0 commit comments

Comments
 (0)