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

Replace default preStopHook with Kubernetes native sleep #538

Closed
tronghn opened this issue Jun 24, 2024 · 1 comment
Closed

Replace default preStopHook with Kubernetes native sleep #538

tronghn opened this issue Jun 24, 2024 · 1 comment
Labels
k8s-1.30 Kubernetes 1.30

Comments

@tronghn
Copy link
Contributor

tronghn commented Jun 24, 2024

Since the dawn of time (for locally adjusted values of time), Naiserator has configured a default preStopHook for pods:

if preStopHook == nil {
return &corev1.Lifecycle{
PreStop: &corev1.LifecycleHandler{
Exec: &corev1.ExecAction{
Command: []string{"sleep", "5"},
},
},
}, nil
}

This essentially executes a sleep 5 to allow a grace period before the container receives a SIGTERM and starts gracefully shutting down. This allows an ingress controller to update its list of Endpoints for routing requests without perceived "downtime".

While this has worked wonderfully for many years, its a hack that depends on the sleep binary to exist in the given container. With the rise of distroless-based images, we can no longer expect this to be the case.

Fortunately for us, KEP-3960: Introducing Sleep Action for PreStop Hook addresses this natively in Kubernetes. It is slated to be available as an alpha feature from 1.29, beta from 1.30, and GA from 1.32.

We should switch to using this feature whenever it is available.

@kimtore kimtore added the k8s-1.30 Kubernetes 1.30 label Jul 2, 2024
@kimtore
Copy link
Contributor

kimtore commented Aug 7, 2024

Issue tracking: kubernetes/enhancements#3960

Can confirm that this feature still is slated to be available as beta in 1.30.

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

No branches or pull requests

2 participants