Skip to content

Commit 4bba52f

Browse files
X4mpRoland Urbanoapeabody
authored
feat: Recurring maintenance window to GA (#1262)
* Added code changes from #1242 Signed-off-by: Roland Urbano <[email protected]> * Added variable definition for new inputs Signed-off-by: Roland Urbano <[email protected]> * Extended READMEs for new inputs and added documentation Signed-off-by: Roland Urbano <[email protected]> Autogenerated documentation and variable inputs Signed-off-by: Roland Urbano <[email protected]> Co-authored-by: Roland Urbano <[email protected]> Co-authored-by: Andrew Peabody <[email protected]>
1 parent 4a7e6e4 commit 4bba52f

File tree

15 files changed

+114
-16
lines changed

15 files changed

+114
-16
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 }))` | `[]` | 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: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ resource "google_container_cluster" "primary" {
243243
}
244244

245245
maintenance_policy {
246-
{% if beta_cluster %}
247246
dynamic "recurring_window" {
248247
for_each = local.cluster_maintenance_window_is_recurring
249248
content {
@@ -268,11 +267,6 @@ resource "google_container_cluster" "primary" {
268267
end_time = maintenance_exclusion.value.end_time
269268
}
270269
}
271-
{% else %}
272-
daily_maintenance_window {
273-
start_time = var.maintenance_start_time
274-
}
275-
{% endif %}
276270
}
277271

278272
{% 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: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,29 @@ resource "google_container_cluster" "primary" {
124124
}
125125

126126
maintenance_policy {
127-
daily_maintenance_window {
128-
start_time = var.maintenance_start_time
127+
dynamic "recurring_window" {
128+
for_each = local.cluster_maintenance_window_is_recurring
129+
content {
130+
start_time = var.maintenance_start_time
131+
end_time = var.maintenance_end_time
132+
recurrence = var.maintenance_recurrence
133+
}
134+
}
135+
136+
dynamic "daily_maintenance_window" {
137+
for_each = local.cluster_maintenance_window_is_daily
138+
content {
139+
start_time = var.maintenance_start_time
140+
}
141+
}
142+
143+
dynamic "maintenance_exclusion" {
144+
for_each = var.maintenance_exclusions
145+
content {
146+
exclusion_name = maintenance_exclusion.value.name
147+
start_time = maintenance_exclusion.value.start_time
148+
end_time = maintenance_exclusion.value.end_time
149+
}
129150
}
130151
}
131152

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/private-cluster-update-variant/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ Then perform the following commands on the root folder:
191191
| 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 |
192192
| 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 |
193193
| 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 |
194+
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
194195
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
196+
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
195197
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
196198
| 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 |
197199
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | `string` | `"10.0.0.0/28"` | no |

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,29 @@ resource "google_container_cluster" "primary" {
124124
}
125125

126126
maintenance_policy {
127-
daily_maintenance_window {
128-
start_time = var.maintenance_start_time
127+
dynamic "recurring_window" {
128+
for_each = local.cluster_maintenance_window_is_recurring
129+
content {
130+
start_time = var.maintenance_start_time
131+
end_time = var.maintenance_end_time
132+
recurrence = var.maintenance_recurrence
133+
}
134+
}
135+
136+
dynamic "daily_maintenance_window" {
137+
for_each = local.cluster_maintenance_window_is_daily
138+
content {
139+
start_time = var.maintenance_start_time
140+
}
141+
}
142+
143+
dynamic "maintenance_exclusion" {
144+
for_each = var.maintenance_exclusions
145+
content {
146+
exclusion_name = maintenance_exclusion.value.name
147+
start_time = maintenance_exclusion.value.start_time
148+
end_time = maintenance_exclusion.value.end_time
149+
}
129150
}
130151
}
131152

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

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

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

149151
/******************************************

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

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

117+
variable "maintenance_end_time" {
118+
type = string
119+
description = "Time window specified for recurring maintenance operations in RFC3339 format"
120+
default = ""
121+
}
122+
123+
variable "maintenance_recurrence" {
124+
type = string
125+
description = "Frequency of the recurring maintenance window in RFC5545 format."
126+
default = ""
127+
}
117128

118129
variable "ip_range_pods" {
119130
type = string

modules/private-cluster/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ Then perform the following commands on the root folder:
169169
| 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 |
170170
| 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 |
171171
| 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 |
172+
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
172173
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
174+
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
173175
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
174176
| 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 |
175177
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | `string` | `"10.0.0.0/28"` | no |

modules/private-cluster/cluster.tf

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,29 @@ resource "google_container_cluster" "primary" {
124124
}
125125

126126
maintenance_policy {
127-
daily_maintenance_window {
128-
start_time = var.maintenance_start_time
127+
dynamic "recurring_window" {
128+
for_each = local.cluster_maintenance_window_is_recurring
129+
content {
130+
start_time = var.maintenance_start_time
131+
end_time = var.maintenance_end_time
132+
recurrence = var.maintenance_recurrence
133+
}
134+
}
135+
136+
dynamic "daily_maintenance_window" {
137+
for_each = local.cluster_maintenance_window_is_daily
138+
content {
139+
start_time = var.maintenance_start_time
140+
}
141+
}
142+
143+
dynamic "maintenance_exclusion" {
144+
for_each = var.maintenance_exclusions
145+
content {
146+
exclusion_name = maintenance_exclusion.value.name
147+
start_time = maintenance_exclusion.value.start_time
148+
end_time = maintenance_exclusion.value.end_time
149+
}
129150
}
130151
}
131152

modules/private-cluster/main.tf

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

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

149151
/******************************************

modules/private-cluster/variables.tf

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

117+
variable "maintenance_end_time" {
118+
type = string
119+
description = "Time window specified for recurring maintenance operations in RFC3339 format"
120+
default = ""
121+
}
122+
123+
variable "maintenance_recurrence" {
124+
type = string
125+
description = "Frequency of the recurring maintenance window in RFC5545 format."
126+
default = ""
127+
}
117128

118129
variable "ip_range_pods" {
119130
type = string

variables.tf

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

117+
variable "maintenance_end_time" {
118+
type = string
119+
description = "Time window specified for recurring maintenance operations in RFC3339 format"
120+
default = ""
121+
}
122+
123+
variable "maintenance_recurrence" {
124+
type = string
125+
description = "Frequency of the recurring maintenance window in RFC5545 format."
126+
default = ""
127+
}
117128

118129
variable "ip_range_pods" {
119130
type = string

0 commit comments

Comments
 (0)