Skip to content

Commit bb74ea3

Browse files
committed
add liveness, readiness, and startup probes to noobaa-operator
- integrate controller-runtime healthz and readyz endpoints into the namespace-scoped manager - expose probe server on :8081 and register default checks - update operator Deployment with liveness, readiness, and startup probes Signed-off-by: Oded Viner <[email protected]>
1 parent aee069d commit bb74ea3

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

deploy/operator.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ spec:
4242
- name: noobaa-operator
4343
image: NOOBAA_OPERATOR_IMAGE
4444
terminationMessagePolicy: FallbackToLogsOnError
45+
ports:
46+
- name: readyz
47+
containerPort: 8081
4548
volumeMounts:
4649
- name: bound-sa-token
4750
mountPath: /var/run/secrets/openshift/serviceaccount
@@ -51,6 +54,29 @@ spec:
5154
# SHOULD BE RETURNED ONCE COSI IS BACK
5255
# - name: socket
5356
# mountPath: /var/lib/cosi
57+
readinessProbe:
58+
httpGet:
59+
path: /readyz
60+
port: readyz
61+
initialDelaySeconds: 5
62+
periodSeconds: 10
63+
timeoutSeconds: 5
64+
failureThreshold: 3
65+
livenessProbe:
66+
httpGet:
67+
path: /readyz
68+
port: readyz
69+
initialDelaySeconds: 15
70+
periodSeconds: 10
71+
timeoutSeconds: 5
72+
failureThreshold: 3
73+
startupProbe:
74+
httpGet:
75+
path: /readyz
76+
port: readyz
77+
periodSeconds: 10
78+
timeoutSeconds: 5
79+
failureThreshold: 30
5480
resources:
5581
limits:
5682
cpu: "250m"

pkg/bundle/deploy.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6436,6 +6436,9 @@ spec:
64366436
- name: noobaa-operator
64376437
image: NOOBAA_OPERATOR_IMAGE
64386438
terminationMessagePolicy: FallbackToLogsOnError
6439+
ports:
6440+
- name: readyz
6441+
containerPort: 8081
64396442
volumeMounts:
64406443
- name: bound-sa-token
64416444
mountPath: /var/run/secrets/openshift/serviceaccount
@@ -6445,6 +6448,29 @@ spec:
64456448
# SHOULD BE RETURNED ONCE COSI IS BACK
64466449
# - name: socket
64476450
# mountPath: /var/lib/cosi
6451+
readinessProbe:
6452+
httpGet:
6453+
path: /readyz
6454+
port: readyz
6455+
initialDelaySeconds: 5
6456+
periodSeconds: 10
6457+
timeoutSeconds: 5
6458+
failureThreshold: 3
6459+
livenessProbe:
6460+
httpGet:
6461+
path: /readyz
6462+
port: readyz
6463+
initialDelaySeconds: 15
6464+
periodSeconds: 10
6465+
timeoutSeconds: 5
6466+
failureThreshold: 3
6467+
startupProbe:
6468+
httpGet:
6469+
path: /readyz
6470+
port: readyz
6471+
periodSeconds: 10
6472+
timeoutSeconds: 5
6473+
failureThreshold: 30
64486474
resources:
64496475
limits:
64506476
cpu: "250m"
@@ -7128,4 +7154,3 @@ metadata:
71287154
app: prometheus-adapter
71297155
name: custom-metrics-prometheus-adapter
71307156
`
7131-

pkg/operator/manager.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/operator-framework/operator-lib/leader"
2626
"sigs.k8s.io/controller-runtime/pkg/cache"
27+
"sigs.k8s.io/controller-runtime/pkg/healthz"
2728
"sigs.k8s.io/controller-runtime/pkg/manager"
2829
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
2930
metricsServer "sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -44,6 +45,11 @@ func RunOperator(cmd *cobra.Command, args []string) {
4445
util.InitLogger(logrus.DebugLevel)
4546
}
4647
version.RunVersion(cmd, args)
48+
// Probe address from CLI flag (defaults to :8081)
49+
probeAddr := os.Getenv("HEALTH_PROBE_BIND_ADDRESS")
50+
if probeAddr == "" {
51+
probeAddr = ":8081"
52+
}
4753

4854
config := util.KubeConfig()
4955

@@ -66,6 +72,7 @@ func RunOperator(cmd *cobra.Command, args []string) {
6672
Metrics: metricsServer.Options{
6773
BindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
6874
},
75+
HealthProbeBindAddress: probeAddr, // Serve /healthz and /readyz here
6976
})
7077
if err != nil {
7178
log.Fatalf("Failed to create manager: %s", err)
@@ -97,6 +104,11 @@ func RunOperator(cmd *cobra.Command, args []string) {
97104
log.Fatalf("Failed AddToClusterScopedManager: %s", err)
98105
}
99106

107+
// Register readiness endpoint on mgr
108+
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
109+
log.Fatalf("Failed to add readiness check: %s", err)
110+
}
111+
100112
util.Panic(mgr.Add(manager.RunnableFunc(func(ctx context.Context) error {
101113
system.RunOperatorCreate(cmd, args)
102114
return nil

0 commit comments

Comments
 (0)