-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for maintenance window on google_container_cluster #670
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,6 +576,25 @@ func TestAccContainerCluster_withNodePoolNodeConfig(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccContainerCluster_withMaintenanceWindow(t *testing.T) { | ||
t.Parallel() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckContainerClusterDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccContainerCluster_withMaintenanceWindow("03:00"), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckContainerCluster( | ||
"google_container_cluster.primary"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be "google_container_cluster.with_maintenance_window" to match the resource name in the test config |
||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckContainerClusterDestroy(s *terraform.State) error { | ||
config := testAccProvider.Meta().(*Config) | ||
|
||
|
@@ -685,6 +704,11 @@ func testAccCheckContainerCluster(n string) resource.TestCheckFunc { | |
clusterTests = append(clusterTests, clusterTestField{"addons_config.0.horizontal_pod_autoscaling.0.disabled", horizontalPodAutoscalingDisabled}) | ||
clusterTests = append(clusterTests, clusterTestField{"addons_config.0.kubernetes_dashboard.0.disabled", kubernetesDashboardDisabled}) | ||
|
||
if cluster.MaintenancePolicy != nil { | ||
clusterTests = append(clusterTests, clusterTestField{"maintenance_policy.0.daily_maintenance_window.0.start_time", cluster.MaintenancePolicy.Window.DailyMaintenanceWindow.StartTime}) | ||
clusterTests = append(clusterTests, clusterTestField{"maintenance_policy.0.daily_maintenance_window.0.duration", cluster.MaintenancePolicy.Window.DailyMaintenanceWindow.Duration}) | ||
} | ||
|
||
for i, np := range cluster.NodePools { | ||
prefix := fmt.Sprintf("node_pool.%d.", i) | ||
clusterTests = append(clusterTests, clusterTestField{prefix + "name", np.Name}) | ||
|
@@ -1441,3 +1465,18 @@ resource "google_container_cluster" "with_node_pool_node_config" { | |
} | ||
`, testId, testId) | ||
} | ||
|
||
func testAccContainerCluster_withMaintenanceWindow(startTime string) string { | ||
return fmt.Sprintf(` | ||
resource "google_container_cluster" "with_maintenance_window" { | ||
name = "cluster-test-%s" | ||
zone = "us-central1-a" | ||
initial_node_count = 1 | ||
|
||
maintenance_policy { | ||
daily_maintenance_window { | ||
start_time = "%s" | ||
} | ||
} | ||
}`, acctest.RandString(10), startTime) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,9 @@ output "cluster_ca_certificate" { | |
write logs to. Available options include `logging.googleapis.com` and | ||
`none`. Defaults to `logging.googleapis.com` | ||
|
||
* `maintenance_policy` - (Optional) The maintenance policy to use for the cluster. Structure is | ||
documented below. | ||
|
||
* `master_auth` - (Optional) The authentication information for accessing the | ||
Kubernetes master. Structure is documented below. | ||
|
||
|
@@ -167,6 +170,20 @@ addons_config { | |
} | ||
``` | ||
|
||
The `maintenance_policy` block supports: | ||
|
||
* `daily_maintenance_window` - (Required) Time window specified for daily maintenance operations. | ||
Specify `start_time` in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format "HH:MM”, | ||
where HH : \[00-23\] and MM : \[00-59\] GMT. For example: | ||
|
||
``` | ||
maintenance_policy { | ||
daily_maintenance_window { | ||
start_time = "03:00" | ||
} | ||
} | ||
``` | ||
|
||
The `master_auth` block supports: | ||
|
||
* `password` - (Required) The password to use for HTTP basic authentication when accessing | ||
|
@@ -243,6 +260,10 @@ exported: | |
* `instance_group_urls` - List of instance group URLs which have been assigned | ||
to the cluster. | ||
|
||
* `maintenance_policy.daily_maintenance_window.duration` - Duration of the time window, automatically chosen to be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nested fields are fun! This is actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes - I see this was recently updated for the master_auth stuff (this explains why it didn't work when I tried to use those attributes without the 0 index recently!) |
||
smallest possible in the given scenario. | ||
Duration will be in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format "PTnHnMnS". | ||
|
||
* `master_auth.0.client_certificate` - Base64 encoded public certificate | ||
used by clients to authenticate to the cluster endpoint. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for the sake of future-proofing, let's go ahead and
ForceNew: true
this one too