Skip to content

Commit de8e1d5

Browse files
authored
feat: Add support for enabling Nodelocal dns cache (var.dns_cache) (#477)
* added support for node local dns cache * config block * updates to testing Signed-off-by: Jonathan Meyers <[email protected]> * generate docs again for example change
1 parent 1883311 commit de8e1d5

File tree

41 files changed

+130
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+130
-12
lines changed

autogen/main/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module "gke" {
8484
{% if beta_cluster %}
8585
istio = true
8686
cloudrun = true
87+
dns_cache = false
8788
{% endif %}
8889
8990
node_pools = [

autogen/main/cluster.tf.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ resource "google_container_cluster" "primary" {
157157
disabled = cloudrun_config.value.disabled
158158
}
159159
}
160+
161+
dns_cache_config {
162+
enabled = var.dns_cache
163+
}
160164
{% endif %}
161165
}
162166

autogen/main/main.tf.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ locals {
160160
# BETA features
161161
cluster_istio_enabled = ! local.cluster_output_istio_disabled
162162
cluster_cloudrun_enabled = var.cloudrun
163+
cluster_dns_cache_enabled = var.dns_cache
163164
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
164165
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled
165166
cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled

autogen/main/outputs.tf.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ output "cloudrun_enabled" {
138138
value = local.cluster_cloudrun_enabled
139139
}
140140

141+
output "dns_cache_enabled" {
142+
description = "Whether DNS Cache enabled"
143+
value = local.cluster_dns_cache_enabled
144+
}
145+
141146
output "pod_security_policy_enabled" {
142147
description = "Whether pod security policy is enabled"
143148
value = local.cluster_pod_security_policy_enabled

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ variable "istio_auth" {
399399
default = "AUTH_MUTUAL_TLS"
400400
}
401401

402+
variable "dns_cache" {
403+
type = bool
404+
description = "(Beta) The status of the NodeLocal DNSCache addon."
405+
default = false
406+
}
407+
402408
variable "database_encryption" {
403409
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
404410
type = list(object({ state = string, key_name = string }))

autogen/safer-cluster/main.tf.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ module "gke" {
122122

123123
cloudrun = var.cloudrun
124124

125+
dns_cache = var.dns_cache
126+
125127
default_max_pods_per_node = var.default_max_pods_per_node
126128

127129
database_encryption = var.database_encryption

autogen/safer-cluster/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ variable "istio_auth" {
237237
default = "AUTH_MUTUAL_TLS"
238238
}
239239

240+
variable "dns_cache" {
241+
type = bool
242+
description = "(Beta) The status of the NodeLocal DNSCache addon."
243+
default = false
244+
}
245+
240246
variable "default_max_pods_per_node" {
241247
description = "The maximum number of pods to schedule per node"
242248
default = 110

examples/node_pool/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.12.0"
22+
version = "~> 3.14.0"
2323
region = var.region
2424
}
2525

examples/node_pool_update_variant/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.12.0"
22+
version = "~> 3.14.0"
2323
region = var.region
2424
}
2525

examples/node_pool_update_variant_beta/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.12.0"
22+
version = "~> 3.14.0"
2323
credentials = file(var.credentials_path)
2424
region = var.region
2525
}

examples/safer_cluster/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ locals {
3030
}
3131

3232
provider "google" {
33-
version = "~> 3.12.0"
33+
version = "~> 3.14.0"
3434
}
3535

3636
provider "google-beta" {
37-
version = "~> 3.12.0"
37+
version = "~> 3.14.0"
3838
}
3939

4040
module "gke" {

examples/simple_regional_beta/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This example illustrates how to create a simple cluster with beta features.
1111
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
1212
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
1313
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | object | `<list>` | no |
14+
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | bool | `"false"` | no |
1415
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
1516
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
1617
| ip\_range\_services | The secondary ip range to use for services | string | n/a | yes |

examples/simple_regional_beta/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.12.0"
22+
version = "~> 3.14.0"
2323
region = var.region
2424
}
2525

@@ -38,6 +38,7 @@ module "gke" {
3838
service_account = var.compute_engine_service_account
3939
istio = var.istio
4040
cloudrun = var.cloudrun
41+
dns_cache = var.dns_cache
4142
node_metadata = var.node_metadata
4243
sandbox_enabled = var.sandbox_enabled
4344
remove_default_node_pool = var.remove_default_node_pool

examples/simple_regional_beta/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ variable "cloudrun" {
5757
default = true
5858
}
5959

60+
variable "dns_cache" {
61+
type = bool
62+
description = "(Beta) The status of the NodeLocal DNSCache addon."
63+
default = false
64+
}
65+
6066
variable "node_metadata" {
6167
description = "Specifies how node metadata is exposed to the workload running on the node"
6268
default = "SECURE"

examples/simple_regional_private_beta/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.12.0"
22+
version = "~> 3.14.0"
2323
region = var.region
2424
}
2525

2626
provider "google-beta" {
27-
version = "~> 3.12.0"
27+
version = "~> 3.14.0"
2828
region = var.region
2929
}
3030

@@ -56,8 +56,9 @@ module "gke" {
5656
},
5757
]
5858

59-
istio = var.istio
60-
cloudrun = var.cloudrun
59+
istio = var.istio
60+
cloudrun = var.cloudrun
61+
dns_cache = var.dns_cache
6162
}
6263

6364
data "google_client_config" "default" {

examples/simple_regional_private_beta/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ variable "cloudrun" {
5757
default = true
5858
}
5959

60+
variable "dns_cache" {
61+
description = "Boolean to enable / disable NodeLocal DNSCache "
62+
default = false
63+
}

examples/workload_identity/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google" {
22-
version = "~> 3.12.0"
22+
version = "~> 3.14.0"
2323
region = var.region
2424
}
2525

examples/workload_metadata_config/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.12.0"
22+
version = "~> 3.14.0"
2323
region = var.region
2424
}
2525

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module "gke" {
7676
master_ipv4_cidr_block = "10.0.0.0/28"
7777
istio = true
7878
cloudrun = true
79+
dns_cache = false
7980
8081
node_pools = [
8182
{
@@ -169,6 +170,7 @@ Then perform the following commands on the root folder:
169170
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | bool | `"false"` | no |
170171
| description | The description of the cluster | string | `""` | no |
171172
| 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 |
173+
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | bool | `"false"` | no |
172174
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
173175
| 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 |
174176
| 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 |
@@ -232,6 +234,7 @@ Then perform the following commands on the root folder:
232234
|------|-------------|
233235
| ca\_certificate | Cluster ca certificate (base64 encoded) |
234236
| cloudrun\_enabled | Whether CloudRun enabled |
237+
| dns\_cache\_enabled | Whether DNS Cache enabled |
235238
| endpoint | Cluster endpoint |
236239
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
237240
| http\_load\_balancing\_enabled | Whether http load balancing enabled |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ resource "google_container_cluster" "primary" {
142142
disabled = cloudrun_config.value.disabled
143143
}
144144
}
145+
146+
dns_cache_config {
147+
enabled = var.dns_cache
148+
}
145149
}
146150

147151
ip_allocation_policy {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ locals {
145145
# BETA features
146146
cluster_istio_enabled = ! local.cluster_output_istio_disabled
147147
cluster_cloudrun_enabled = var.cloudrun
148+
cluster_dns_cache_enabled = var.dns_cache
148149
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
149150
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled
150151
cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ output "cloudrun_enabled" {
135135
value = local.cluster_cloudrun_enabled
136136
}
137137

138+
output "dns_cache_enabled" {
139+
description = "Whether DNS Cache enabled"
140+
value = local.cluster_dns_cache_enabled
141+
}
142+
138143
output "pod_security_policy_enabled" {
139144
description = "Whether pod security policy is enabled"
140145
value = local.cluster_pod_security_policy_enabled

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ variable "istio_auth" {
392392
default = "AUTH_MUTUAL_TLS"
393393
}
394394

395+
variable "dns_cache" {
396+
type = bool
397+
description = "(Beta) The status of the NodeLocal DNSCache addon."
398+
default = false
399+
}
400+
395401
variable "database_encryption" {
396402
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
397403
type = list(object({ state = string, key_name = string }))

modules/beta-private-cluster/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module "gke" {
5454
master_ipv4_cidr_block = "10.0.0.0/28"
5555
istio = true
5656
cloudrun = true
57+
dns_cache = false
5758
5859
node_pools = [
5960
{
@@ -147,6 +148,7 @@ Then perform the following commands on the root folder:
147148
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | bool | `"false"` | no |
148149
| description | The description of the cluster | string | `""` | no |
149150
| 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 |
151+
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | bool | `"false"` | no |
150152
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
151153
| 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 |
152154
| 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 |
@@ -210,6 +212,7 @@ Then perform the following commands on the root folder:
210212
|------|-------------|
211213
| ca\_certificate | Cluster ca certificate (base64 encoded) |
212214
| cloudrun\_enabled | Whether CloudRun enabled |
215+
| dns\_cache\_enabled | Whether DNS Cache enabled |
213216
| endpoint | Cluster endpoint |
214217
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
215218
| http\_load\_balancing\_enabled | Whether http load balancing enabled |

modules/beta-private-cluster/cluster.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ resource "google_container_cluster" "primary" {
142142
disabled = cloudrun_config.value.disabled
143143
}
144144
}
145+
146+
dns_cache_config {
147+
enabled = var.dns_cache
148+
}
145149
}
146150

147151
ip_allocation_policy {

modules/beta-private-cluster/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ locals {
145145
# BETA features
146146
cluster_istio_enabled = ! local.cluster_output_istio_disabled
147147
cluster_cloudrun_enabled = var.cloudrun
148+
cluster_dns_cache_enabled = var.dns_cache
148149
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
149150
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled
150151
cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled

modules/beta-private-cluster/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ output "cloudrun_enabled" {
135135
value = local.cluster_cloudrun_enabled
136136
}
137137

138+
output "dns_cache_enabled" {
139+
description = "Whether DNS Cache enabled"
140+
value = local.cluster_dns_cache_enabled
141+
}
142+
138143
output "pod_security_policy_enabled" {
139144
description = "Whether pod security policy is enabled"
140145
value = local.cluster_pod_security_policy_enabled

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ variable "istio_auth" {
392392
default = "AUTH_MUTUAL_TLS"
393393
}
394394

395+
variable "dns_cache" {
396+
type = bool
397+
description = "(Beta) The status of the NodeLocal DNSCache addon."
398+
default = false
399+
}
400+
395401
variable "database_encryption" {
396402
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
397403
type = list(object({ state = string, key_name = string }))

modules/beta-public-cluster/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module "gke" {
3636
network_policy = true
3737
istio = true
3838
cloudrun = true
39+
dns_cache = false
3940
4041
node_pools = [
4142
{
@@ -128,6 +129,7 @@ Then perform the following commands on the root folder:
128129
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | string | `"110"` | no |
129130
| description | The description of the cluster | string | `""` | no |
130131
| 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 |
132+
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | bool | `"false"` | no |
131133
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
132134
| 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 |
133135
| 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 |
@@ -188,6 +190,7 @@ Then perform the following commands on the root folder:
188190
|------|-------------|
189191
| ca\_certificate | Cluster ca certificate (base64 encoded) |
190192
| cloudrun\_enabled | Whether CloudRun enabled |
193+
| dns\_cache\_enabled | Whether DNS Cache enabled |
191194
| endpoint | Cluster endpoint |
192195
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
193196
| http\_load\_balancing\_enabled | Whether http load balancing enabled |

modules/beta-public-cluster/cluster.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ resource "google_container_cluster" "primary" {
142142
disabled = cloudrun_config.value.disabled
143143
}
144144
}
145+
146+
dns_cache_config {
147+
enabled = var.dns_cache
148+
}
145149
}
146150

147151
ip_allocation_policy {

modules/beta-public-cluster/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ locals {
145145
# BETA features
146146
cluster_istio_enabled = ! local.cluster_output_istio_disabled
147147
cluster_cloudrun_enabled = var.cloudrun
148+
cluster_dns_cache_enabled = var.dns_cache
148149
cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled
149150
cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled
150151
cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled

modules/beta-public-cluster/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ output "cloudrun_enabled" {
129129
value = local.cluster_cloudrun_enabled
130130
}
131131

132+
output "dns_cache_enabled" {
133+
description = "Whether DNS Cache enabled"
134+
value = local.cluster_dns_cache_enabled
135+
}
136+
132137
output "pod_security_policy_enabled" {
133138
description = "Whether pod security policy is enabled"
134139
value = local.cluster_pod_security_policy_enabled

0 commit comments

Comments
 (0)