Skip to content

Commit dbda452

Browse files
authored
Merge pull request #241 from paulpalamarchuk/add_sandbox_config_param
Add flag to enable GKE Sandbox
2 parents b65204f + 8792ffd commit dbda452

File tree

12 files changed

+52
-0
lines changed

12 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Extending the adopted spec, each change should have a link to its corresponding
99
## [Unreleased]
1010
### Added
1111

12+
* Added `sandbox_enabled` variable to use GKE Sandbox [#241]
1213
* Added `grant_registry_access` variable to grant Container Registry access to created SA [#236]
1314
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
1415
* Support for Workload Identity beta feature [#234]
@@ -171,6 +172,7 @@ Extending the adopted spec, each change should have a link to its corresponding
171172
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
172173
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0
173174

175+
[#241]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/241
174176
[#250]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/250
175177
[#236]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/236
176178
[#217]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/217

autogen/cluster.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ resource "google_container_cluster" "primary" {
158158
node_metadata = workload_metadata_config.value.node_metadata
159159
}
160160
}
161+
162+
dynamic "sandbox_config" {
163+
for_each = local.cluster_sandbox_enabled
164+
165+
content {
166+
sandbox_type = sandbox_config.value
167+
}
168+
}
161169
{% endif %}
162170
}
163171
}

autogen/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ locals {
7575
security_group = var.authenticator_security_group
7676
}]
7777

78+
cluster_sandbox_enabled = var.sandbox_enabled ? ["gvisor"] : []
79+
7880
{% endif %}
7981

8082
cluster_output_name = google_container_cluster.primary.name

autogen/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ variable "node_metadata" {
371371
default = "UNSPECIFIED"
372372
}
373373

374+
variable "sandbox_enabled" {
375+
type = bool
376+
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it)."
377+
default = false
378+
}
379+
374380
variable "enable_intranode_visibility" {
375381
type = bool
376382
description = "Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network"

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
191191
| region | The region to host the cluster in (required) | string | n/a | yes |
192192
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
193193
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
194+
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it). | bool | `"false"` | no |
194195
| 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 |
195196
| 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 |
196197
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |

modules/beta-private-cluster/cluster.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ resource "google_container_cluster" "primary" {
149149
node_metadata = workload_metadata_config.value.node_metadata
150150
}
151151
}
152+
153+
dynamic "sandbox_config" {
154+
for_each = local.cluster_sandbox_enabled
155+
156+
content {
157+
sandbox_type = sandbox_config.value
158+
}
159+
}
152160
}
153161
}
154162

modules/beta-private-cluster/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ locals {
7070
security_group = var.authenticator_security_group
7171
}]
7272

73+
cluster_sandbox_enabled = var.sandbox_enabled ? ["gvisor"] : []
74+
7375

7476
cluster_output_name = google_container_cluster.primary.name
7577
cluster_output_location = google_container_cluster.primary.location

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ variable "node_metadata" {
368368
default = "UNSPECIFIED"
369369
}
370370

371+
variable "sandbox_enabled" {
372+
type = bool
373+
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it)."
374+
default = false
375+
}
376+
371377
variable "enable_intranode_visibility" {
372378
type = bool
373379
description = "Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network"

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
182182
| region | The region to host the cluster in (required) | string | n/a | yes |
183183
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | bool | `"true"` | no |
184184
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | bool | `"false"` | no |
185+
| sandbox\_enabled | (Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` and `node_version` = `1.12.7-gke.17` or later to use it). | bool | `"false"` | no |
185186
| 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 |
186187
| 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 |
187188
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |

modules/beta-public-cluster/cluster.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ resource "google_container_cluster" "primary" {
149149
node_metadata = workload_metadata_config.value.node_metadata
150150
}
151151
}
152+
153+
dynamic "sandbox_config" {
154+
for_each = local.cluster_sandbox_enabled
155+
156+
content {
157+
sandbox_type = sandbox_config.value
158+
}
159+
}
152160
}
153161
}
154162

0 commit comments

Comments
 (0)