Skip to content

Commit

Permalink
Merge pull request #2651 from elinx/feat-admission-healthz
Browse files Browse the repository at this point in the history
add healthz for admission
  • Loading branch information
volcano-sh-bot authored Feb 9, 2023
2 parents 8f93176 + cd954e0 commit 3859cd3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/webhook-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
defaultBurst = 100
defaultEnabledAdmission = "/jobs/mutate,/jobs/validate,/podgroups/mutate,/pods/validate,/pods/mutate,/queues/mutate,/queues/validate"
defaultIgnoredNamespaces = "volcano-system,kube-system"
defaultHealthzAddress = ":11251"
)

// Config admission-controller server config.
Expand All @@ -52,6 +53,11 @@ type Config struct {
ConfigPath string
EnabledAdmission string
IgnoredNamespaces string

EnableHealthz bool
// HealthzBindAddress is the IP address and port for the health check server to serve on
// defaulting to :11251
HealthzBindAddress string
}

type DecryptFunc func(c *Config) error
Expand Down Expand Up @@ -83,6 +89,8 @@ func (c *Config) AddFlags(fs *pflag.FlagSet) {
fs.StringArrayVar(&c.SchedulerNames, "scheduler-name", []string{defaultSchedulerName}, "Volcano will handle pods whose .spec.SchedulerName is same as scheduler-name")
fs.StringVar(&c.ConfigPath, "admission-conf", "", "The configmap file of this webhook")
fs.StringVar(&c.IgnoredNamespaces, "ignored-namespaces", defaultIgnoredNamespaces, "Comma-separated list of namespaces to be ignored by admission webhooks")
fs.BoolVar(&c.EnableHealthz, "enable-healthz", false, "Enable the health check; it is false by default")
fs.StringVar(&c.HealthzBindAddress, "healthz-address", defaultHealthzAddress, "The address to listen on for the health check server.")
}

// CheckPortOrDie check valid port range.
Expand Down
7 changes: 7 additions & 0 deletions cmd/webhook-manager/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/klog"

"volcano.sh/apis/pkg/apis/helpers"
"volcano.sh/apis/pkg/apis/scheduling/scheme"
"volcano.sh/volcano/cmd/webhook-manager/app/options"
"volcano.sh/volcano/pkg/kube"
Expand All @@ -45,6 +46,12 @@ func Run(config *options.Config) error {
return nil
}

if config.EnableHealthz {
if err := helpers.StartHealthz(config.HealthzBindAddress, "volcano-admission", config.CertData, config.KeyData); err != nil {
return err
}
}

if config.WebhookURL == "" && config.WebhookNamespace == "" && config.WebhookName == "" {
return fmt.Errorf("failed to start webhooks as both 'url' and 'namespace/name' of webhook are empty")
}
Expand Down
1 change: 1 addition & 0 deletions installer/helm/chart/volcano/templates/admission.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ spec:
- --admission-conf=/admission.local.config/configmap/{{base .Values.basic.admission_config_file}}
- --webhook-namespace={{ .Release.Namespace }}
- --webhook-service-name={{ .Release.Name }}-admission-service
- --enable-healthz=true
- --logtostderr
- --port={{.Values.basic.admission_port}}
- -v=4
Expand Down
1 change: 1 addition & 0 deletions installer/volcano-development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ spec:
- --admission-conf=/admission.local.config/configmap/volcano-admission.conf
- --webhook-namespace=volcano-system
- --webhook-service-name=volcano-admission-service
- --enable-healthz=true
- --logtostderr
- --port=8443
- -v=4
Expand Down

0 comments on commit 3859cd3

Please sign in to comment.