diff --git a/charts/descheduler/templates/deployment.yaml b/charts/descheduler/templates/deployment.yaml index c0b60c2c4..3e4d85189 100644 --- a/charts/descheduler/templates/deployment.yaml +++ b/charts/descheduler/templates/deployment.yaml @@ -47,6 +47,14 @@ spec: ports: - containerPort: 10258 protocol: TCP + livenessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10258 + scheme: HTTPS + initialDelaySeconds: 3 + periodSeconds: 3 resources: {{- toYaml .Values.resources | nindent 12 }} securityContext: diff --git a/cmd/descheduler/app/server.go b/cmd/descheduler/app/server.go index a3ed547c5..3044f4233 100644 --- a/cmd/descheduler/app/server.go +++ b/cmd/descheduler/app/server.go @@ -20,6 +20,7 @@ package app import ( "context" "io" + "k8s.io/apiserver/pkg/server/healthz" "sigs.k8s.io/descheduler/cmd/descheduler/app/options" "sigs.k8s.io/descheduler/pkg/descheduler" @@ -68,15 +69,17 @@ func NewDeschedulerCommand(out io.Writer) *cobra.Command { klog.SetLogger(log) } + ctx := context.TODO() + pathRecorderMux := mux.NewPathRecorderMux("descheduler") if !s.DisableMetrics { - ctx := context.TODO() - pathRecorderMux := mux.NewPathRecorderMux("descheduler") pathRecorderMux.Handle("/metrics", legacyregistry.HandlerWithReset()) + } - if _, err := SecureServing.Serve(pathRecorderMux, 0, ctx.Done()); err != nil { - klog.Fatalf("failed to start secure server: %v", err) - return - } + healthz.InstallHandler(pathRecorderMux, healthz.NamedCheck("Descheduler", healthz.PingHealthz.Check)) + + if _, err := SecureServing.Serve(pathRecorderMux, 0, ctx.Done()); err != nil { + klog.Fatalf("failed to start secure server: %v", err) + return } err := Run(s) diff --git a/kubernetes/cronjob/cronjob.yaml b/kubernetes/cronjob/cronjob.yaml index c38d52efa..628934a39 100644 --- a/kubernetes/cronjob/cronjob.yaml +++ b/kubernetes/cronjob/cronjob.yaml @@ -31,6 +31,14 @@ spec: requests: cpu: "500m" memory: "256Mi" + livenessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10258 + scheme: HTTPS + initialDelaySeconds: 3 + periodSeconds: 10 securityContext: allowPrivilegeEscalation: false capabilities: diff --git a/kubernetes/deployment/deployment.yaml b/kubernetes/deployment/deployment.yaml index 478cc6907..9b19b3486 100644 --- a/kubernetes/deployment/deployment.yaml +++ b/kubernetes/deployment/deployment.yaml @@ -33,6 +33,14 @@ spec: ports: - containerPort: 10258 protocol: TCP + livenessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10258 + scheme: HTTPS + initialDelaySeconds: 3 + periodSeconds: 3 resources: requests: cpu: 500m diff --git a/kubernetes/job/job.yaml b/kubernetes/job/job.yaml index 9f28d2976..f4ffe5075 100644 --- a/kubernetes/job/job.yaml +++ b/kubernetes/job/job.yaml @@ -29,6 +29,14 @@ spec: requests: cpu: "500m" memory: "256Mi" + livenessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10258 + scheme: HTTPS + initialDelaySeconds: 3 + periodSeconds: 3 securityContext: allowPrivilegeEscalation: false capabilities: diff --git a/pkg/api/v1alpha1/zz_generated.conversion.go b/pkg/api/v1alpha1/zz_generated.conversion.go index 8e4aa990c..c319b8fb9 100644 --- a/pkg/api/v1alpha1/zz_generated.conversion.go +++ b/pkg/api/v1alpha1/zz_generated.conversion.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2021 The Kubernetes Authors. +Copyright 2022 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go index 839a6ef7a..7aedfb34a 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2021 The Kubernetes Authors. +Copyright 2022 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/api/zz_generated.deepcopy.go b/pkg/api/zz_generated.deepcopy.go index 2335974b1..430f5d951 100644 --- a/pkg/api/zz_generated.deepcopy.go +++ b/pkg/api/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2021 The Kubernetes Authors. +Copyright 2022 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go b/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go index 9b9c308d3..b3a54b518 100644 --- a/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2021 The Kubernetes Authors. +Copyright 2022 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go index 762446dd4..740b56bc4 100644 --- a/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2021 The Kubernetes Authors. +Copyright 2022 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/componentconfig/zz_generated.deepcopy.go b/pkg/apis/componentconfig/zz_generated.deepcopy.go index 14f8a73a6..ae340923c 100644 --- a/pkg/apis/componentconfig/zz_generated.deepcopy.go +++ b/pkg/apis/componentconfig/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2021 The Kubernetes Authors. +Copyright 2022 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.