Skip to content

Commit 85cfb93

Browse files
committed
Add operator deployment readiness probe
1 parent 6d0117b commit 85cfb93

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

charts/postgres-operator/templates/deployment.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ spec:
5757
{{ toYaml .Values.resources | indent 10 }}
5858
securityContext:
5959
{{ toYaml .Values.securityContext | indent 10 }}
60+
{{- if .Values.readinessProbe }}
61+
readinessProbe:
62+
httpGet:
63+
path: /readyz
64+
port: {{ .Values.configLoggingRestApi.api_port }}
65+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
66+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
67+
{{- end }}
6068
{{- if .Values.imagePullSecrets }}
6169
imagePullSecrets:
6270
{{ toYaml .Values.imagePullSecrets | indent 8 }}

charts/postgres-operator/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ securityContext:
435435
readOnlyRootFilesystem: true
436436
allowPrivilegeEscalation: false
437437

438+
# Allow to setup operator Deployment readiness probe
439+
readinessProbe:
440+
initialDelaySeconds: 5
441+
periodSeconds: 10
442+
438443
# Affinity for pod assignment
439444
# Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
440445
affinity: {}

pkg/apiserver/apiserver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"time"
1313

1414
"github.com/sirupsen/logrus"
15-
1615
"github.com/zalando/postgres-operator/pkg/cluster"
1716
"github.com/zalando/postgres-operator/pkg/spec"
1817
"github.com/zalando/postgres-operator/pkg/util"
@@ -87,6 +86,7 @@ func New(controller controllerInformer, port int, logger *logrus.Logger) *Server
8786
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
8887

8988
mux.Handle("/status/", http.HandlerFunc(s.controllerStatus))
89+
mux.Handle("/readyz/", http.HandlerFunc(s.controllerReady))
9090
mux.Handle("/config/", http.HandlerFunc(s.operatorConfig))
9191

9292
mux.HandleFunc("/clusters/", s.clusters)
@@ -155,6 +155,10 @@ func (s *Server) controllerStatus(w http.ResponseWriter, req *http.Request) {
155155
s.respond(s.controller.GetStatus(), nil, w)
156156
}
157157

158+
func (s *Server) controllerReady(w http.ResponseWriter, req *http.Request) {
159+
s.respond("OK", nil, w)
160+
}
161+
158162
func (s *Server) operatorConfig(w http.ResponseWriter, req *http.Request) {
159163
s.respond(map[string]interface{}{
160164
"controller": s.controller.GetConfig(),

pkg/controller/controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,14 @@ func (c *Controller) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
455455
go c.runPodInformer(stopCh, wg)
456456
go c.runPostgresqlInformer(stopCh, wg)
457457
go c.clusterResync(stopCh, wg)
458-
go c.apiserver.Run(stopCh, wg)
459458
go c.kubeNodesInformer(stopCh, wg)
460459

461460
if c.opConfig.EnablePostgresTeamCRD {
462461
go c.runPostgresTeamInformer(stopCh, wg)
463462
}
464463

464+
go c.apiserver.Run(stopCh, wg)
465+
465466
c.logger.Info("started working in background")
466467
}
467468

0 commit comments

Comments
 (0)