diff --git a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go index 0b36aab67f95a..e2f462b30b419 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go +++ b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go @@ -326,6 +326,11 @@ func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error { defer close(delayedStopCh) <-stopCh + // As soon as shutdown is initiated, /readyz should start returning failure. + // This gives the load balancer a window defined by ShutdownDelayDuration to detect that /readyz is red + // and stop sending traffic to this server. + close(s.readinessStopCh) + s.Eventf(corev1.EventTypeNormal, "TerminationStart", "Received signal to terminate, becoming unready, but keeping serving") time.Sleep(s.ShutdownDelayDuration) @@ -396,7 +401,6 @@ func (s preparedGenericAPIServer) NonBlockingRun(stopCh <-chan struct{}) error { // ensure cleanup. go func() { <-stopCh - close(s.readinessStopCh) close(internalStopCh) if stoppedCh != nil { <-stoppedCh