Skip to content

Commit e5a09c1

Browse files
committed
2 parents bc7f7f7 + e7566c5 commit e5a09c1

Some content is hidden

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

74 files changed

+899
-151
lines changed

.github/renovate.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515
],
1616
"stabilityDays":0
1717
},
18+
"separateMajorMinor":false,
1819
"packageRules": [
1920
{
2021
"matchPaths": ["examples/**", "test/**", ".github/**"],
2122
"extends": [":semanticCommitTypeAll(chore)"]
2223
},
24+
{
25+
"matchPaths": ["*", "modules/**"],
26+
"extends": [":semanticCommitTypeAll(fix)"]
27+
},
2328
{
2429
"matchDepTypes": ["module"],
25-
"groupName": "TF modules",
26-
"separateMajorMinor":false,
27-
"major": {
28-
"semanticCommitType": "feat!"
29-
}
30+
"groupName": "TF modules"
3031
},
3132
{
3233
"matchDepTypes": ["require"],
3334
"groupName": "GO modules",
34-
"postUpdateOptions": ["gomodTidy"],
35-
"separateMajorMinor":false
35+
"postUpdateOptions": ["gomodTidy"]
3636
},
3737
{
3838
"matchPackageNames": ["go"],
@@ -41,8 +41,7 @@
4141
},
4242
{
4343
"matchPackageNames": ["google", "google-beta"],
44-
"groupName": "terraform googles",
45-
"separateMajorMinor": false
44+
"groupName": "terraform googles"
4645
}
4746
]
4847
}

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
stale:
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/stale@v6
24+
- uses: actions/stale@v7
2525
with:
2626
repo-token: ${{ secrets.GITHUB_TOKEN }}
2727
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days'

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Then perform the following commands on the root folder:
155155
| filestore\_csi\_driver | The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes | `bool` | `false` | no |
156156
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers. Either flag `add_master_webhook_firewall_rules` or `add_cluster_firewall_rules` (also adds egress rules) must be set to `true` for inbound-ports firewall rules to be applied. | `list(string)` | <pre>[<br> "8443",<br> "9443",<br> "15017"<br>]</pre> | no |
157157
| firewall\_priority | Priority rule for firewall rules | `number` | `1000` | no |
158+
| gce\_pd\_csi\_driver | Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | `bool` | `true` | no |
158159
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |
159160
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | `bool` | `true` | no |
160161
| http\_load\_balancing | Enable httpload balancer addon | `bool` | `true` | no |
@@ -183,6 +184,7 @@ Then perform the following commands on the root folder:
183184
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
184185
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
185186
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | `map(list(string))` | <pre>{<br> "all": [<br> "https://www.googleapis.com/auth/cloud-platform"<br> ],<br> "default-node-pool": []<br>}</pre> | no |
187+
| node\_pools\_resource\_labels | Map of maps containing resource labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
186188
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | `map(list(string))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
187189
| node\_pools\_taints | Map of lists containing node taints by node-pool name | `map(list(object({ key = string, value = string, effect = string })))` | <pre>{<br> "all": [],<br> "default-node-pool": []<br>}</pre> | no |
188190
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
@@ -278,6 +280,7 @@ The node_pools variable takes the following parameters:
278280
| tags | The list of instance tags applied to all nodes | | Required |
279281
| value | The value for the taint | | Required |
280282
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
283+
| location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
281284

282285
## windows_node_pools variable
283286
The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.

autogen/main/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ The node_pools variable takes the following parameters:
232232
| tags | The list of instance tags applied to all nodes | | Required |
233233
| value | The value for the taint | | Required |
234234
| version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional |
235+
| location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional |
235236

236237
## windows_node_pools variable
237238
The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created.

autogen/main/cluster.tf.tmpl

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ resource "google_container_cluster" "primary" {
150150
}
151151
}
152152
{% endif %}
153+
{% if autopilot_cluster == true %}
154+
cluster_autoscaling {
155+
dynamic "auto_provisioning_defaults" {
156+
for_each = var.create_service_account ? [1] : []
157+
158+
content {
159+
service_account = local.service_account
160+
}
161+
}
162+
}
163+
{% endif %}
153164
vertical_pod_autoscaling {
154165
enabled = var.enable_vertical_pod_autoscaling
155166
}
@@ -224,7 +235,6 @@ resource "google_container_cluster" "primary" {
224235
disabled = !var.horizontal_pod_autoscaling
225236
}
226237

227-
228238
{% if autopilot_cluster != true %}
229239
network_policy_config {
230240
disabled = !var.network_policy
@@ -237,6 +247,14 @@ resource "google_container_cluster" "primary" {
237247
gcp_filestore_csi_driver_config {
238248
enabled = var.filestore_csi_driver
239249
}
250+
251+
dynamic "gce_persistent_disk_csi_driver_config" {
252+
for_each = local.cluster_gce_pd_csi_config
253+
254+
content {
255+
enabled = gce_persistent_disk_csi_driver_config.value.enabled
256+
}
257+
}
240258
{% endif %}
241259
{% if beta_cluster and autopilot_cluster != true %}
242260

@@ -253,14 +271,6 @@ resource "google_container_cluster" "primary" {
253271
}
254272
}
255273

256-
dynamic "gce_persistent_disk_csi_driver_config" {
257-
for_each = local.cluster_gce_pd_csi_config
258-
259-
content {
260-
enabled = gce_persistent_disk_csi_driver_config.value.enabled
261-
}
262-
}
263-
264274
kalm_config {
265275
enabled = var.kalm_config
266276
}
@@ -686,6 +696,10 @@ resource "google_container_node_pool" "windows_pools" {
686696
local.node_pools_labels["all"],
687697
local.node_pools_labels[each.value["name"]],
688698
)
699+
resource_labels = merge(
700+
local.node_pools_resource_labels["all"],
701+
local.node_pools_resource_labels[each.value["name"]],
702+
)
689703
metadata = merge(
690704
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
691705
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},

autogen/main/main.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ locals {
9595
enabled = false
9696
provider = null
9797
}]
98+
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
9899
{% endif %}
99100
{% if beta_cluster and autopilot_cluster != true %}
100101
cluster_cloudrun_config_load_balancer_config = (var.cloudrun && var.cloudrun_load_balancer_type != "") ? {
@@ -109,7 +110,6 @@ locals {
109110
)
110111
] : []
111112
cluster_cloudrun_enabled = var.cloudrun
112-
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
113113
gke_backup_agent_config = var.gke_backup_agent_config ? [{ enabled = true }] : [{ enabled = false }]
114114
logmon_config_is_set = length(var.logging_enabled_components) > 0 || length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus
115115
{% endif %}

autogen/main/variables.tf.tmpl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ variable "node_pools_labels" {
171171
}
172172
}
173173

174+
variable "node_pools_resource_labels" {
175+
type = map(map(string))
176+
description = "Map of maps containing resource labels by node-pool name"
177+
178+
default = {
179+
all = {}
180+
default-node-pool = {}
181+
}
182+
}
183+
174184
variable "node_pools_metadata" {
175185
type = map(map(string))
176186
description = "Map of maps containing node metadata by node-pool name"
@@ -605,6 +615,12 @@ variable "cluster_dns_domain" {
605615
default = ""
606616
}
607617

618+
variable "gce_pd_csi_driver" {
619+
type = bool
620+
description = "Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
621+
default = true
622+
}
623+
608624
{% endif %}
609625
variable "timeouts" {
610626
type = map(string)
@@ -713,11 +729,5 @@ variable "enable_identity_service" {
713729
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
714730
default = false
715731
}
716-
717-
variable "gce_pd_csi_driver" {
718-
type = bool
719-
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
720-
default = false
721-
}
722732
{% endif %}
723733
{% endif %}

autogen/main/variables_defaults.tf.tmpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ locals {
3535
var.node_pools_labels
3636
)
3737

38+
node_pools_resource_labels = merge(
39+
{ all = {} },
40+
{ default-node-pool = {} },
41+
zipmap(
42+
[for node_pool in var.node_pools : node_pool["name"]],
43+
[for node_pool in var.node_pools : {}]
44+
),
45+
zipmap(
46+
[for node_pool in var.windows_node_pools : node_pool["name"]],
47+
[for node_pool in var.windows_node_pools : {}]
48+
),
49+
var.node_pools_resource_labels
50+
)
51+
3852
node_pools_metadata = merge(
3953
{ all = {} },
4054
{ default-node-pool = {} },

autogen/main/versions.tf.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ terraform {
2424
required_providers {
2525
google-beta = {
2626
source = "hashicorp/google-beta"
27-
version = ">= 4.42.0, < 5.0"
27+
version = ">= 4.45.0, < 5.0"
2828
}
2929
kubernetes = {
3030
source = "hashicorp/kubernetes"
@@ -38,7 +38,7 @@ terraform {
3838
required_providers {
3939
google = {
4040
source = "hashicorp/google"
41-
version = ">= 4.36.0, < 5.0"
41+
version = ">= 4.45.0, < 5.0"
4242
}
4343
kubernetes = {
4444
source = "hashicorp/kubernetes"

autogen/safer-cluster/main.tf.tmpl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ module "gke" {
8686
// If removing the default node pool, initial_node_count should be at least 1.
8787
initial_node_count = (var.initial_node_count == 0) ? 1 : var.initial_node_count
8888

89-
node_pools = var.node_pools
90-
windows_node_pools = var.windows_node_pools
91-
node_pools_labels = var.node_pools_labels
92-
node_pools_metadata = var.node_pools_metadata
93-
node_pools_taints = var.node_pools_taints
94-
node_pools_tags = var.node_pools_tags
89+
node_pools = var.node_pools
90+
windows_node_pools = var.windows_node_pools
91+
node_pools_labels = var.node_pools_labels
92+
node_pools_resource_labels = var.node_pools_resource_labels
93+
node_pools_metadata = var.node_pools_metadata
94+
node_pools_taints = var.node_pools_taints
95+
node_pools_tags = var.node_pools_tags
9596

9697
node_pools_oauth_scopes = var.node_pools_oauth_scopes
9798

autogen/safer-cluster/variables.tf.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ variable "node_pools_labels" {
168168
}
169169
}
170170

171+
variable "node_pools_resource_labels" {
172+
type = map(map(string))
173+
description = "Map of maps containing resource labels by node-pool name"
174+
175+
default = {
176+
all = {}
177+
default-node-pool = {}
178+
}
179+
}
180+
171181
variable "node_pools_metadata" {
172182
type = map(map(string))
173183
description = "Map of maps containing node metadata by node-pool name"

build/int.cloudbuild.yaml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,26 @@ steps:
401401
- verify private-zonal-with-networking
402402
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
403403
args: ['/bin/bash', '-c', 'cft test run TestPrivateZonalWithNetworking --stage teardown --verbose --test-dir test/integration']
404-
405-
406-
404+
- id: init simple-autopilot-private-non-default-sa
405+
waitFor:
406+
- prepare
407+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
408+
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivateNonDefaultSA --stage init --verbose']
409+
- id: apply simple-autopilot-private-non-default-sa
410+
waitFor:
411+
- init simple-autopilot-private-non-default-sa
412+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
413+
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivateNonDefaultSA --stage apply --verbose']
414+
- id: verify simple-autopilot-private-non-default-sa
415+
waitFor:
416+
- apply simple-autopilot-private-non-default-sa
417+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
418+
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivateNonDefaultSA --stage verify --verbose']
419+
- id: teardown simple-autopilot-private-non-default-sa
420+
waitFor:
421+
- verify simple-autopilot-private-non-default-sa
422+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
423+
args: ['/bin/bash', '-c', 'cft test run TestSimpleAutopilotPrivateNonDefaultSA --stage teardown --verbose']
407424
tags:
408425
- 'ci'
409426
- 'integration'

cluster.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ resource "google_container_cluster" "primary" {
131131
disabled = !var.horizontal_pod_autoscaling
132132
}
133133

134-
135134
network_policy_config {
136135
disabled = !var.network_policy
137136
}
@@ -143,6 +142,14 @@ resource "google_container_cluster" "primary" {
143142
gcp_filestore_csi_driver_config {
144143
enabled = var.filestore_csi_driver
145144
}
145+
146+
dynamic "gce_persistent_disk_csi_driver_config" {
147+
for_each = local.cluster_gce_pd_csi_config
148+
149+
content {
150+
enabled = gce_persistent_disk_csi_driver_config.value.enabled
151+
}
152+
}
146153
}
147154

148155
datapath_provider = var.datapath_provider
@@ -377,6 +384,10 @@ resource "google_container_node_pool" "pools" {
377384
local.node_pools_labels["all"],
378385
local.node_pools_labels[each.value["name"]],
379386
)
387+
resource_labels = merge(
388+
local.node_pools_resource_labels["all"],
389+
local.node_pools_resource_labels[each.value["name"]],
390+
)
380391
metadata = merge(
381392
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
382393
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},
@@ -531,6 +542,10 @@ resource "google_container_node_pool" "windows_pools" {
531542
local.node_pools_labels["all"],
532543
local.node_pools_labels[each.value["name"]],
533544
)
545+
resource_labels = merge(
546+
local.node_pools_resource_labels["all"],
547+
local.node_pools_resource_labels[each.value["name"]],
548+
)
534549
metadata = merge(
535550
lookup(lookup(local.node_pools_metadata, "default_values", {}), "cluster_name", true) ? { "cluster_name" = var.name } : {},
536551
lookup(lookup(local.node_pools_metadata, "default_values", {}), "node_pool", true) ? { "node_pool" = each.value["name"] } : {},

0 commit comments

Comments
 (0)