Skip to content

Commit

Permalink
feat: Add protect_config to beta clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Edvin Norling <edvin.norling@kognic.com>
  • Loading branch information
NissesSenap committed Apr 25, 2023
1 parent db51271 commit 026c76d
Show file tree
Hide file tree
Showing 23 changed files with 157 additions and 14 deletions.
7 changes: 7 additions & 0 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ resource "google_container_cluster" "primary" {

{% if beta_cluster %}
networking_mode = "VPC_NATIVE"

protect_config {
workload_config {
audit_mode = var.protect_config.workload_config.audit_mode
}
workload_vulnerability_mode = var.protect_config.workload_vulnerability_mode
}
{% endif %}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
Expand Down
18 changes: 18 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -760,5 +760,23 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "protect_config" {
description = "(beta) Enable/Disable Protect API features for the cluster."
type = object({
workload_vulnerability_mode = string,
workload_config = object({
audit_mode = string
})
}
)

default = {
workload_vulnerability_mode = ""
workload_config = {
audit_mode = "MODE_UNSPECIFIED"
}
}
}
{% endif %}
{% endif %}
4 changes: 2 additions & 2 deletions autogen/main/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-autopilot-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ resource "google_container_cluster" "primary" {
}

networking_mode = "VPC_NATIVE"

protect_config {
workload_config {
audit_mode = var.protect_config.workload_config.audit_mode
}
workload_vulnerability_mode = var.protect_config.workload_vulnerability_mode
}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-autopilot-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-autopilot-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ resource "google_container_cluster" "primary" {
}

networking_mode = "VPC_NATIVE"

protect_config {
workload_config {
audit_mode = var.protect_config.workload_config.audit_mode
}
workload_vulnerability_mode = var.protect_config.workload_vulnerability_mode
}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-autopilot-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
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 @@ -247,6 +247,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| protect\_config | (beta) Enable/Disable Protect API features for the cluster. | <pre>object({<br> workload_vulnerability_mode = string,<br> workload_config = object({<br> audit_mode = string<br> })<br> }<br> )</pre> | <pre>{<br> "workload_config": {<br> "audit_mode": "MODE_UNSPECIFIED"<br> },<br> "workload_vulnerability_mode": ""<br>}</pre> | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
| registry\_project\_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the `grant_registry_access` variable is set to `true`, the `storage.objectViewer` and `artifactregsitry.reader` roles are assigned on these projects. | `list(string)` | `[]` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ resource "google_container_cluster" "primary" {
datapath_provider = var.datapath_provider

networking_mode = "VPC_NATIVE"

protect_config {
workload_config {
audit_mode = var.protect_config.workload_config.audit_mode
}
workload_vulnerability_mode = var.protect_config.workload_vulnerability_mode
}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
18 changes: 18 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,21 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "protect_config" {
description = "(beta) Enable/Disable Protect API features for the cluster."
type = object({
workload_vulnerability_mode = string,
workload_config = object({
audit_mode = string
})
}
)

default = {
workload_vulnerability_mode = ""
workload_config = {
audit_mode = "MODE_UNSPECIFIED"
}
}
}
4 changes: 2 additions & 2 deletions modules/beta-private-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| protect\_config | (beta) Enable/Disable Protect API features for the cluster. | <pre>object({<br> workload_vulnerability_mode = string,<br> workload_config = object({<br> audit_mode = string<br> })<br> }<br> )</pre> | <pre>{<br> "workload_config": {<br> "audit_mode": "MODE_UNSPECIFIED"<br> },<br> "workload_vulnerability_mode": ""<br>}</pre> | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
| registry\_project\_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the `grant_registry_access` variable is set to `true`, the `storage.objectViewer` and `artifactregsitry.reader` roles are assigned on these projects. | `list(string)` | `[]` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ resource "google_container_cluster" "primary" {
datapath_provider = var.datapath_provider

networking_mode = "VPC_NATIVE"

protect_config {
workload_config {
audit_mode = var.protect_config.workload_config.audit_mode
}
workload_vulnerability_mode = var.protect_config.workload_vulnerability_mode
}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
18 changes: 18 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,21 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "protect_config" {
description = "(beta) Enable/Disable Protect API features for the cluster."
type = object({
workload_vulnerability_mode = string,
workload_config = object({
audit_mode = string
})
}
)

default = {
workload_vulnerability_mode = ""
workload_config = {
audit_mode = "MODE_UNSPECIFIED"
}
}
}
4 changes: 2 additions & 2 deletions modules/beta-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
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 @@ -236,6 +236,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| protect\_config | (beta) Enable/Disable Protect API features for the cluster. | <pre>object({<br> workload_vulnerability_mode = string,<br> workload_config = object({<br> audit_mode = string<br> })<br> }<br> )</pre> | <pre>{<br> "workload_config": {<br> "audit_mode": "MODE_UNSPECIFIED"<br> },<br> "workload_vulnerability_mode": ""<br>}</pre> | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
| registry\_project\_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the `grant_registry_access` variable is set to `true`, the `storage.objectViewer` and `artifactregsitry.reader` roles are assigned on these projects. | `list(string)` | `[]` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ resource "google_container_cluster" "primary" {
datapath_provider = var.datapath_provider

networking_mode = "VPC_NATIVE"

protect_config {
workload_config {
audit_mode = var.protect_config.workload_config.audit_mode
}
workload_vulnerability_mode = var.protect_config.workload_vulnerability_mode
}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
18 changes: 18 additions & 0 deletions modules/beta-public-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,21 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "protect_config" {
description = "(beta) Enable/Disable Protect API features for the cluster."
type = object({
workload_vulnerability_mode = string,
workload_config = object({
audit_mode = string
})
}
)

default = {
workload_vulnerability_mode = ""
workload_config = {
audit_mode = "MODE_UNSPECIFIED"
}
}
}
4 changes: 2 additions & 2 deletions modules/beta-public-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| protect\_config | (beta) Enable/Disable Protect API features for the cluster. | <pre>object({<br> workload_vulnerability_mode = string,<br> workload_config = object({<br> audit_mode = string<br> })<br> }<br> )</pre> | <pre>{<br> "workload_config": {<br> "audit_mode": "MODE_UNSPECIFIED"<br> },<br> "workload_vulnerability_mode": ""<br>}</pre> | no |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
| registry\_project\_ids | Projects holding Google Container Registries. If empty, we use the cluster project. If a service account is created and the `grant_registry_access` variable is set to `true`, the `storage.objectViewer` and `artifactregsitry.reader` roles are assigned on these projects. | `list(string)` | `[]` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ resource "google_container_cluster" "primary" {
datapath_provider = var.datapath_provider

networking_mode = "VPC_NATIVE"

protect_config {
workload_config {
audit_mode = var.protect_config.workload_config.audit_mode
}
workload_vulnerability_mode = var.protect_config.workload_vulnerability_mode
}
ip_allocation_policy {
cluster_secondary_range_name = var.ip_range_pods
services_secondary_range_name = var.ip_range_services
Expand Down
18 changes: 18 additions & 0 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,21 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "protect_config" {
description = "(beta) Enable/Disable Protect API features for the cluster."
type = object({
workload_vulnerability_mode = string,
workload_config = object({
audit_mode = string
})
}
)

default = {
workload_vulnerability_mode = ""
workload_config = {
audit_mode = "MODE_UNSPECIFIED"
}
}
}
4 changes: 2 additions & 2 deletions modules/beta-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.51.0, < 5.0"
version = ">= 4.63.0, < 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down

0 comments on commit 026c76d

Please sign in to comment.