Skip to content

Commit 7b12b63

Browse files
committed
Add liveness probe to OCS Operator
- Register /healthz endpoint in main.go - Add liveness, readiness, and startup probes to manager Deployment Signed-off-by: Oded Viner <[email protected]>
1 parent d54f77a commit 7b12b63

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

config/manager/manager.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ spec:
3030
image: ocs-dev/ocs-operator:latest
3131
imagePullPolicy: Always
3232
name: ocs-operator
33+
ports:
34+
- name: healthz
35+
containerPort: 8081
3336
env:
3437
- name: WATCH_NAMESPACE
3538
valueFrom:
@@ -38,13 +41,30 @@ spec:
3841
readinessProbe:
3942
httpGet:
4043
path: /readyz
41-
port: 8081
44+
port: healthz
4245
initialDelaySeconds: 5
4346
periodSeconds: 10
47+
timeoutSeconds: 5
48+
failureThreshold: 3
49+
livenessProbe:
50+
httpGet:
51+
path: /healthz
52+
port: healthz
53+
initialDelaySeconds: 15
54+
periodSeconds: 10
55+
timeoutSeconds: 5
56+
failureThreshold: 3
57+
startupProbe:
58+
httpGet:
59+
path: /healthz
60+
port: healthz
61+
periodSeconds: 10
62+
timeoutSeconds: 5
63+
failureThreshold: 30
4464
securityContext:
4565
allowPrivilegeEscalation: false
4666
capabilities:
47-
drop:
67+
drop:
4868
- all
4969
readOnlyRootFilesystem: true
5070
terminationMessagePolicy: FallbackToLogsOnError

deploy/csv-templates/ocs-operator.csv.yaml.in

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ metadata:
7979
"spec": null
8080
}
8181
]
82-
createdAt: "2025-08-01T04:18:29Z"
82+
createdAt: "2025-08-21T09:07:16Z"
8383
description: Red Hat OpenShift Container Storage provides hyperconverged storage
8484
for applications within an OpenShift cluster.
8585
operators.operatorframework.io/builder: operator-sdk-v1.30.0
@@ -617,20 +617,40 @@ spec:
617617
fieldPath: metadata.annotations['olm.targetNamespaces']
618618
image: quay.io/ocs-dev/ocs-operator:latest
619619
imagePullPolicy: Always
620+
livenessProbe:
621+
failureThreshold: 3
622+
httpGet:
623+
path: /healthz
624+
port: healthz
625+
initialDelaySeconds: 15
626+
periodSeconds: 10
627+
timeoutSeconds: 5
620628
name: ocs-operator
629+
ports:
630+
- containerPort: 8081
631+
name: healthz
621632
readinessProbe:
633+
failureThreshold: 3
622634
httpGet:
623635
path: /readyz
624-
port: 8081
636+
port: healthz
625637
initialDelaySeconds: 5
626638
periodSeconds: 10
639+
timeoutSeconds: 5
627640
resources: {}
628641
securityContext:
629642
allowPrivilegeEscalation: false
630643
capabilities:
631644
drop:
632645
- all
633646
readOnlyRootFilesystem: true
647+
startupProbe:
648+
failureThreshold: 30
649+
httpGet:
650+
path: /healthz
651+
port: healthz
652+
periodSeconds: 10
653+
timeoutSeconds: 5
634654
terminationMessagePolicy: FallbackToLogsOnError
635655
volumeMounts:
636656
- mountPath: /etc/private-key

deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ metadata:
5656
capabilities: Deep Insights
5757
categories: Storage
5858
containerImage: quay.io/ocs-dev/ocs-operator:latest
59-
createdAt: "2025-08-07T13:47:12Z"
59+
createdAt: "2025-08-21T09:07:16Z"
6060
description: Red Hat OpenShift Container Storage provides hyperconverged storage
6161
for applications within an OpenShift cluster.
6262
external.features.ocs.openshift.io/supported-platforms: '["BareMetal", "None",
@@ -658,13 +658,26 @@ spec:
658658
fieldPath: metadata.namespace
659659
image: quay.io/ocs-dev/ocs-operator:latest
660660
imagePullPolicy: Always
661+
livenessProbe:
662+
failureThreshold: 3
663+
httpGet:
664+
path: /healthz
665+
port: healthz
666+
initialDelaySeconds: 15
667+
periodSeconds: 10
668+
timeoutSeconds: 5
661669
name: ocs-operator
670+
ports:
671+
- containerPort: 8081
672+
name: healthz
662673
readinessProbe:
674+
failureThreshold: 3
663675
httpGet:
664676
path: /readyz
665-
port: 8081
677+
port: healthz
666678
initialDelaySeconds: 5
667679
periodSeconds: 10
680+
timeoutSeconds: 5
668681
resources:
669682
limits:
670683
cpu: 250m
@@ -678,6 +691,13 @@ spec:
678691
drop:
679692
- all
680693
readOnlyRootFilesystem: true
694+
startupProbe:
695+
failureThreshold: 30
696+
httpGet:
697+
path: /healthz
698+
port: healthz
699+
periodSeconds: 10
700+
timeoutSeconds: 5
681701
terminationMessagePolicy: FallbackToLogsOnError
682702
volumeMounts:
683703
- mountPath: /etc/private-key

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import (
6060
ctrl "sigs.k8s.io/controller-runtime"
6161
"sigs.k8s.io/controller-runtime/pkg/cache"
6262
apiclient "sigs.k8s.io/controller-runtime/pkg/client"
63+
"sigs.k8s.io/controller-runtime/pkg/healthz"
6364
"sigs.k8s.io/controller-runtime/pkg/log/zap"
6465
"sigs.k8s.io/controller-runtime/pkg/manager"
6566
metrics "sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -319,6 +320,12 @@ func main() {
319320
os.Exit(1)
320321
}
321322

323+
// Liveness (/healthz)
324+
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
325+
setupLog.Error(err, "unable to add a health check")
326+
os.Exit(1)
327+
}
328+
322329
// Add readiness probe
323330
if err := mgr.AddReadyzCheck("readyz", storagecluster.ReadinessChecker); err != nil {
324331
setupLog.Error(err, "unable add a readiness check")

0 commit comments

Comments
 (0)