Skip to content

Commit f88afab

Browse files
author
Patrick Ziegler
committed
fix: set CLOUD_DNS as default provider for gke autopilot cluster
> Starting in August 2023, the default DNS provider for your new GKE Autopilot > clusters using version 1.25.9-gke.400 or later and 1.26.4-gke.500 or later > becomes Cloud DNS, at no extra charge. This change will be gradual and > expected to be completed by Aug 12th. Without this change, the default setting `PROVIDER_UNSPECIFIED` for `dns_config.cluster_dns` is used with the `google_container_cluster` ressource. Thus running terraform apply to update parts of an deployment will always recreate the cluster: ``` - dns_config { # forces replacement - cluster_dns = "CLOUD_DNS" -> null - cluster_dns_domain = "cluster.local" -> null - cluster_dns_scope = "CLUSTER_SCOPE" -> null } ```
1 parent fd233e5 commit f88afab

File tree

6 files changed

+54
-2
lines changed

6 files changed

+54
-2
lines changed

modules/beta-autopilot-private-cluster/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Then perform the following commands on the root folder:
7575
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
7676
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
7777
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
78+
| cluster\_dns\_domain | The suffix used for all cluster service records. Defaults to `cluster.local`. | `string` | `"cluster.local"` | no |
79+
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED or PLATFORM\_DEFAULT or CLOUD\_DNS (default). | `string` | `"CLOUD_DNS"` | no |
80+
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED or CLUSTER\_SCOPE (default) or VPC\_SCOPE. | `string` | `"CLUSTER_SCOPE"` | no |
7881
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `string` | `null` | no |
7982
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no |
8083
| configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | `bool` | `false` | no |

modules/beta-autopilot-private-cluster/cluster.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ resource "google_container_cluster" "primary" {
135135
}
136136
workload_vulnerability_mode = var.workload_vulnerability_mode
137137
}
138+
139+
dns_config {
140+
cluster_dns = var.cluster_dns_provider
141+
cluster_dns_domain = var.cluster_dns_domain
142+
cluster_dns_scope = var.cluster_dns_scope
143+
}
144+
138145
ip_allocation_policy {
139146
cluster_secondary_range_name = var.ip_range_pods
140147
services_secondary_range_name = var.ip_range_services

modules/beta-autopilot-private-cluster/variables.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,23 @@ variable "database_encryption" {
405405
}]
406406
}
407407

408+
variable "cluster_dns_provider" {
409+
type = string
410+
description = "Which in-cluster DNS provider should be used. PROVIDER_UNSPECIFIED or PLATFORM_DEFAULT or CLOUD_DNS (default)."
411+
default = "CLOUD_DNS"
412+
}
413+
414+
variable "cluster_dns_scope" {
415+
type = string
416+
description = "The scope of access to cluster DNS records. DNS_SCOPE_UNSPECIFIED or CLUSTER_SCOPE (default) or VPC_SCOPE."
417+
default = "CLUSTER_SCOPE"
418+
}
419+
420+
variable "cluster_dns_domain" {
421+
type = string
422+
description = "The suffix used for all cluster service records. Defaults to `cluster.local`."
423+
default = "cluster.local"
424+
}
408425

409426
variable "timeouts" {
410427
type = map(string)
@@ -415,4 +432,3 @@ variable "timeouts" {
415432
error_message = "Only create, update, delete timeouts can be specified."
416433
}
417434
}
418-

modules/beta-autopilot-public-cluster/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Then perform the following commands on the root folder:
6969
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
7070
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
7171
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
72+
| cluster\_dns\_domain | The suffix used for all cluster service records. Defaults to `cluster.local`. | `string` | `"cluster.local"` | no |
73+
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED or PLATFORM\_DEFAULT or CLOUD\_DNS (default). | `string` | `"CLOUD_DNS"` | no |
74+
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED or CLUSTER\_SCOPE (default) or VPC\_SCOPE. | `string` | `"CLUSTER_SCOPE"` | no |
7275
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `string` | `null` | no |
7376
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no |
7477
| configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | `bool` | `false` | no |

modules/beta-autopilot-public-cluster/cluster.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ resource "google_container_cluster" "primary" {
135135
}
136136
workload_vulnerability_mode = var.workload_vulnerability_mode
137137
}
138+
139+
dns_config {
140+
cluster_dns = var.cluster_dns_provider
141+
cluster_dns_domain = var.cluster_dns_domain
142+
cluster_dns_scope = var.cluster_dns_scope
143+
}
144+
138145
ip_allocation_policy {
139146
cluster_secondary_range_name = var.ip_range_pods
140147
services_secondary_range_name = var.ip_range_services

modules/beta-autopilot-public-cluster/variables.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,23 @@ variable "database_encryption" {
375375
}]
376376
}
377377

378+
variable "cluster_dns_provider" {
379+
type = string
380+
description = "Which in-cluster DNS provider should be used. PROVIDER_UNSPECIFIED or PLATFORM_DEFAULT or CLOUD_DNS (default)."
381+
default = "CLOUD_DNS"
382+
}
383+
384+
variable "cluster_dns_scope" {
385+
type = string
386+
description = "The scope of access to cluster DNS records. DNS_SCOPE_UNSPECIFIED or CLUSTER_SCOPE (default) or VPC_SCOPE."
387+
default = "CLUSTER_SCOPE"
388+
}
389+
390+
variable "cluster_dns_domain" {
391+
type = string
392+
description = "The suffix used for all cluster service records. Defaults to `cluster.local`."
393+
default = "cluster.local"
394+
}
378395

379396
variable "timeouts" {
380397
type = map(string)
@@ -385,4 +402,3 @@ variable "timeouts" {
385402
error_message = "Only create, update, delete timeouts can be specified."
386403
}
387404
}
388-

0 commit comments

Comments
 (0)