Skip to content
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

Enable graceful node shutdown for 1.30+ on AL2 #1544

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cartermckinnon
Copy link
Member

@cartermckinnon cartermckinnon commented Dec 13, 2023

Description of changes:

Configures a node shutdown period of 45 seconds, with the last 15 seconds reserved for critical pods, for Kubernetes versions 1.30 and above.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@cartermckinnon
Copy link
Member Author

/ci

Copy link
Contributor

@cartermckinnon roger that! I've dispatched a workflow. 👍

Copy link
Contributor

@cartermckinnon the workflow that you requested has completed. 🎉

Kubernetes versionBuildLaunchTest
1.23failure ❌skipped ⏭️skipped ⏭️
1.24failure ❌skipped ⏭️skipped ⏭️
1.25failure ❌skipped ⏭️skipped ⏭️
1.26failure ❌skipped ⏭️skipped ⏭️
1.27failure ❌skipped ⏭️skipped ⏭️
1.28failure ❌skipped ⏭️skipped ⏭️

@cartermckinnon
Copy link
Member Author

CI is broken after Packer finally pulled the plug on builtin plugins. Should be fixed by #1545 .

@cartermckinnon
Copy link
Member Author

/ci

let's see if that did it...

Copy link
Contributor

@cartermckinnon roger that! I've dispatched a workflow. 👍

Copy link
Contributor

@cartermckinnon the workflow that you requested has completed. 🎉

Kubernetes versionBuildLaunchTest
1.23success ✅success ✅success ✅
1.24success ✅success ✅success ✅
1.25success ✅success ✅success ✅
1.26success ✅success ✅success ✅
1.27success ✅success ✅success ✅
1.28success ✅success ✅success ✅

bryantbiggs added a commit to clowdhaus/eksnode that referenced this pull request Dec 26, 2023
@cartermckinnon cartermckinnon changed the title Enable graceful node shutdown for 1.29+ [WIP] Enable graceful node shutdown for 1.29+ Jan 31, 2024
@cartermckinnon
Copy link
Member Author

In my tests, this config didn't seem sufficient to actually block shutdown. I think we need to increase logind's InhibitDelayMaxSec for this to have any effect. Kubelet will attempt to increase it itself, but maybe this doesn't work on AL2?

@youwalther65
Copy link

youwalther65 commented Apr 9, 2024

@cartermckinnon EBS CSI FAQ troubleshooting section here proposes InhibitDelayMaxSec as well and following it I got:

#  journalctl  -u kubelet | grep -i shutdown
Apr 09 08:02:36 ip-10-0-136-54.eu-west-1.compute.internal kubelet[1011931]: I0409 08:02:36.347456 1011931 nodeshutdown_manager_linux.go:137] "Creating node shutdown manager" shutdownGracePeriodRequested="45s" shutdownGracePeriodCriticalPods="15s" shutdownGracePeriodByPodPriority=[{"Priority":0,"ShutdownGracePeriodSeconds":30},{"Priority":2000000000,"ShutdownGracePeriodSeconds":15}]

# systemd-inhibit --list
     Who: kubelet (UID 0/root, PID 1011931/kubelet)
    What: shutdown
     Why: Kubelet needs time to handle node shutdown
    Mode: delay

1 inhibitors listed.

But I still wonder how Karpenter or MNG node drain plays together with kubelet graceful shutdown.

@cartermckinnon
Copy link
Member Author

cartermckinnon commented Apr 9, 2024

But I still wonder how Karpenter or MNG node drain plays together with kubelet graceful shutdown.

MNG and Karpenter will evict all the pods from a node before shutting it down, so you don't really need kubelet's graceful shutdown feature by the time the shutdown signal arrives (though some daemonsets could still benefit from it). The graceful shutdown feature is intended to honor your pods' own termination grace periods and cleanly shut them down when e.g. there is no orchestrator handling that for you (such as when the shutdown is unexpected).

@cartermckinnon cartermckinnon changed the title [WIP] Enable graceful node shutdown for 1.29+ [WIP] Enable graceful node shutdown for 1.30+ Apr 9, 2024
@cartermckinnon cartermckinnon changed the base branch from master to main April 9, 2024 17:07
@cartermckinnon cartermckinnon force-pushed the graceful-node-shutdown branch 3 times, most recently from 141e688 to f566d39 Compare April 9, 2024 17:29
@cartermckinnon
Copy link
Member Author

/ci
+workflow:os_distros al2

@cartermckinnon
Copy link
Member Author

/ci
+workflow:os_distros al2

Copy link
Contributor

github-actions bot commented Apr 9, 2024

@cartermckinnon roger that! I've dispatched a workflow. 👍

@cartermckinnon cartermckinnon changed the title [WIP] Enable graceful node shutdown for 1.30+ Enable graceful node shutdown for 1.30+ Apr 9, 2024
@awslabs awslabs deleted a comment from github-actions bot Apr 9, 2024
@awslabs awslabs deleted a comment from github-actions bot Apr 9, 2024
@awslabs awslabs deleted a comment from github-actions bot Apr 9, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

@cartermckinnon the workflow that you requested has completed. 🎉

AMI variantBuildTest
1.21 / al2success ✅success ✅
1.22 / al2success ✅success ✅
1.23 / al2success ✅success ✅
1.24 / al2success ✅success ✅
1.25 / al2success ✅success ✅
1.26 / al2success ✅success ✅
1.27 / al2success ✅success ✅
1.28 / al2success ✅success ✅
1.29 / al2success ✅success ✅

@cartermckinnon
Copy link
Member Author

/ci
+workflow:os_distros al2
+workflow:k8s_versions 1.30

@cartermckinnon cartermckinnon changed the title Enable graceful node shutdown for 1.30+ Enable graceful node shutdown for 1.30+ on AL2 Apr 9, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

@cartermckinnon roger that! I've dispatched a workflow. 👍

Copy link
Contributor

github-actions bot commented Apr 9, 2024

@cartermckinnon the workflow that you requested has completed. 🎉

AMI variantBuildTest
1.30 / al2failure ❌skipped ⏭️

@youwalther65
Copy link

But I still wonder how Karpenter or MNG node drain plays together with kubelet graceful shutdown.

MNG and Karpenter will evict all the pods from a node before shutting it down, so you don't really need kubelet's graceful shutdown feature by the time the shutdown signal arrives (though some daemonsets could still benefit from it). The graceful shutdown feature is intended to honor your pods' own termination grace periods and cleanly shut them down when e.g. there is no orchestrator handling that for you (such as when the shutdown is unexpected).

Agree, especially DaemonSets like EBS CSI would benefit from kubelet graceful node shutdown and the team even recommends it in its FAQ

@cartermckinnon
Copy link
Member Author

/ci
+workflow:k8s_versions 1.30

@stevehipwell
Copy link
Contributor

@cartermckinnon is this blocked for a reason? Also what about AL2023?

I was just looking through the code for Bottlerocket and I can't see any handling for InhibitDelayMaxSec despite this being supported there, but I suspect that this should be configurable given the default termination grace period for a K8s pod is 300s?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants