Skip to content

Support shutdownGracePeriodSeconds in node_kubelet_config#17556

Open
shlomitubul wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
shlomitubul:kubelet-shutdown-grace-period
Open

Support shutdownGracePeriodSeconds in node_kubelet_config#17556
shlomitubul wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
shlomitubul:kubelet-shutdown-grace-period

Conversation

@shlomitubul
Copy link
Copy Markdown

@shlomitubul shlomitubul commented May 14, 2026

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 two fields correspond to the shutdownGracePeriodSeconds and shutdownGracePeriodCriticalPodsSeconds properties that are already exposed in the NodeKubeletConfig struct of the container v1 and v1beta1 Go 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. Default 30.
  • shutdown_grace_period_critical_pods_seconds: portion reserved for critical pods (0 to 120, must be less than shutdown_grace_period_seconds).

Reference: GCP doc states gcloud equivalent is --system-config-from-file, but it is also a first-class field on NodeKubeletConfig, so it is consistent with the rest of the kubelet_config block to surface in TF.

Why this is needed

Validation

  • shutdown_grace_period_seconds is validated with validation.IntInSlice([]int{0, 30, 120}) to match the GCP-imposed allowed values.
  • shutdown_grace_period_critical_pods_seconds is validated with validation.IntBetween(0, 120).

What I touched

  • Schema: added 2 fields to schemaNodeConfig() kubelet_config block.
  • expandKubeletConfig: read both fields and set on kConfig.
  • flattenKubeletConfig: output both fields.
  • Test: extended testAccContainerNodePool_withKubeletConfig with the new fields + 2 new TestCheckResourceAttr assertions.
  • Docs: added entries under kubelet_config in container_cluster.html.markdown (which container_node_pool docs 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)

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

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
\`\`\`
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label May 14, 2026
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 14, 2026

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.

@github-actions
Copy link
Copy Markdown

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.

@shlomitubul shlomitubul marked this pull request as draft May 14, 2026 10:13
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).
@shlomitubul shlomitubul marked this pull request as ready for review May 14, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants