Skip to content

Add preStop hook to prevent webhook failures during pod termination#290

Open
sotoiwa wants to merge 1 commit into
aws:masterfrom
sotoiwa:patch/preStop-hook
Open

Add preStop hook to prevent webhook failures during pod termination#290
sotoiwa wants to merge 1 commit into
aws:masterfrom
sotoiwa:patch/preStop-hook

Conversation

@sotoiwa
Copy link
Copy Markdown
Contributor

@sotoiwa sotoiwa commented Dec 12, 2025

Issue #, if available:

#289

Description of changes:

This PR adds a preStop hook with sleep action to the webhook deployment to prevent connection failures during pod termination.

Changes:

  • Added lifecycle.preStop.sleep configuration with 10-second delay to the webhook container

Problem solved:
During cluster operations (node drain, upgrade, pod deletion), the webhook experiences connection failures because pods receive traffic while terminating. This occurs due to the timing gap between pod termination start and Endpoints removal.

Technical details:
The preStop hook delays SIGTERM delivery, allowing time for:

  • Endpoints removal to propagate
  • In-flight requests to complete
  • kube-proxy iptables rules to update

The native sleep action is available since Kubernetes 1.29 (alpha) and 1.30+ (beta, enabled by default).

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

@sotoiwa sotoiwa requested a review from a team as a code owner December 12, 2025 10:15
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.

1 participant