Skip to content

Commit bf032c6

Browse files
authored
Merge branch 'master' into filestore_autopilot
2 parents 250a606 + 375d27c commit bf032c6

File tree

98 files changed

+1506
-247
lines changed

Some content is hidden

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

98 files changed

+1506
-247
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ Then perform the following commands on the root folder:
190190
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
191191
| identity\_namespace | The workload pool to attach all Kubernetes service accounts to. (Default value of `enabled` automatically sets project-based pool `[project_id].svc.id.goog`) | `string` | `"enabled"` | no |
192192
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | `number` | `0` | no |
193+
| insecure\_kubelet\_readonly\_port\_enabled | Whether or not to set `insecure_kubelet_readonly_port_enabled` for node pool defaults and autopilot clusters. Note: this can be set at the node pool level separately within `node_pools`. | `bool` | `null` | no |
193194
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | `bool` | `false` | no |
194195
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | `string` | `"60s"` | no |
195196
| ip\_range\_pods | The _name_ of the secondary subnet ip range to use for pods | `string` | n/a | yes |
@@ -319,6 +320,7 @@ The node_pools variable takes the following parameters:
319320
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
320321
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
321322
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
323+
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
322324
| key | The key required for the taint | | Required |
323325
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
324326
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |

autogen/main/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ The node_pools variable takes the following parameters:
213213
| gpu_partition_size | Size of partitions to create on the GPU | null | Optional |
214214
| image_type | The image type to use for this node. Note that changing the image type will delete and recreate all nodes in the node pool | COS_CONTAINERD | Optional |
215215
| initial_node_count | The initial number of nodes for the pool. In regional or multi-zonal clusters, this is the number of nodes per zone. Changing this will force recreation of the resource. Defaults to the value of min_count | " " | Optional |
216+
| insecure_kubelet_readonly_port_enabled | (boolean) Whether or not to enable the insecure Kubelet readonly port. | null | Optional |
216217
| key | The key required for the taint | | Required |
217218
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
218219
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |

autogen/main/cluster.tf.tmpl

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,21 @@ resource "google_container_cluster" "primary" {
530530
}
531531
}
532532

533+
dynamic "kubelet_config" {
534+
for_each = length(setintersection(
535+
keys(var.node_pools[0]),
536+
["cpu_manager_policy", "cpu_cfs_quota", "cpu_cfs_quota_period", "insecure_kubelet_readonly_port_enabled", "pod_pids_limit"]
537+
)) != 0 || var.insecure_kubelet_readonly_port_enabled != null ? [1] : []
538+
539+
content {
540+
cpu_manager_policy = lookup(var.node_pools[0], "cpu_manager_policy", "static")
541+
cpu_cfs_quota = lookup(var.node_pools[0], "cpu_cfs_quota", null)
542+
cpu_cfs_quota_period = lookup(var.node_pools[0], "cpu_cfs_quota_period", null)
543+
insecure_kubelet_readonly_port_enabled = lookup(var.node_pools[0], "insecure_kubelet_readonly_port_enabled", var.insecure_kubelet_readonly_port_enabled) != null ? upper(tostring(lookup(var.node_pools[0], "insecure_kubelet_readonly_port_enabled", var.insecure_kubelet_readonly_port_enabled))) : null
544+
pod_pids_limit = lookup(var.node_pools[0], "pod_pids_limit", null)
545+
}
546+
}
547+
533548
service_account = lookup(var.node_pools[0], "service_account", local.service_account)
534549

535550
tags = concat(
@@ -661,7 +676,6 @@ resource "google_container_cluster" "primary" {
661676
}
662677
}
663678
}
664-
{% if beta_cluster %}
665679

666680
node_pool_defaults {
667681
node_config_defaults {
@@ -675,15 +689,17 @@ resource "google_container_cluster" "primary" {
675689
}
676690
{% endif %}
677691
{% if autopilot_cluster != true %}
692+
{% if beta_cluster %}
678693
gcfs_config {
679694
enabled = var.enable_gcfs
680695
}
681696
{% endif %}
697+
insecure_kubelet_readonly_port_enabled = var.insecure_kubelet_readonly_port_enabled != null ? upper(tostring(var.insecure_kubelet_readonly_port_enabled)) : null
698+
{% endif %}
682699
}
683700
}
684-
{% endif %}
685-
{% if beta_cluster %}
686701

702+
{% if beta_cluster %}
687703
depends_on = [google_project_iam_member.service_agent]
688704
{% endif %}
689705
}
@@ -706,6 +722,9 @@ locals {
706722
"enable_secure_boot",
707723
"enable_integrity_monitoring",
708724
"local_ssd_count",
725+
{% if beta_cluster %}
726+
"local_ssd_ephemeral_count",
727+
{% endif %}
709728
"machine_type",
710729
"placement_policy",
711730
"max_pods_per_node",
@@ -723,6 +742,7 @@ locals {
723742
"reservation_affinity_key",
724743
"reservation_affinity_values",
725744
"enable_confidential_nodes",
745+
"secondary_boot_disk",
726746
]
727747
}
728748

@@ -1042,14 +1062,15 @@ resource "google_container_node_pool" "windows_pools" {
10421062
dynamic "kubelet_config" {
10431063
for_each = length(setintersection(
10441064
keys(each.value),
1045-
["cpu_manager_policy", "cpu_cfs_quota", "cpu_cfs_quota_period", "pod_pids_limit"]
1065+
["cpu_manager_policy", "cpu_cfs_quota", "cpu_cfs_quota_period", "insecure_kubelet_readonly_port_enabled", "pod_pids_limit"]
10461066
)) != 0 ? [1] : []
10471067

10481068
content {
1049-
cpu_manager_policy = lookup(each.value, "cpu_manager_policy", "static")
1050-
cpu_cfs_quota = lookup(each.value, "cpu_cfs_quota", null)
1051-
cpu_cfs_quota_period = lookup(each.value, "cpu_cfs_quota_period", null)
1052-
pod_pids_limit = lookup(each.value, "pod_pids_limit", null)
1069+
cpu_manager_policy = lookup(each.value, "cpu_manager_policy", "static")
1070+
cpu_cfs_quota = lookup(each.value, "cpu_cfs_quota", null)
1071+
cpu_cfs_quota_period = lookup(each.value, "cpu_cfs_quota_period", null)
1072+
insecure_kubelet_readonly_port_enabled = lookup(each.value, "insecure_kubelet_readonly_port_enabled", null) != null ? upper(tostring(each.value.insecure_kubelet_readonly_port_enabled)) : null
1073+
pod_pids_limit = lookup(each.value, "pod_pids_limit", null)
10531074
}
10541075
}
10551076
{% if beta_cluster %}
@@ -1088,7 +1109,7 @@ resource "google_container_node_pool" "windows_pools" {
10881109
}
10891110

10901111
dynamic "confidential_nodes" {
1091-
for_each = lookup(each.value, "enable_confidential_nodes", null) != null ? [each.value.confidential_nodes] : []
1112+
for_each = lookup(each.value, "enable_confidential_nodes", null) != null ? [each.value.enable_confidential_nodes] : []
10921113
content {
10931114
enabled = confidential_nodes.value
10941115
}

autogen/main/dns.tf.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Manage kube-dns configmaps
2121
*****************************************/
2222

23-
resource "kubernetes_config_map_v1_data" "kube-dns" {
23+
resource "kubernetes_config_map_v1_data" "kube_dns" {
2424
count = local.custom_kube_dns_config && !local.upstream_nameservers_config ? 1 : 0
2525

2626
metadata {
@@ -44,7 +44,7 @@ EOF
4444
]
4545
}
4646

47-
resource "kubernetes_config_map_v1_data" "kube-dns-upstream-namservers" {
47+
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers" {
4848
count = !local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0
4949

5050
metadata {
@@ -68,7 +68,7 @@ EOF
6868
]
6969
}
7070

71-
resource "kubernetes_config_map_v1_data" "kube-dns-upstream-nameservers-and-stub-domains" {
71+
resource "kubernetes_config_map_v1_data" "kube_dns_upstream_nameservers_and_stub_domains" {
7272
count = local.custom_kube_dns_config && local.upstream_nameservers_config ? 1 : 0
7373

7474
metadata {

autogen/main/masq.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/******************************************
2020
Create ip-masq-agent confimap
2121
*****************************************/
22-
resource "kubernetes_config_map" "ip-masq-agent" {
22+
resource "kubernetes_config_map" "ip_masq_agent" {
2323
count = var.configure_ip_masq ? 1 : 0
2424

2525
metadata {

autogen/main/moved.tf.tmpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# Updates for kebab to snake case, to match best practices and Google style.
18+
moved {
19+
from = kubernetes_config_map_v1_data.kube-dns
20+
to = kubernetes_config_map_v1_data.kube_dns
21+
}
22+
23+
# Typo fix and snake case at the same time
24+
moved {
25+
from = kubernetes_config_map_v1_data.kube-dns-upstream-namservers
26+
to = kubernetes_config_map_v1_data.kube_dns_upstream_nameservers
27+
}
28+
29+
moved {
30+
from = kubernetes_config_map_v1_data.kube-dns-upstream-nameservers-and-stub-domains
31+
to = kubernetes_config_map_v1_data.kube_dns_upstream_nameservers_and_stub_domains
32+
}
33+
34+
moved {
35+
from = kubernetes_config_map.ip-masq-agent
36+
to = kubernetes_config_map.ip_masq_agent
37+
}
38+
39+
moved {
40+
from = google_project_iam_member.cluster_service_account-nodeService_account
41+
to = google_project_iam_member.cluster_service_account_node_service_account
42+
}
43+
44+
moved {
45+
from = google_project_iam_member.cluster_service_account-metric_writer
46+
to = google_project_iam_member.cluster_service_account_metric_writer
47+
}
48+
49+
moved {
50+
from = google_project_iam_member.cluster_service_account-resourceMetadata-writer
51+
to = google_project_iam_member.cluster_service_account_resource_metadata_writer
52+
}
53+
54+
moved {
55+
from = google_project_iam_member.cluster_service_account-gcr
56+
to = google_project_iam_member.cluster_service_account_gcr
57+
}
58+
59+
moved {
60+
from = google_project_iam_member.cluster_service_account-artifact-registry
61+
to = google_project_iam_member.cluster_service_account_artifact_registry
62+
}

autogen/main/sa.tf.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,35 @@ resource "google_service_account" "cluster_service_account" {
4646
display_name = "Terraform-managed service account for cluster ${var.name}"
4747
}
4848

49-
resource "google_project_iam_member" "cluster_service_account-nodeService_account" {
49+
resource "google_project_iam_member" "cluster_service_account_node_service_account" {
5050
count = var.create_service_account ? 1 : 0
5151
project = google_service_account.cluster_service_account[0].project
5252
role = "roles/container.defaultNodeServiceAccount"
5353
member = google_service_account.cluster_service_account[0].member
5454
}
5555

56-
resource "google_project_iam_member" "cluster_service_account-metric_writer" {
56+
resource "google_project_iam_member" "cluster_service_account_metric_writer" {
5757
count = var.create_service_account ? 1 : 0
5858
project = google_service_account.cluster_service_account[0].project
5959
role = "roles/monitoring.metricWriter"
6060
member = google_service_account.cluster_service_account[0].member
6161
}
6262

63-
resource "google_project_iam_member" "cluster_service_account-resourceMetadata-writer" {
63+
resource "google_project_iam_member" "cluster_service_account_resource_metadata_writer" {
6464
count = var.create_service_account ? 1 : 0
6565
project = google_service_account.cluster_service_account[0].project
6666
role = "roles/stackdriver.resourceMetadata.writer"
6767
member = google_service_account.cluster_service_account[0].member
6868
}
6969

70-
resource "google_project_iam_member" "cluster_service_account-gcr" {
70+
resource "google_project_iam_member" "cluster_service_account_gcr" {
7171
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
7272
project = each.key
7373
role = "roles/storage.objectViewer"
7474
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
7575
}
7676

77-
resource "google_project_iam_member" "cluster_service_account-artifact-registry" {
77+
resource "google_project_iam_member" "cluster_service_account_artifact_registry" {
7878
for_each = var.create_service_account && var.grant_registry_access ? toset(local.registry_projects_list) : []
7979
project = each.key
8080
role = "roles/artifactregistry.reader"

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ variable "service_external_ips" {
109109
}
110110

111111
{% if autopilot_cluster != true %}
112+
variable "insecure_kubelet_readonly_port_enabled" {
113+
type = bool
114+
description = "Whether or not to set `insecure_kubelet_readonly_port_enabled` for node pool defaults and autopilot clusters. Note: this can be set at the node pool level separately within `node_pools`."
115+
default = null
116+
}
117+
112118
variable "datapath_provider" {
113119
type = string
114120
description = "The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature."

autogen/main/versions.tf.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ terraform {
2424
required_providers {
2525
google = {
2626
source = "hashicorp/google"
27-
version = ">= 5.40.0, < 7"
27+
version = ">= 5.44.2, !=6.0.0, !=6.0.1, !=6.1.0, !=6.2.0, !=6.3.0, !=6.4.0, !=6.5.0, !=6.6.0, < 7"
2828
}
2929
google-beta = {
3030
source = "hashicorp/google-beta"
31-
version = ">= 5.40.0, < 7"
31+
version = ">= 5.44.2, !=6.0.0, !=6.0.1, !=6.1.0, !=6.2.0, !=6.3.0, !=6.4.0, !=6.5.0, !=6.6.0, < 7"
3232
}
3333
kubernetes = {
3434
source = "hashicorp/kubernetes"
@@ -86,7 +86,7 @@ terraform {
8686
required_providers {
8787
google = {
8888
source = "hashicorp/google"
89-
version = ">= 5.40.0, < 7"
89+
version = ">= 5.44.2, !=6.0.0, !=6.0.1, !=6.1.0, !=6.2.0, !=6.3.0, !=6.4.0, !=6.5.0, !=6.6.0, < 7"
9090
}
9191
kubernetes = {
9292
source = "hashicorp/kubernetes"

autogen/safer-cluster/main.tf.tmpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,16 @@ module "gke" {
119119
// All applications should run with an identity defined via Workload Identity anyway.
120120
// - Use a service account passed as a parameter to the module, in case the user
121121
// wants to maintain control of their service accounts.
122-
create_service_account = var.compute_engine_service_account == "" ? true : false
123122
service_account = var.compute_engine_service_account
124123
registry_project_ids = var.registry_project_ids
125124
grant_registry_access = var.grant_registry_access
126125

126+
// If create_service_account is explicitly set to false we short-circuit the
127+
// compute_engine_service_account check to potentially avoid an error (see variables.tf documentation).
128+
// Otherwise if true (the default), we check if compute_engine_service_account is set for backwards compatability
129+
// before the create_service_account variable was added.
130+
create_service_account = var.create_service_account == false ? var.create_service_account : (var.compute_engine_service_account == "" ? true : false)
131+
127132
issue_client_certificate = false
128133

129134
cluster_resource_labels = var.cluster_resource_labels
@@ -209,7 +214,7 @@ module "gke" {
209214
// Enabling vulnerability and audit for workloads
210215
workload_vulnerability_mode = var.workload_vulnerability_mode
211216
workload_config_audit_mode = var.workload_config_audit_mode
212-
217+
213218
// Enabling security posture
214219
security_posture_mode = var.security_posture_mode
215220
security_posture_vulnerability_mode = var.security_posture_vulnerability_mode

0 commit comments

Comments
 (0)