Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions cmd/cockroach-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"flag"
"os"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"strings"

crdbv1alpha1 "github.com/cockroachdb/cockroach-operator/apis/v1alpha1"
Expand Down Expand Up @@ -88,13 +89,15 @@ func main() {
watchNamespace := os.Getenv(watchNamespaceEnvVar)

mgrOpts := ctrl.Options{
Scheme: scheme,
Namespace: watchNamespace,
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: leaderElectionID,
Port: 9443,
CertDir: certDir,
Scheme: scheme,
Namespace: watchNamespace,
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: leaderElectionID,
LivenessEndpointName: "live",
ReadinessEndpointName: "ready",
Port: 9443,
CertDir: certDir,
}

if strings.Contains(watchNamespace, ",") {
Expand All @@ -109,6 +112,20 @@ func main() {
os.Exit(1)
}

// Add readiness probe
err = mgr.AddReadyzCheck("ready-ping", healthz.Ping)
if err != nil {
setupLog.Error(err, "unable add a readiness check")
os.Exit(1)
}

// Add liveness probe
err = mgr.AddHealthzCheck("live-ping", healthz.Ping)
if err != nil {
setupLog.Error(err, "unable add a health check")
os.Exit(1)
}

if err := (&crdbv1alpha1.CrdbCluster{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to setup webhook")
os.Exit(1)
Expand Down
14 changes: 14 additions & 0 deletions install/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,20 @@ spec:
image: cockroachdb/cockroach-operator:v2.10.0
imagePullPolicy: IfNotPresent
name: cockroach-operator
readinessProbe:
httpGet:
path: /ready
port: 9443
scheme: HTTPS
periodSeconds: 5
initialDelaySeconds: 5
livenessProbe:
httpGet:
path: /live
port: 9443
scheme: HTTPS
initialDelaySeconds: 10
periodSeconds: 5
resources:
requests:
cpu: 10m
Expand Down