Skip to content

Commit e105bb5

Browse files
authored
feat: Add beta support for confidential_nodes (terraform-google-modules#1040)
* Add beta support for confidential_nodes * Cannot use a null value in for_each * Add example and test * Add example and test * Update test name * Review Comments * Review Comments * Review Comments Co-authored-by: Stenal P Jolly <stenalpjolly@google.com>
1 parent 8e92f6e commit e105bb5

File tree

21 files changed

+78
-0
lines changed

21 files changed

+78
-0
lines changed

autogen/main/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ The node_pools variable takes the following parameters:
179179
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
180180
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
181181
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
182+
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
182183
{% endif %}
183184
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
184185
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |

autogen/main/cluster.tf.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ resource "google_container_cluster" "primary" {
5252
channel = release_channel.value.channel
5353
}
5454
}
55+
{% if beta_cluster %}
56+
dynamic "confidential_nodes" {
57+
for_each = local.confidential_node_config
58+
content {
59+
enabled = confidential_nodes.value.enabled
60+
}
61+
}
62+
{% endif %}
5563

5664
subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"
5765

autogen/main/main.tf.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ locals {
188188
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
189189
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled
190190
cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled
191+
confidential_node_config = var.enable_confidential_nodes == true ? [{ enabled = true }] : []
191192

192193
# /BETA features
193194
{% endif %}

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,12 @@ variable "shadow_firewall_rules_priority" {
614614
}
615615

616616
{% if beta_cluster %}
617+
variable "enable_confidential_nodes" {
618+
type = bool
619+
description = "An optional flag to enable confidential node config."
620+
default = false
621+
}
622+
617623
variable "disable_default_snat" {
618624
type = bool
619625
description = "Whether to disable the default SNAT to support the private use of public IP addresses"

examples/simple_regional_private_beta/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ module "gke" {
6464
},
6565
]
6666

67+
enable_confidential_nodes = true
68+
6769
istio = var.istio
6870
cloudrun = var.cloudrun
6971
dns_cache = var.dns_cache

modules/beta-private-cluster-update-variant/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Then perform the following commands on the root folder:
180180
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | `bool` | `true` | no |
181181
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
182182
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
183+
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
183184
| enable\_intranode\_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | `bool` | `false` | no |
184185
| enable\_kubernetes\_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | `bool` | `false` | no |
185186
| enable\_l4\_ilb\_subsetting | Enable L4 ILB Subsetting on the cluster | `bool` | `false` | no |
@@ -301,6 +302,7 @@ The node_pools variable takes the following parameters:
301302
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
302303
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
303304
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
305+
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
304306
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
305307
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
306308
| effect | Effect for the taint | | Required |

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ resource "google_container_cluster" "primary" {
4848
channel = release_channel.value.channel
4949
}
5050
}
51+
dynamic "confidential_nodes" {
52+
for_each = local.confidential_node_config
53+
content {
54+
enabled = confidential_nodes.value.enabled
55+
}
56+
}
5157

5258
subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"
5359

modules/beta-private-cluster-update-variant/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ locals {
170170
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
171171
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled
172172
cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled
173+
confidential_node_config = var.enable_confidential_nodes == true ? [{ enabled = true }] : []
173174

174175
# /BETA features
175176

modules/beta-private-cluster-update-variant/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ variable "shadow_firewall_rules_priority" {
593593
default = 999
594594
}
595595

596+
variable "enable_confidential_nodes" {
597+
type = bool
598+
description = "An optional flag to enable confidential node config."
599+
default = false
600+
}
601+
596602
variable "disable_default_snat" {
597603
type = bool
598604
description = "Whether to disable the default SNAT to support the private use of public IP addresses"

modules/beta-private-cluster/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Then perform the following commands on the root folder:
158158
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | `bool` | `true` | no |
159159
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
160160
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
161+
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
161162
| enable\_intranode\_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | `bool` | `false` | no |
162163
| enable\_kubernetes\_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | `bool` | `false` | no |
163164
| enable\_l4\_ilb\_subsetting | Enable L4 ILB Subsetting on the cluster | `bool` | `false` | no |
@@ -279,6 +280,7 @@ The node_pools variable takes the following parameters:
279280
| cpu_manager_policy | The CPU manager policy on the node. One of "none" or "static". | "static" | Optional |
280281
| cpu_cfs_quota | Enforces the Pod's CPU limit. Setting this value to false means that the CPU limits for Pods are ignored | null | Optional |
281282
| cpu_cfs_quota_period | The CPU CFS quota period value, which specifies the period of how often a cgroup's access to CPU resources should be reallocated | null | Optional |
283+
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
282284
| disk_size_gb | Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB | 100 | Optional |
283285
| disk_type | Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') | pd-standard | Optional |
284286
| effect | Effect for the taint | | Required |

0 commit comments

Comments
 (0)