Skip to content

Commit 625e804

Browse files
authored
Add operator deployment readiness probe (#1874)
* Add operator deployment readiness probe
1 parent 29cec0c commit 625e804

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
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
@@ -470,6 +470,11 @@ securityContext:
470470
readOnlyRootFilesystem: true
471471
allowPrivilegeEscalation: false
472472

473+
# Allow to setup operator Deployment readiness probe
474+
readinessProbe:
475+
initialDelaySeconds: 5
476+
periodSeconds: 10
477+
473478
# Affinity for pod assignment
474479
# Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
475480
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(),

0 commit comments

Comments
 (0)