Add shutdown delay (wait for the readiness probe)

This commit is contained in:
Stefan Prodan
2018-09-25 12:01:01 +03:00
parent 083de34465
commit 18a22d1b94
4 changed files with 10 additions and 4 deletions

View File

@@ -68,6 +68,7 @@ spec:
- check
- http
- localhost:{{ .Values.containerPort }}/readyz
periodSeconds: 3
volumeMounts:
- name: data
mountPath: /data

View File

@@ -69,6 +69,7 @@ spec:
- check
- http
- localhost:{{ .Values.containerPort }}/readyz
periodSeconds: 3
volumeMounts:
- name: data
mountPath: /data

View File

@@ -71,6 +71,7 @@ spec:
- check
- http
- localhost:{{ .Values.service.containerPort }}/readyz
periodSeconds: 3
volumeMounts:
- name: data
mountPath: /data

View File

@@ -10,6 +10,8 @@ import (
"sync/atomic"
"time"
"github.com/spf13/viper"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/stefanprodan/k8s-podinfo/pkg/fscache"
@@ -143,10 +145,11 @@ func (s *Server) ListenAndServe(stopCh <-chan struct{}) {
s.logger.Info("Shutting down HTTP server", zap.Duration("timeout", s.config.HttpServerShutdownTimeout))
// wait for Kubernetes readiness probe
// to remove this instance from the load balancer
// the readiness check interval must lower than the timeout
//time.Sleep(s.config.HttpServerShutdownTimeout)
// wait for Kubernetes readiness probe to remove this instance from the load balancer
// the readiness check interval must be lower than the timeout
if viper.GetString("level") != "debug" {
time.Sleep(3 * time.Second)
}
// attempt graceful shutdown
if err := srv.Shutdown(ctx); err != nil {