Skip to content

Commit

Permalink
Add flag to enable GKE Sandbox
Browse files Browse the repository at this point in the history
 * Add `sandbox_enabled` variable to use Sandbox (Fixes terraform-google-modules#240)
  • Loading branch information
paulpalamarchuk committed Aug 21, 2019
1 parent b5fb648 commit 3efa2f3
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Extending the adopted spec, each change should have a link to its corresponding
## [Unreleased]
### Added

* Add `sandbox_enabled` variable to use Sandbox [#23_]
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
* Support for Workload Identity beta feature [#234]

Expand Down Expand Up @@ -168,6 +169,7 @@ Extending the adopted spec, each change should have a link to its corresponding
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0

[#23_]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/23_
[#234]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/234
[#216]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/216
[#214]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/214
Expand Down
8 changes: 8 additions & 0 deletions autogen/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ resource "google_container_cluster" "primary" {
node_metadata = workload_metadata_config.value.node_metadata
}
}

dynamic "sandbox_config" {
for_each = local.cluster_sandbox_enabled

content {
sandbox_type = sandbox_config.value
}
}
{% endif %}
}
}
Expand Down
3 changes: 2 additions & 1 deletion autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ locals {
cluster_node_metadata_config = var.node_metadata == "UNSPECIFIED" ? [] : [{
node_metadata = var.node_metadata
}]


cluster_sandbox_enabled = var.sandbox_enabled ? ["gvisor"] : []
{% endif %}

cluster_output_name = google_container_cluster.primary.name
Expand Down
6 changes: 6 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ variable "node_metadata" {
default = "UNSPECIFIED"
}

variable "sandbox_enabled" {
type = bool
description = "(Beta) Enable GKE Sandbox."
default = false
}

variable "enable_intranode_visibility" {
type = bool
description = "Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network"
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 @@ -189,6 +189,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| sandbox\_enabled | (Beta) Enable GKE Sandbox. | bool | `"false"` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created. | string | `""` | no |
| 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 |
Expand Down
8 changes: 8 additions & 0 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ resource "google_container_cluster" "primary" {
node_metadata = workload_metadata_config.value.node_metadata
}
}

dynamic "sandbox_config" {
for_each = local.cluster_sandbox_enabled

content {
sandbox_type = sandbox_config.value
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ locals {
node_metadata = var.node_metadata
}]

cluster_sandbox_enabled = var.sandbox_enabled ? ["gvisor"] : []

cluster_output_name = google_container_cluster.primary.name
cluster_output_location = google_container_cluster.primary.location
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 @@ -362,6 +362,12 @@ variable "node_metadata" {
default = "UNSPECIFIED"
}

variable "sandbox_enabled" {
type = bool
description = "(Beta) Enable GKE Sandbox."
default = false
}

variable "enable_intranode_visibility" {
type = bool
description = "Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network"
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 @@ -180,6 +180,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
| sandbox\_enabled | (Beta) Enable GKE Sandbox. | bool | `"false"` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created. | string | `""` | no |
| 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 |
Expand Down
8 changes: 8 additions & 0 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ resource "google_container_cluster" "primary" {
node_metadata = workload_metadata_config.value.node_metadata
}
}

dynamic "sandbox_config" {
for_each = local.cluster_sandbox_enabled

content {
sandbox_type = sandbox_config.value
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ locals {
node_metadata = var.node_metadata
}]

cluster_sandbox_enabled = var.sandbox_enabled ? ["gvisor"] : []

cluster_output_name = google_container_cluster.primary.name
cluster_output_location = google_container_cluster.primary.location
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 @@ -338,6 +338,12 @@ variable "node_metadata" {
default = "UNSPECIFIED"
}

variable "sandbox_enabled" {
type = bool
description = "(Beta) Enable GKE Sandbox."
default = false
}

variable "enable_intranode_visibility" {
type = bool
description = "Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network"
Expand Down

0 comments on commit 3efa2f3

Please sign in to comment.