Skip to content

Commit

Permalink
Add WI/Google Groups RBAC
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev25 committed Jul 25, 2019
1 parent 0ac165a commit 0f0d39d
Show file tree
Hide file tree
Showing 17 changed files with 197 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ resource "google_container_cluster" "primary" {
}
}

dynamic "workload_identity_config" {
for_each = var.workload_identity_config
content {
identity_namespace = "${var.project_id}.svc.id.goog"
}
}

dynamic "authenticator_groups_config" {
for_each = var.authenticator_groups_config
content {
security_group = "${authenticator_groups_config.value.security_group}"
}
}

{% endif %}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
Expand Down
14 changes: 14 additions & 0 deletions autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ resource "google_container_cluster" "zonal_primary" {
}
}

dynamic "workload_identity_config" {
for_each = var.workload_identity_config
content {
identity_namespace = "${var.project_id}.svc.id.goog"
}
}

dynamic "authenticator_groups_config" {
for_each = var.authenticator_groups_config
content {
security_group = "${authenticator_groups_config.value.security_group}"
}
}

{% endif %}
dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
Expand Down
13 changes: 13 additions & 0 deletions autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ locals {
regional = element(concat(google_container_cluster.primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
}

cluster_type_workload_identity_namespace = {
regional = element(concat(google_container_cluster.primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
}

cluster_type_authenticator_security_group = {
regional = element(concat(google_container_cluster.primary.*.authenticator_groups_config.0.security_group, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.authenticator_groups_config.0.security_group, [""]), 0)
}

# /BETA features
{% endif %}

Expand Down Expand Up @@ -301,6 +312,8 @@ locals {
cluster_pod_security_policy_enabled = local.cluster_type_output_pod_security_policy_enabled[local.cluster_type]
cluster_intranode_visibility_enabled = local.cluster_type_output_intranode_visbility_enabled[local.cluster_type]
cluster_vertical_pod_autoscaling_enabled = local.cluster_type_output_vertical_pod_autoscaling_enabled[local.cluster_type]
cluster_workload_identity_namespace = local.cluster_type_workload_identity_namespace[local.cluster_type]
cluster_authenticator_security_group = local.cluster_type_authenticator_security_group[local.cluster_type]
# /BETA features
{% endif %}
}
Expand Down
11 changes: 11 additions & 0 deletions autogen/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,15 @@ output "vertical_pod_autoscaling_enabled" {
value = local.cluster_vertical_pod_autoscaling_enabled
}


output "workload_identity_namespace" {
description = "Workload Identity Namespace"
value = local.cluster_workload_identity_namespace
}


output "authenticator_security_group" {
description = "Whether veritical pod autoscaling is enabled"
value = local.cluster_authenticator_security_group
}
{% endif %}
11 changes: 11 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,15 @@ variable "enable_intranode_visibility" {
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
default = false
}

variable "workload_identity_config" {
description = "Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account."
default = []
}

variable "authenticator_groups_config" {
type = list(map(string))
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 gke-security-groups@yourdomain.com"
default = []
}
{% endif %}
4 changes: 4 additions & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| 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 gke-security-groups@yourdomain.com | list(map(string)) | `<list>` | no |
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
| 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 |
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
Expand Down Expand Up @@ -187,12 +188,14 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |
| workload\_identity\_config | Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account. | list | `<list>` | no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) | `<list>` | no |

## Outputs

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

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ resource "google_container_cluster" "primary" {
}
}

dynamic "workload_identity_config" {
for_each = var.workload_identity_config
content {
identity_namespace = "${var.project_id}.svc.id.goog"
}
}

dynamic "authenticator_groups_config" {
for_each = var.authenticator_groups_config
content {
security_group = "${authenticator_groups_config.value.security_group}"
}
}

dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
content {
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ resource "google_container_cluster" "zonal_primary" {
}
}

dynamic "workload_identity_config" {
for_each = var.workload_identity_config
content {
identity_namespace = "${var.project_id}.svc.id.goog"
}
}

dynamic "authenticator_groups_config" {
for_each = var.authenticator_groups_config
content {
security_group = "${authenticator_groups_config.value.security_group}"
}
}

dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
content {
Expand Down
13 changes: 13 additions & 0 deletions modules/beta-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ locals {
regional = element(concat(google_container_cluster.primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
}

cluster_type_workload_identity_namespace = {
regional = element(concat(google_container_cluster.primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
}

cluster_type_authenticator_security_group = {
regional = element(concat(google_container_cluster.primary.*.authenticator_groups_config.0.security_group, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.authenticator_groups_config.0.security_group, [""]), 0)
}

# /BETA features

cluster_type_output_node_pools_names = {
Expand Down Expand Up @@ -282,6 +293,8 @@ locals {
cluster_pod_security_policy_enabled = local.cluster_type_output_pod_security_policy_enabled[local.cluster_type]
cluster_intranode_visibility_enabled = local.cluster_type_output_intranode_visbility_enabled[local.cluster_type]
cluster_vertical_pod_autoscaling_enabled = local.cluster_type_output_vertical_pod_autoscaling_enabled[local.cluster_type]
cluster_workload_identity_namespace = local.cluster_type_workload_identity_namespace[local.cluster_type]
cluster_authenticator_security_group = local.cluster_type_authenticator_security_group[local.cluster_type]
# /BETA features
}

Expand Down
11 changes: 11 additions & 0 deletions modules/beta-private-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,14 @@ output "vertical_pod_autoscaling_enabled" {
value = local.cluster_vertical_pod_autoscaling_enabled
}


output "workload_identity_namespace" {
description = "Workload Identity Namespace"
value = local.cluster_workload_identity_namespace
}


output "authenticator_security_group" {
description = "Whether veritical pod autoscaling is enabled"
value = local.cluster_authenticator_security_group
}
11 changes: 11 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,14 @@ variable "enable_vertical_pod_autoscaling" {
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
default = false
}

variable "workload_identity_config" {
description = "Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account."
default = []
}

variable "authenticator_groups_config" {
type = list(map(string))
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 gke-security-groups@yourdomain.com"
default = []
}
4 changes: 4 additions & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| 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 gke-security-groups@yourdomain.com | list(map(string)) | `<list>` | no |
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
| 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 |
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
Expand Down Expand Up @@ -178,12 +179,14 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| 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 |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
| upstream\_nameservers | If specified, the values replace the nameservers taken by default from the node’s /etc/resolv.conf | list | `<list>` | no |
| workload\_identity\_config | Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account. | list | `<list>` | no |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list(string) | `<list>` | no |

## Outputs

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

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-public-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ resource "google_container_cluster" "primary" {
}
}

dynamic "workload_identity_config" {
for_each = var.workload_identity_config
content {
identity_namespace = "${var.project_id}.svc.id.goog"
}
}

dynamic "authenticator_groups_config" {
for_each = var.authenticator_groups_config
content {
security_group = "${authenticator_groups_config.value.security_group}"
}
}

dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
content {
Expand Down
14 changes: 14 additions & 0 deletions modules/beta-public-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ resource "google_container_cluster" "zonal_primary" {
}
}

dynamic "workload_identity_config" {
for_each = var.workload_identity_config
content {
identity_namespace = "${var.project_id}.svc.id.goog"
}
}

dynamic "authenticator_groups_config" {
for_each = var.authenticator_groups_config
content {
security_group = "${authenticator_groups_config.value.security_group}"
}
}

dynamic "master_authorized_networks_config" {
for_each = var.master_authorized_networks_config
content {
Expand Down
13 changes: 13 additions & 0 deletions modules/beta-public-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ locals {
regional = element(concat(google_container_cluster.primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.vertical_pod_autoscaling.0.enabled, [""]), 0)
}

cluster_type_workload_identity_namespace = {
regional = element(concat(google_container_cluster.primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.workload_identity_config.0.identity_namespace, [""]), 0)
}

cluster_type_authenticator_security_group = {
regional = element(concat(google_container_cluster.primary.*.authenticator_groups_config.0.security_group, [""]), 0)
zonal = element(concat(google_container_cluster.zonal_primary.*.authenticator_groups_config.0.security_group, [""]), 0)
}

# /BETA features

cluster_type_output_node_pools_names = {
Expand Down Expand Up @@ -284,6 +295,8 @@ locals {
cluster_pod_security_policy_enabled = local.cluster_type_output_pod_security_policy_enabled[local.cluster_type]
cluster_intranode_visibility_enabled = local.cluster_type_output_intranode_visbility_enabled[local.cluster_type]
cluster_vertical_pod_autoscaling_enabled = local.cluster_type_output_vertical_pod_autoscaling_enabled[local.cluster_type]
cluster_workload_identity_namespace = local.cluster_type_workload_identity_namespace[local.cluster_type]
cluster_authenticator_security_group = local.cluster_type_authenticator_security_group[local.cluster_type]
# /BETA features
}

Expand Down
11 changes: 11 additions & 0 deletions modules/beta-public-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,14 @@ output "vertical_pod_autoscaling_enabled" {
value = local.cluster_vertical_pod_autoscaling_enabled
}


output "workload_identity_namespace" {
description = "Workload Identity Namespace"
value = local.cluster_workload_identity_namespace
}


output "authenticator_security_group" {
description = "Whether veritical pod autoscaling is enabled"
value = local.cluster_authenticator_security_group
}
11 changes: 11 additions & 0 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,14 @@ variable "enable_vertical_pod_autoscaling" {
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"
default = false
}

variable "workload_identity_config" {
description = "Workload Identity allows Kubernetes service accounts to act as a user-managed Google IAM Service Account."
default = []
}

variable "authenticator_groups_config" {
type = list(map(string))
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 gke-security-groups@yourdomain.com"
default = []
}

0 comments on commit 0f0d39d

Please sign in to comment.