Skip to content

Commit

Permalink
Merge pull request #4989 from sbueringer/pr-add-webhook-healthcheck
Browse files Browse the repository at this point in the history
✨ add webhook readiness and health check
  • Loading branch information
k8s-ci-robot authored Jul 26, 2021
2 parents c1f399c + bc720b4 commit ff3c2bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/healthz"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -185,12 +184,12 @@ func main() {
}

func setupChecks(mgr ctrl.Manager) {
if err := mgr.AddReadyzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create ready check")
os.Exit(1)
}

if err := mgr.AddHealthzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddHealthzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create health check")
os.Exit(1)
}
Expand Down
5 changes: 2 additions & 3 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/healthz"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -179,12 +178,12 @@ func main() {
}

func setupChecks(mgr ctrl.Manager) {
if err := mgr.AddReadyzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create ready check")
os.Exit(1)
}

if err := mgr.AddHealthzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddHealthzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create health check")
os.Exit(1)
}
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/healthz"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -218,12 +217,12 @@ func main() {
}

func setupChecks(mgr ctrl.Manager) {
if err := mgr.AddReadyzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create ready check")
os.Exit(1)
}

if err := mgr.AddHealthzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddHealthzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create health check")
os.Exit(1)
}
Expand Down
5 changes: 2 additions & 3 deletions test/infrastructure/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"sigs.k8s.io/cluster-api/feature"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/healthz"

infrav1old "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1alpha3"
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1alpha4"
Expand Down Expand Up @@ -137,12 +136,12 @@ func main() {
}

func setupChecks(mgr ctrl.Manager) {
if err := mgr.AddReadyzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create ready check")
os.Exit(1)
}

if err := mgr.AddHealthzCheck("ping", healthz.Ping); err != nil {
if err := mgr.AddHealthzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
setupLog.Error(err, "unable to create health check")
os.Exit(1)
}
Expand Down

0 comments on commit ff3c2bd

Please sign in to comment.