Support shutdownGracePeriodSeconds in node_kubelet_config#17556
Support shutdownGracePeriodSeconds in node_kubelet_config#17556shlomitubul wants to merge 2 commits into
Conversation
Add `shutdown_grace_period_seconds` and `shutdown_grace_period_critical_pods_seconds` fields to the `kubelet_config` block on `google_container_node_pool` and `google_container_cluster` resources. These fields correspond to the `shutdownGracePeriodSeconds` and `shutdownGracePeriodCriticalPodsSeconds` properties already present in the `NodeKubeletConfig` message of the GKE container/v1 API. They control how long a node delays shutting down to gracefully terminate Pods (only valid for Spot VMs). Allowed values for `shutdown_grace_period_seconds`: 0, 30, 120. Reference: https://cloud.google.com/kubernetes-engine/docs/how-to/node-system-config Tracked under #21030. **Release Note Template for Downstream PRs (will be copied)** \`\`\`release-note:enhancement container: added \`node_config.kubelet_config.shutdown_grace_period_seconds\` and \`node_config.kubelet_config.shutdown_grace_period_critical_pods_seconds\` fields to \`google_container_node_pool\` and \`google_container_cluster\` resources \`\`\`
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @malhotrasagar2212, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
Match the parent shutdown_grace_period_seconds field's description: the critical-pods variant is transitively Spot-only since it depends on shutdown_grace_period_seconds being set (per Go SDK comment and GCP docs).
Add
shutdown_grace_period_secondsandshutdown_grace_period_critical_pods_secondsfields to thekubelet_configblock ongoogle_container_node_poolandgoogle_container_clusterresources.These two fields correspond to the
shutdownGracePeriodSecondsandshutdownGracePeriodCriticalPodsSecondsproperties that are already exposed in theNodeKubeletConfigstruct of the containerv1andv1beta1Go API SDK, but are not currently surfaced in the Terraform provider schema.The fields control how long a GKE node delays shutting down to gracefully terminate Pods. Per the GKE node system configuration docs:
shutdown_grace_period_seconds: total duration the node delays shutdown. Only valid for Spot VMs. Allowed values:0,30,120. Default30.shutdown_grace_period_critical_pods_seconds: portion reserved for critical pods (0to120, must be less thanshutdown_grace_period_seconds).Reference: GCP doc states
gcloudequivalent is--system-config-from-file, but it is also a first-class field onNodeKubeletConfig, so it is consistent with the rest of thekubelet_configblock to surface in TF.Why this is needed
Validation
shutdown_grace_period_secondsis validated withvalidation.IntInSlice([]int{0, 30, 120})to match the GCP-imposed allowed values.shutdown_grace_period_critical_pods_secondsis validated withvalidation.IntBetween(0, 120).What I touched
schemaNodeConfig()kubelet_configblock.expandKubeletConfig: read both fields and set onkConfig.flattenKubeletConfig: output both fields.testAccContainerNodePool_withKubeletConfigwith the new fields + 2 newTestCheckResourceAttrassertions.kubelet_configincontainer_cluster.html.markdown(whichcontainer_node_pooldocs link to).Out of scope (intentional)
schemaNodePoolAutoConfigNodeKubeletConfig(the auto-config CC subset) is intentionally not extended in this PR. That schema is explicitly a subset; extending it can be a follow-up.Release Note Template for Downstream PRs (will be copied)