From 27a5a4016b7270f4ff4bd71aecb64b4a92ecb846 Mon Sep 17 00:00:00 2001 From: Leopold Jacquot Date: Wed, 26 Jul 2023 16:50:20 +0200 Subject: [PATCH] fix: use webhook namespace if pod namespace is empty Signed-off-by: Leopold Jacquot --- webhooks/pod_webhook.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webhooks/pod_webhook.go b/webhooks/pod_webhook.go index 2031d5d40..4869e34ce 100644 --- a/webhooks/pod_webhook.go +++ b/webhooks/pod_webhook.go @@ -65,6 +65,11 @@ func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admissio }() pod := &corev1.Pod{} err := m.decoder.Decode(req, pod) + + if pod.Namespace == "" { + pod.Namespace = req.Namespace + } + if err != nil { return admission.Errored(http.StatusBadRequest, err) }