Skip to content

Commit

Permalink
feat: Recurring maintenance window to GA (#1262)
Browse files Browse the repository at this point in the history
* Added code changes from #1242

Signed-off-by: Roland Urbano <roland.urbano@datenkraft.com>

* Added variable definition for new inputs

Signed-off-by: Roland Urbano <roland.urbano@datenkraft.com>

* Extended READMEs for new inputs and added documentation

Signed-off-by: Roland Urbano <roland.urbano@datenkraft.com>

Autogenerated documentation and variable inputs

Signed-off-by: Roland Urbano <roland.urbano@datenkraft.com>

Co-authored-by: Roland Urbano <roland.urbano@datenkraft.com>
Co-authored-by: Andrew Peabody <andrewpeabody@google.com>
  • Loading branch information
3 people committed May 31, 2022
1 parent 4a7e6e4 commit 4bba52f
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ Then perform the following commands on the root folder:
| 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 |
| 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 |
| 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 |
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
| 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 |
| 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 |
Expand Down
6 changes: 0 additions & 6 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ resource "google_container_cluster" "primary" {
}

maintenance_policy {
{% if beta_cluster %}
dynamic "recurring_window" {
for_each = local.cluster_maintenance_window_is_recurring
content {
Expand All @@ -268,11 +267,6 @@ resource "google_container_cluster" "primary" {
end_time = maintenance_exclusion.value.end_time
}
}
{% else %}
daily_maintenance_window {
start_time = var.maintenance_start_time
}
{% endif %}
}

{% if autopilot_cluster != true %}
Expand Down
2 changes: 0 additions & 2 deletions autogen/main/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ locals {
# /BETA features
{% endif %}

{% if beta_cluster %}
cluster_maintenance_window_is_recurring = var.maintenance_recurrence != "" && var.maintenance_end_time != "" ? [1] : []
cluster_maintenance_window_is_daily = length(local.cluster_maintenance_window_is_recurring) > 0 ? [] : [1]
{% endif %}
}

/******************************************
Expand Down
2 changes: 0 additions & 2 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ variable "maintenance_exclusions" {
default = []
}

{% if beta_cluster %}
variable "maintenance_end_time" {
type = string
description = "Time window specified for recurring maintenance operations in RFC3339 format"
Expand All @@ -126,7 +125,6 @@ variable "maintenance_recurrence" {
description = "Frequency of the recurring maintenance window in RFC5545 format."
default = ""
}
{% endif %}

variable "ip_range_pods" {
type = string
Expand Down
25 changes: 23 additions & 2 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,29 @@ resource "google_container_cluster" "primary" {
}

maintenance_policy {
daily_maintenance_window {
start_time = var.maintenance_start_time
dynamic "recurring_window" {
for_each = local.cluster_maintenance_window_is_recurring
content {
start_time = var.maintenance_start_time
end_time = var.maintenance_end_time
recurrence = var.maintenance_recurrence
}
}

dynamic "daily_maintenance_window" {
for_each = local.cluster_maintenance_window_is_daily
content {
start_time = var.maintenance_start_time
}
}

dynamic "maintenance_exclusion" {
for_each = var.maintenance_exclusions
content {
exclusion_name = maintenance_exclusion.value.name
start_time = maintenance_exclusion.value.start_time
end_time = maintenance_exclusion.value.end_time
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ locals {
workload_pool = "${var.project_id}.svc.id.goog" }] : [{ workload_pool = var.identity_namespace
}]

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

/******************************************
Expand Down
2 changes: 2 additions & 0 deletions modules/private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ Then perform the following commands on the root folder:
| 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 |
| 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 |
| 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 |
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
| 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 |
| 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 |
Expand Down
25 changes: 23 additions & 2 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,29 @@ resource "google_container_cluster" "primary" {
}

maintenance_policy {
daily_maintenance_window {
start_time = var.maintenance_start_time
dynamic "recurring_window" {
for_each = local.cluster_maintenance_window_is_recurring
content {
start_time = var.maintenance_start_time
end_time = var.maintenance_end_time
recurrence = var.maintenance_recurrence
}
}

dynamic "daily_maintenance_window" {
for_each = local.cluster_maintenance_window_is_daily
content {
start_time = var.maintenance_start_time
}
}

dynamic "maintenance_exclusion" {
for_each = var.maintenance_exclusions
content {
exclusion_name = maintenance_exclusion.value.name
start_time = maintenance_exclusion.value.start_time
end_time = maintenance_exclusion.value.end_time
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions modules/private-cluster-update-variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ locals {
workload_pool = "${var.project_id}.svc.id.goog" }] : [{ workload_pool = var.identity_namespace
}]

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

/******************************************
Expand Down
11 changes: 11 additions & 0 deletions modules/private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ variable "maintenance_exclusions" {
default = []
}

variable "maintenance_end_time" {
type = string
description = "Time window specified for recurring maintenance operations in RFC3339 format"
default = ""
}

variable "maintenance_recurrence" {
type = string
description = "Frequency of the recurring maintenance window in RFC5545 format."
default = ""
}

variable "ip_range_pods" {
type = string
Expand Down
2 changes: 2 additions & 0 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ Then perform the following commands on the root folder:
| 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 |
| 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 |
| 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 |
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
| 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 |
| 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 |
Expand Down
25 changes: 23 additions & 2 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,29 @@ resource "google_container_cluster" "primary" {
}

maintenance_policy {
daily_maintenance_window {
start_time = var.maintenance_start_time
dynamic "recurring_window" {
for_each = local.cluster_maintenance_window_is_recurring
content {
start_time = var.maintenance_start_time
end_time = var.maintenance_end_time
recurrence = var.maintenance_recurrence
}
}

dynamic "daily_maintenance_window" {
for_each = local.cluster_maintenance_window_is_daily
content {
start_time = var.maintenance_start_time
}
}

dynamic "maintenance_exclusion" {
for_each = var.maintenance_exclusions
content {
exclusion_name = maintenance_exclusion.value.name
start_time = maintenance_exclusion.value.start_time
end_time = maintenance_exclusion.value.end_time
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions modules/private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ locals {
workload_pool = "${var.project_id}.svc.id.goog" }] : [{ workload_pool = var.identity_namespace
}]

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

/******************************************
Expand Down
11 changes: 11 additions & 0 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ variable "maintenance_exclusions" {
default = []
}

variable "maintenance_end_time" {
type = string
description = "Time window specified for recurring maintenance operations in RFC3339 format"
default = ""
}

variable "maintenance_recurrence" {
type = string
description = "Frequency of the recurring maintenance window in RFC5545 format."
default = ""
}

variable "ip_range_pods" {
type = string
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ variable "maintenance_exclusions" {
default = []
}

variable "maintenance_end_time" {
type = string
description = "Time window specified for recurring maintenance operations in RFC3339 format"
default = ""
}

variable "maintenance_recurrence" {
type = string
description = "Frequency of the recurring maintenance window in RFC5545 format."
default = ""
}

variable "ip_range_pods" {
type = string
Expand Down

0 comments on commit 4bba52f

Please sign in to comment.