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

Add readyz to admission #186

Merged
merged 3 commits into from
Jan 31, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ spec:
{{- toYaml .Values.global.securityContext | nindent 12 }}
imagePullPolicy: IfNotPresent
image: "{{ .Values.global.admission.image }}"
readinessProbe:
httpGet:
port: 8090
path: /readyz/
resources:
{{- toYaml .Values.global.admission.resources | nindent 12 }}
args:
Expand All @@ -45,6 +49,9 @@ spec:
containerPort: 9090
- name: http-profiling
containerPort: 8008
- name: health
containerPort: 8090
protocol: TCP
volumeMounts:
- name: config
mountPath: {{ .Values.global.config.dir }}
Expand All @@ -57,7 +64,7 @@ spec:
configMap:
name: {{ .Values.global.config.configmapName }}
- name: tmp-cert
emptyDir: {}
emptyDir: { }
- name: notary-tmp
emptyDir: {}
emptyDir: { }
priorityClassName: {{ .Values.global.wardenPriorityClassName }}
19 changes: 12 additions & 7 deletions cmd/admission/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"flag"
"fmt"
"os"

"github.com/kyma-project/warden/internal/env"
"github.com/kyma-project/warden/internal/logging"
"github.com/kyma-project/warden/internal/webhook"
"go.uber.org/zap/zapcore"
"os"
"sigs.k8s.io/controller-runtime/pkg/healthz"

"github.com/go-logr/zapr"
"github.com/kyma-project/warden/internal/admission"
Expand Down Expand Up @@ -105,10 +105,11 @@ func main() {
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), manager.Options{
Scheme: scheme,
Port: appConfig.Admission.Port,
MetricsBindAddress: ":9090",
Logger: logrZap,
Scheme: scheme,
Port: appConfig.Admission.Port,
MetricsBindAddress: ":9090",
Logger: logrZap,
HealthProbeBindAddress: ":8090",
ClientDisableCacheFor: []ctrlclient.Object{
&corev1.Secret{},
&corev1.ConfigMap{},
Expand All @@ -119,6 +120,11 @@ func main() {
os.Exit(2)
}

if err := mgr.AddReadyzCheck("readiness check", healthz.Ping); err != nil {
logger.Error(err, "unable to register readyz")
os.Exit(1)
}

if err := webhook.SetupResourcesController(context.TODO(), mgr,
appConfig.Admission.ServiceName,
appConfig.Admission.SystemNamespace,
Expand Down Expand Up @@ -146,7 +152,6 @@ func main() {
whs := mgr.GetWebhookServer()
whs.CertName = certs.CertFile
whs.KeyName = certs.KeyFile

whs.Register(admission.ValidationPath, &ctrlwebhook.Admission{
Handler: admission.NewValidationWebhook(logger.With("webhook", "validation")),
})
Expand Down
Loading