Skip to content

Commit 5507045

Browse files
committed
Merge branch 'master' into feature/maintenance-exclusion
2 parents 7e22154 + 4bba52f commit 5507045

File tree

21 files changed

+199
-94
lines changed

21 files changed

+199
-94
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ Then perform the following commands on the root folder:
160160
| issue\_client\_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | `bool` | `false` | no |
161161
| kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | `string` | `"latest"` | no |
162162
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | `string` | `"logging.googleapis.com/kubernetes"` | no |
163+
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
163164
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string }))` | `[]` | no |
165+
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
164166
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
165167
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | `list(object({ cidr_block = string, display_name = string }))` | `[]` | no |
166168
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | `string` | `"monitoring.googleapis.com/kubernetes"` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,14 @@ resource "google_container_cluster" "primary" {
234234

235235
datapath_provider = var.datapath_provider
236236

237-
{% if beta_cluster %}
238237
networking_mode = "VPC_NATIVE"
239-
{% endif %}
238+
240239
ip_allocation_policy {
241240
cluster_secondary_range_name = var.ip_range_pods
242241
services_secondary_range_name = var.ip_range_services
243242
}
244243

245244
maintenance_policy {
246-
{% if beta_cluster %}
247245
dynamic "recurring_window" {
248246
for_each = local.cluster_maintenance_window_is_recurring
249247
content {
@@ -253,31 +251,28 @@ resource "google_container_cluster" "primary" {
253251
}
254252
}
255253

256-
dynamic "daily_maintenance_window" {
257-
for_each = local.cluster_maintenance_window_is_daily
258-
content {
259-
start_time = var.maintenance_start_time
260-
}
261-
}
262-
263-
{% else %}
264-
daily_maintenance_window {
265-
start_time = var.maintenance_start_time
266-
}
267-
{% endif %}
268-
269254
dynamic "maintenance_exclusion" {
270255
for_each = var.maintenance_exclusions
271256
content {
272257
exclusion_name = maintenance_exclusion.value.name
273258
start_time = maintenance_exclusion.value.start_time
274259
end_time = maintenance_exclusion.value.end_time
275260

276-
exclusion_options {
277-
scope = maintenance_exclusion.value.exclusion_options == null ? "NO_UPGRADES" : maintenance_exclusion.value.exclusion_options
261+
dynamic "exclusion_options" {
262+
for_each = maintenance_exclusion.value["scope"] == null ? [] : [maintenance_exclusion.value["scope"]]
263+
content {
264+
scope = exclusion_options.value
265+
}
278266
}
279267
}
280268
}
269+
270+
dynamic "daily_maintenance_window" {
271+
for_each = local.cluster_maintenance_window_is_daily
272+
content {
273+
start_time = var.maintenance_start_time
274+
}
275+
}
281276
}
282277

283278
{% if autopilot_cluster != true %}

autogen/main/main.tf.tmpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,8 @@ locals {
213213
# /BETA features
214214
{% endif %}
215215

216-
{% if beta_cluster %}
217216
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
218217
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
219-
{% endif %}
220218
}
221219

222220
/******************************************

autogen/main/variables.tf.tmpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ variable "maintenance_exclusions" {
114114
default = []
115115
}
116116

117-
{% if beta_cluster %}
118117
variable "maintenance_end_time" {
119118
type = string
120119
description = "Time window specified for recurring maintenance operations in RFC3339 format"
@@ -126,7 +125,6 @@ variable "maintenance_recurrence" {
126125
description = "Frequency of the recurring maintenance window in RFC5545 format."
127126
default = ""
128127
}
129-
{% endif %}
130128

131129
variable "ip_range_pods" {
132130
type = string

cluster.tf

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,21 @@ resource "google_container_cluster" "primary" {
118118

119119
datapath_provider = var.datapath_provider
120120

121+
networking_mode = "VPC_NATIVE"
122+
121123
ip_allocation_policy {
122124
cluster_secondary_range_name = var.ip_range_pods
123125
services_secondary_range_name = var.ip_range_services
124126
}
125127

126128
maintenance_policy {
127-
daily_maintenance_window {
128-
start_time = var.maintenance_start_time
129+
dynamic "recurring_window" {
130+
for_each = local.cluster_maintenance_window_is_recurring
131+
content {
132+
start_time = var.maintenance_start_time
133+
end_time = var.maintenance_end_time
134+
recurrence = var.maintenance_recurrence
135+
}
129136
}
130137

131138
dynamic "maintenance_exclusion" {
@@ -135,11 +142,21 @@ resource "google_container_cluster" "primary" {
135142
start_time = maintenance_exclusion.value.start_time
136143
end_time = maintenance_exclusion.value.end_time
137144

138-
exclusion_options {
139-
scope = maintenance_exclusion.value.exclusion_options == null ? "NO_UPGRADES" : maintenance_exclusion.value.exclusion_options
145+
dynamic "exclusion_options" {
146+
for_each = maintenance_exclusion.value["scope"] == null ? [] : [maintenance_exclusion.value["scope"]]
147+
content {
148+
scope = exclusion_options.value
149+
}
140150
}
141151
}
142152
}
153+
154+
dynamic "daily_maintenance_window" {
155+
for_each = local.cluster_maintenance_window_is_daily
156+
content {
157+
start_time = var.maintenance_start_time
158+
}
159+
}
143160
}
144161

145162
lifecycle {

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ locals {
143143
workload_pool = "${var.project_id}.svc.id.goog" }] : [{ workload_pool = var.identity_namespace
144144
}]
145145

146+
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
147+
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
146148
}
147149

148150
/******************************************

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ resource "google_container_cluster" "primary" {
9292
datapath_provider = var.datapath_provider
9393

9494
networking_mode = "VPC_NATIVE"
95+
9596
ip_allocation_policy {
9697
cluster_secondary_range_name = var.ip_range_pods
9798
services_secondary_range_name = var.ip_range_services
@@ -107,26 +108,28 @@ resource "google_container_cluster" "primary" {
107108
}
108109
}
109110

110-
dynamic "daily_maintenance_window" {
111-
for_each = local.cluster_maintenance_window_is_daily
112-
content {
113-
start_time = var.maintenance_start_time
114-
}
115-
}
116-
117-
118111
dynamic "maintenance_exclusion" {
119112
for_each = var.maintenance_exclusions
120113
content {
121114
exclusion_name = maintenance_exclusion.value.name
122115
start_time = maintenance_exclusion.value.start_time
123116
end_time = maintenance_exclusion.value.end_time
124117

125-
exclusion_options {
126-
scope = maintenance_exclusion.value.exclusion_options == null ? "NO_UPGRADES" : maintenance_exclusion.value.exclusion_options
118+
dynamic "exclusion_options" {
119+
for_each = maintenance_exclusion.value["scope"] == null ? [] : [maintenance_exclusion.value["scope"]]
120+
content {
121+
scope = exclusion_options.value
122+
}
127123
}
128124
}
129125
}
126+
127+
dynamic "daily_maintenance_window" {
128+
for_each = local.cluster_maintenance_window_is_daily
129+
content {
130+
start_time = var.maintenance_start_time
131+
}
132+
}
130133
}
131134

132135

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ resource "google_container_cluster" "primary" {
9292
datapath_provider = var.datapath_provider
9393

9494
networking_mode = "VPC_NATIVE"
95+
9596
ip_allocation_policy {
9697
cluster_secondary_range_name = var.ip_range_pods
9798
services_secondary_range_name = var.ip_range_services
@@ -107,26 +108,28 @@ resource "google_container_cluster" "primary" {
107108
}
108109
}
109110

110-
dynamic "daily_maintenance_window" {
111-
for_each = local.cluster_maintenance_window_is_daily
112-
content {
113-
start_time = var.maintenance_start_time
114-
}
115-
}
116-
117-
118111
dynamic "maintenance_exclusion" {
119112
for_each = var.maintenance_exclusions
120113
content {
121114
exclusion_name = maintenance_exclusion.value.name
122115
start_time = maintenance_exclusion.value.start_time
123116
end_time = maintenance_exclusion.value.end_time
124117

125-
exclusion_options {
126-
scope = maintenance_exclusion.value.exclusion_options == null ? "NO_UPGRADES" : maintenance_exclusion.value.exclusion_options
118+
dynamic "exclusion_options" {
119+
for_each = maintenance_exclusion.value["scope"] == null ? [] : [maintenance_exclusion.value["scope"]]
120+
content {
121+
scope = exclusion_options.value
122+
}
127123
}
128124
}
129125
}
126+
127+
dynamic "daily_maintenance_window" {
128+
for_each = local.cluster_maintenance_window_is_daily
129+
content {
130+
start_time = var.maintenance_start_time
131+
}
132+
}
130133
}
131134

132135

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ resource "google_container_cluster" "primary" {
203203
datapath_provider = var.datapath_provider
204204

205205
networking_mode = "VPC_NATIVE"
206+
206207
ip_allocation_policy {
207208
cluster_secondary_range_name = var.ip_range_pods
208209
services_secondary_range_name = var.ip_range_services
@@ -218,26 +219,28 @@ resource "google_container_cluster" "primary" {
218219
}
219220
}
220221

221-
dynamic "daily_maintenance_window" {
222-
for_each = local.cluster_maintenance_window_is_daily
223-
content {
224-
start_time = var.maintenance_start_time
225-
}
226-
}
227-
228-
229222
dynamic "maintenance_exclusion" {
230223
for_each = var.maintenance_exclusions
231224
content {
232225
exclusion_name = maintenance_exclusion.value.name
233226
start_time = maintenance_exclusion.value.start_time
234227
end_time = maintenance_exclusion.value.end_time
235228

236-
exclusion_options {
237-
scope = maintenance_exclusion.value.exclusion_options == null ? "NO_UPGRADES" : maintenance_exclusion.value.exclusion_options
229+
dynamic "exclusion_options" {
230+
for_each = maintenance_exclusion.value["scope"] == null ? [] : [maintenance_exclusion.value["scope"]]
231+
content {
232+
scope = exclusion_options.value
233+
}
238234
}
239235
}
240236
}
237+
238+
dynamic "daily_maintenance_window" {
239+
for_each = local.cluster_maintenance_window_is_daily
240+
content {
241+
start_time = var.maintenance_start_time
242+
}
243+
}
241244
}
242245

243246
lifecycle {

modules/beta-private-cluster/cluster.tf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ resource "google_container_cluster" "primary" {
203203
datapath_provider = var.datapath_provider
204204

205205
networking_mode = "VPC_NATIVE"
206+
206207
ip_allocation_policy {
207208
cluster_secondary_range_name = var.ip_range_pods
208209
services_secondary_range_name = var.ip_range_services
@@ -218,26 +219,28 @@ resource "google_container_cluster" "primary" {
218219
}
219220
}
220221

221-
dynamic "daily_maintenance_window" {
222-
for_each = local.cluster_maintenance_window_is_daily
223-
content {
224-
start_time = var.maintenance_start_time
225-
}
226-
}
227-
228-
229222
dynamic "maintenance_exclusion" {
230223
for_each = var.maintenance_exclusions
231224
content {
232225
exclusion_name = maintenance_exclusion.value.name
233226
start_time = maintenance_exclusion.value.start_time
234227
end_time = maintenance_exclusion.value.end_time
235228

236-
exclusion_options {
237-
scope = maintenance_exclusion.value.exclusion_options == null ? "NO_UPGRADES" : maintenance_exclusion.value.exclusion_options
229+
dynamic "exclusion_options" {
230+
for_each = maintenance_exclusion.value["scope"] == null ? [] : [maintenance_exclusion.value["scope"]]
231+
content {
232+
scope = exclusion_options.value
233+
}
238234
}
239235
}
240236
}
237+
238+
dynamic "daily_maintenance_window" {
239+
for_each = local.cluster_maintenance_window_is_daily
240+
content {
241+
start_time = var.maintenance_start_time
242+
}
243+
}
241244
}
242245

243246
lifecycle {

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ resource "google_container_cluster" "primary" {
203203
datapath_provider = var.datapath_provider
204204

205205
networking_mode = "VPC_NATIVE"
206+
206207
ip_allocation_policy {
207208
cluster_secondary_range_name = var.ip_range_pods
208209
services_secondary_range_name = var.ip_range_services
@@ -218,26 +219,28 @@ resource "google_container_cluster" "primary" {
218219
}
219220
}
220221

221-
dynamic "daily_maintenance_window" {
222-
for_each = local.cluster_maintenance_window_is_daily
223-
content {
224-
start_time = var.maintenance_start_time
225-
}
226-
}
227-
228-
229222
dynamic "maintenance_exclusion" {
230223
for_each = var.maintenance_exclusions
231224
content {
232225
exclusion_name = maintenance_exclusion.value.name
233226
start_time = maintenance_exclusion.value.start_time
234227
end_time = maintenance_exclusion.value.end_time
235228

236-
exclusion_options {
237-
scope = maintenance_exclusion.value.exclusion_options == null ? "NO_UPGRADES" : maintenance_exclusion.value.exclusion_options
229+
dynamic "exclusion_options" {
230+
for_each = maintenance_exclusion.value["scope"] == null ? [] : [maintenance_exclusion.value["scope"]]
231+
content {
232+
scope = exclusion_options.value
233+
}
238234
}
239235
}
240236
}
237+
238+
dynamic "daily_maintenance_window" {
239+
for_each = local.cluster_maintenance_window_is_daily
240+
content {
241+
start_time = var.maintenance_start_time
242+
}
243+
}
241244
}
242245

243246
lifecycle {

0 commit comments

Comments
 (0)