Skip to content

Commit

Permalink
[v2] adding liveness and readiness probes (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
zroubalik authored Apr 29, 2020
1 parent 6619132 commit 711b0ed
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
26 changes: 20 additions & 6 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (
"runtime"
"strings"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"

"github.com/kedacore/keda/pkg/apis"
"github.com/kedacore/keda/pkg/controller"
"github.com/kedacore/keda/version"
Expand All @@ -26,8 +22,11 @@ import (
"github.com/spf13/pflag"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/healthz"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
Expand Down Expand Up @@ -95,8 +94,9 @@ func main() {

// Set default manager options
options := manager.Options{
Namespace: namespace,
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
Namespace: namespace,
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
HealthProbeBindAddress: ":8080",
}

// Add support for MultiNamespace set in WATCH_NAMESPACE (e.g ns1,ns2)
Expand All @@ -115,6 +115,20 @@ func main() {
os.Exit(1)
}

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

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

log.Info("Registering Components.")

// Setup Scheme for all resources
Expand Down
10 changes: 10 additions & 0 deletions deploy/12-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ spec:
- '--zap-level=info'
- '--zap-time-encoding=epoch'
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 25
readinessProbe:
httpGet:
path: /readyz
port: 8080
initialDelaySeconds: 20
env:
- name: WATCH_NAMESPACE
value: ""
Expand Down
12 changes: 12 additions & 0 deletions deploy/22-metrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ spec:
- name: keda-metrics-apiserver
image: docker.io/kedacore/keda-metrics-adapter:2.0.0-alpha1
imagePullPolicy: Always
livenessProbe:
httpGet:
scheme: HTTPS
path: /healthz
port: 6443
initialDelaySeconds: 5
readinessProbe:
httpGet:
scheme: HTTPS
path: /readyz
port: 6443
initialDelaySeconds: 5
env:
- name: WATCH_NAMESPACE
value: ""
Expand Down

0 comments on commit 711b0ed

Please sign in to comment.