From 8ffdc9bafdf1adb706be965bc11bae09c04ef0cf Mon Sep 17 00:00:00 2001 From: Enrico Candino Date: Mon, 13 Oct 2025 17:25:17 +0200 Subject: [PATCH] renaming webhook (#506) --- k3k-kubelet/controller/webhook/pod.go | 10 +++++----- k3k-kubelet/kubelet.go | 6 +++--- k3k-kubelet/provider/provider.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/k3k-kubelet/controller/webhook/pod.go b/k3k-kubelet/controller/webhook/pod.go index 8b6ca3c4..49432aa1 100644 --- a/k3k-kubelet/controller/webhook/pod.go +++ b/k3k-kubelet/controller/webhook/pod.go @@ -24,7 +24,7 @@ import ( ) const ( - webhookName = "podmutator.k3k.io" + webhookName = "podmutating.k3k.io" webhookTimeout = int32(10) webhookPath = "/mutate--v1-pod" FieldpathField = "k3k.io/fieldpath" @@ -40,10 +40,10 @@ type webhookHandler struct { webhookPort int } -// AddPodMutatorWebhook will add a mutator webhook to the virtual cluster to +// AddPodMutatingWebhook will add a mutating webhook to the virtual cluster to // modify the nodeName of the created pods with the name of the virtual kubelet node name // as well as remove any status fields of the downward apis env fields -func AddPodMutatorWebhook(ctx context.Context, mgr manager.Manager, hostClient ctrlruntimeclient.Client, clusterName, clusterNamespace, serviceName string, logger logr.Logger, webhookPort int) error { +func AddPodMutatingWebhook(ctx context.Context, mgr manager.Manager, hostClient ctrlruntimeclient.Client, clusterName, clusterNamespace, serviceName string, logger logr.Logger, webhookPort int) error { handler := webhookHandler{ client: mgr.GetClient(), scheme: mgr.GetScheme(), @@ -54,7 +54,7 @@ func AddPodMutatorWebhook(ctx context.Context, mgr manager.Manager, hostClient c webhookPort: webhookPort, } - // create mutator webhook configuration to the cluster + // create mutating webhook configuration to the cluster config, err := handler.configuration(ctx, hostClient) if err != nil { return err @@ -75,7 +75,7 @@ func (w *webhookHandler) Default(ctx context.Context, obj runtime.Object) error return fmt.Errorf("invalid request: object was type %t not cluster", obj) } - w.logger.Info("mutator webhook request", "pod", pod.Name, "namespace", pod.Namespace) + w.logger.Info("mutating webhook request", "pod", pod.Name, "namespace", pod.Namespace) // look for status.* fields in the env if pod.Annotations == nil { pod.Annotations = make(map[string]string) diff --git a/k3k-kubelet/kubelet.go b/k3k-kubelet/kubelet.go index 093d86fd..c77e6b77 100644 --- a/k3k-kubelet/kubelet.go +++ b/k3k-kubelet/kubelet.go @@ -147,10 +147,10 @@ func newKubelet(ctx context.Context, c *config, logger logr.Logger) (*kubelet, e return nil, errors.New("unable to create controller-runtime mgr for virtual cluster: " + err.Error()) } - logger.Info("adding pod mutator webhook") + logger.Info("adding pod mutating webhook") - if err := k3kwebhook.AddPodMutatorWebhook(ctx, virtualMgr, hostClient, c.ClusterName, c.ClusterNamespace, c.ServiceName, logger, c.WebhookPort); err != nil { - return nil, errors.New("unable to add pod mutator webhook for virtual cluster: " + err.Error()) + if err := k3kwebhook.AddPodMutatingWebhook(ctx, virtualMgr, hostClient, c.ClusterName, c.ClusterNamespace, c.ServiceName, logger, c.WebhookPort); err != nil { + return nil, errors.New("unable to add pod mutating webhook for virtual cluster: " + err.Error()) } if err := addControllers(ctx, hostMgr, virtualMgr, c, hostClient); err != nil { diff --git a/k3k-kubelet/provider/provider.go b/k3k-kubelet/provider/provider.go index 3fa44d59..63309b7f 100644 --- a/k3k-kubelet/provider/provider.go +++ b/k3k-kubelet/provider/provider.go @@ -766,7 +766,7 @@ func mergeEnvVars(orig, updated []corev1.EnvVar) []corev1.EnvVar { return orig } -// configureFieldPathEnv will retrieve all annotations created by the pod mutator webhook +// configureFieldPathEnv will retrieve all annotations created by the pod mutating webhook // to assign env fieldpaths to pods, it will also make sure to change the metadata.name and metadata.namespace to the // assigned annotations func (p *Provider) configureFieldPathEnv(pod, tPod *corev1.Pod) error {