Skip to content

Commit 68cae2b

Browse files
authored
Merge pull request terraform-google-modules#397 from gajicdev/feature/recurring-window-maintenance-policy
Add recurring_window maintenance_policy to beta files
2 parents 7a9f788 + 61fa291 commit 68cae2b

File tree

24 files changed

+149
-19
lines changed

24 files changed

+149
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Then perform the following commands on the root folder:
132132
| 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 |
133133
| 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 |
134134
| 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 |
135-
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
135+
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string | `"05:00"` | no |
136136
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
137137
| 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 |
138138
| name | The name of the cluster (required) | string | n/a | yes |

autogen/main/cluster.tf.tmpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,27 @@ resource "google_container_cluster" "primary" {
156156
}
157157

158158
maintenance_policy {
159+
{% if beta_cluster %}
160+
dynamic "recurring_window"{
161+
for_each = local.cluster_maintenance_window_is_recurring
162+
content {
163+
start_time = var.maintenance_start_time
164+
end_time = var.maintenance_end_time
165+
recurrence = var.maintenance_recurrence
166+
}
167+
}
168+
169+
dynamic "daily_maintenance_window"{
170+
for_each = local.cluster_maintenance_window_is_daily
171+
content {
172+
start_time = var.maintenance_start_time
173+
}
174+
}
175+
{% else %}
159176
daily_maintenance_window {
160177
start_time = var.maintenance_start_time
161178
}
179+
{% endif %}
162180
}
163181

164182
lifecycle {

autogen/main/main.tf.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ locals {
164164
}]
165165
# /BETA features
166166
{% endif %}
167+
168+
{% if beta_cluster %}
169+
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
170+
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
171+
{% endif %}
167172
}
168173

169174
/******************************************

autogen/main/variables.tf.tmpl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,24 @@ variable "network_policy_provider" {
110110

111111
variable "maintenance_start_time" {
112112
type = string
113-
description = "Time window specified for daily maintenance operations in RFC3339 format"
113+
description = "Time window specified for daily or recurring maintenance operations in RFC3339 format"
114114
default = "05:00"
115115
}
116116

117+
{% if beta_cluster %}
118+
variable "maintenance_end_time" {
119+
type = string
120+
description = "Time window specified for recurring maintenance operations in RFC3339 format"
121+
default = ""
122+
}
123+
124+
variable "maintenance_recurrence" {
125+
type = string
126+
description = "Frequency of the recurring maintenance window in RFC5545 format."
127+
default = ""
128+
}
129+
{% endif %}
130+
117131
variable "ip_range_pods" {
118132
type = string
119133
description = "The _name_ of the secondary subnet ip range to use for pods"

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ locals {
106106
cluster_network_policy_enabled = ! local.cluster_output_network_policy_enabled
107107
cluster_http_load_balancing_enabled = ! local.cluster_output_http_load_balancing_enabled
108108
cluster_horizontal_pod_autoscaling_enabled = ! local.cluster_output_horizontal_pod_autoscaling_enabled
109+
109110
}
110111

111112
/******************************************

modules/beta-private-cluster-update-variant/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ Then perform the following commands on the root folder:
167167
| istio | (Beta) Enable Istio addon | string | `"false"` | no |
168168
| 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 |
169169
| 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 |
170-
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
170+
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | string | `""` | no |
171+
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string | `""` | no |
172+
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string | `"05:00"` | no |
171173
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
172174
| 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 |
173175
| 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 |

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,20 @@ resource "google_container_cluster" "primary" {
146146
}
147147

148148
maintenance_policy {
149-
daily_maintenance_window {
150-
start_time = var.maintenance_start_time
149+
dynamic "recurring_window" {
150+
for_each = local.cluster_maintenance_window_is_recurring
151+
content {
152+
start_time = var.maintenance_start_time
153+
end_time = var.maintenance_end_time
154+
recurrence = var.maintenance_recurrence
155+
}
156+
}
157+
158+
dynamic "daily_maintenance_window" {
159+
for_each = local.cluster_maintenance_window_is_daily
160+
content {
161+
start_time = var.maintenance_start_time
162+
}
151163
}
152164
}
153165

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ locals {
148148
identity_namespace = var.identity_namespace
149149
}]
150150
# /BETA features
151+
152+
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
153+
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
151154
}
152155

153156
/******************************************

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,22 @@ variable "network_policy_provider" {
110110

111111
variable "maintenance_start_time" {
112112
type = string
113-
description = "Time window specified for daily maintenance operations in RFC3339 format"
113+
description = "Time window specified for daily or recurring maintenance operations in RFC3339 format"
114114
default = "05:00"
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+
}
128+
117129
variable "ip_range_pods" {
118130
type = string
119131
description = "The _name_ of the secondary subnet ip range to use for pods"

modules/beta-private-cluster/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ Then perform the following commands on the root folder:
167167
| istio | (Beta) Enable Istio addon | string | `"false"` | no |
168168
| 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 |
169169
| 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 |
170-
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
170+
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | string | `""` | no |
171+
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string | `""` | no |
172+
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string | `"05:00"` | no |
171173
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
172174
| 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 |
173175
| 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 |

modules/beta-private-cluster/cluster.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,20 @@ resource "google_container_cluster" "primary" {
146146
}
147147

148148
maintenance_policy {
149-
daily_maintenance_window {
150-
start_time = var.maintenance_start_time
149+
dynamic "recurring_window" {
150+
for_each = local.cluster_maintenance_window_is_recurring
151+
content {
152+
start_time = var.maintenance_start_time
153+
end_time = var.maintenance_end_time
154+
recurrence = var.maintenance_recurrence
155+
}
156+
}
157+
158+
dynamic "daily_maintenance_window" {
159+
for_each = local.cluster_maintenance_window_is_daily
160+
content {
161+
start_time = var.maintenance_start_time
162+
}
151163
}
152164
}
153165

modules/beta-private-cluster/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ locals {
148148
identity_namespace = var.identity_namespace
149149
}]
150150
# /BETA features
151+
152+
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
153+
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
151154
}
152155

153156
/******************************************

modules/beta-private-cluster/variables.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,22 @@ variable "network_policy_provider" {
110110

111111
variable "maintenance_start_time" {
112112
type = string
113-
description = "Time window specified for daily maintenance operations in RFC3339 format"
113+
description = "Time window specified for daily or recurring maintenance operations in RFC3339 format"
114114
default = "05:00"
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+
}
128+
117129
variable "ip_range_pods" {
118130
type = string
119131
description = "The _name_ of the secondary subnet ip range to use for pods"

modules/beta-public-cluster/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ Then perform the following commands on the root folder:
146146
| istio | (Beta) Enable Istio addon | string | `"false"` | no |
147147
| 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 |
148148
| 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 |
149-
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
149+
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | string | `""` | no |
150+
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | string | `""` | no |
151+
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string | `"05:00"` | no |
150152
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
151153
| 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 |
152154
| name | The name of the cluster (required) | string | n/a | yes |

modules/beta-public-cluster/cluster.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,20 @@ resource "google_container_cluster" "primary" {
146146
}
147147

148148
maintenance_policy {
149-
daily_maintenance_window {
150-
start_time = var.maintenance_start_time
149+
dynamic "recurring_window" {
150+
for_each = local.cluster_maintenance_window_is_recurring
151+
content {
152+
start_time = var.maintenance_start_time
153+
end_time = var.maintenance_end_time
154+
recurrence = var.maintenance_recurrence
155+
}
156+
}
157+
158+
dynamic "daily_maintenance_window" {
159+
for_each = local.cluster_maintenance_window_is_daily
160+
content {
161+
start_time = var.maintenance_start_time
162+
}
151163
}
152164
}
153165

modules/beta-public-cluster/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ locals {
148148
identity_namespace = var.identity_namespace
149149
}]
150150
# /BETA features
151+
152+
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
153+
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
151154
}
152155

153156
/******************************************

modules/beta-public-cluster/variables.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,22 @@ variable "network_policy_provider" {
110110

111111
variable "maintenance_start_time" {
112112
type = string
113-
description = "Time window specified for daily maintenance operations in RFC3339 format"
113+
description = "Time window specified for daily or recurring maintenance operations in RFC3339 format"
114114
default = "05:00"
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+
}
128+
117129
variable "ip_range_pods" {
118130
type = string
119131
description = "The _name_ of the secondary subnet ip range to use for pods"

modules/private-cluster-update-variant/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Then perform the following commands on the root folder:
153153
| 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 |
154154
| 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 |
155155
| 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 |
156-
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
156+
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string | `"05:00"` | no |
157157
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
158158
| 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 |
159159
| 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 |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ locals {
106106
cluster_network_policy_enabled = ! local.cluster_output_network_policy_enabled
107107
cluster_http_load_balancing_enabled = ! local.cluster_output_http_load_balancing_enabled
108108
cluster_horizontal_pod_autoscaling_enabled = ! local.cluster_output_horizontal_pod_autoscaling_enabled
109+
109110
}
110111

111112
/******************************************

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ variable "network_policy_provider" {
110110

111111
variable "maintenance_start_time" {
112112
type = string
113-
description = "Time window specified for daily maintenance operations in RFC3339 format"
113+
description = "Time window specified for daily or recurring maintenance operations in RFC3339 format"
114114
default = "05:00"
115115
}
116116

117+
117118
variable "ip_range_pods" {
118119
type = string
119120
description = "The _name_ of the secondary subnet ip range to use for pods"

modules/private-cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Then perform the following commands on the root folder:
153153
| 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 |
154154
| 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 |
155155
| 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 |
156-
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
156+
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | string | `"05:00"` | no |
157157
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | object | `<list>` | no |
158158
| 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 |
159159
| 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 |

modules/private-cluster/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ locals {
106106
cluster_network_policy_enabled = ! local.cluster_output_network_policy_enabled
107107
cluster_http_load_balancing_enabled = ! local.cluster_output_http_load_balancing_enabled
108108
cluster_horizontal_pod_autoscaling_enabled = ! local.cluster_output_horizontal_pod_autoscaling_enabled
109+
109110
}
110111

111112
/******************************************

0 commit comments

Comments
 (0)