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

feat: allow customizable [Mutating|Validating]WebhookConfiguration names #2751

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions apis/config/v1beta1/configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ type ControllerWebhook struct {
// must be named tls.key and tls.crt, respectively.
// +optional
CertDir string `json:"certDir,omitempty"`

// MutatingWebhookConfigurationName is the name of the K8s MutatingWebhookConfiguration
// +optional
MutatingWebhookConfigurationName *string `json:"mutatingWebhookConfigurationName,omitempty"`

// ValidatingWebhookConfigurationName is the name of the K8s ValidatingWebhookConfiguration
// +optional
ValidatingWebhookConfigurationName *string `json:"validatingWebhookConfigurationName,omitempty"`
}

// ControllerMetrics defines the metrics configs.
Expand Down
8 changes: 8 additions & 0 deletions apis/config/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (
DefaultNamespace = "kueue-system"
DefaultWebhookServiceName = "kueue-webhook-service"
DefaultWebhookSecretName = "kueue-webhook-server-cert"
DefaultMutatingWebhookConfigurationName = "kueue-mutating-webhook-configuration"
DefaultValidatingWebhookConfigurationName = "kueue-validating-webhook-configuration"
DefaultWebhookPort = 9443
DefaultHealthProbeBindAddress = ":8081"
DefaultMetricsBindAddress = ":8080"
Expand Down Expand Up @@ -70,6 +72,12 @@ func SetDefaults_Configuration(cfg *Configuration) {
if cfg.Webhook.Port == nil {
cfg.Webhook.Port = ptr.To(DefaultWebhookPort)
}
if cfg.Webhook.MutatingWebhookConfigurationName == nil {
cfg.Webhook.MutatingWebhookConfigurationName = ptr.To(DefaultMutatingWebhookConfigurationName)
}
if cfg.Webhook.ValidatingWebhookConfigurationName == nil {
cfg.Webhook.ValidatingWebhookConfigurationName = ptr.To(DefaultValidatingWebhookConfigurationName)
}
if len(cfg.Metrics.BindAddress) == 0 {
cfg.Metrics.BindAddress = DefaultMetricsBindAddress
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/util/cert/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (

const (
certDir = "/tmp/k8s-webhook-server/serving-certs"
vwcName = "kueue-validating-webhook-configuration"
mwcName = "kueue-mutating-webhook-configuration"
caName = "kueue-ca"
caOrganization = "kueue"
)
Expand All @@ -56,10 +54,10 @@ func ManageCerts(mgr ctrl.Manager, cfg config.Configuration, setupFinished chan
IsReady: setupFinished,
Webhooks: []cert.WebhookInfo{{
Type: cert.Validating,
Name: vwcName,
Name: *cfg.ControllerManager.Webhook.ValidatingWebhookConfigurationName,
}, {
Type: cert.Mutating,
Name: mwcName,
Name: *cfg.ControllerManager.Webhook.MutatingWebhookConfigurationName,
}},
// When kueue is running in the leader election mode,
// we expect webhook server will run in primary and secondary instance
Expand Down