Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] adding liveness and readiness probes #792

Merged
merged 1 commit into from
Apr 29, 2020
Merged
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
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