From 61700950500065ec67cad0c763b5318f6e828584 Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Thu, 1 Feb 2024 12:41:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Djava-agent=E6=B3=A8?= =?UTF-8?q?=E5=85=A5=E6=97=B6plugin.enable=E6=A0=BC=E5=BC=8F=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/inject/pkg/kube/inject/inject.go | 1 + pkg/inject/pkg/kube/inject/webhook.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pkg/inject/pkg/kube/inject/inject.go b/pkg/inject/pkg/kube/inject/inject.go index b8c5bd26..5c4e0077 100644 --- a/pkg/inject/pkg/kube/inject/inject.go +++ b/pkg/inject/pkg/kube/inject/inject.go @@ -271,6 +271,7 @@ func validateBool(value string) error { func (wh *Webhook) getSidecarMode(namespace string, pod *corev1.Pod) utils.SidecarMode { // 这里主要是处理北极星 sidecar, 优先级: pod.annotations > namespace.labels > configmap if val, ok := pod.Annotations["polarismesh.cn/javaagent"]; ok && val == "true" { + log.InjectScope().Infof("inject pod namespace %q mode is java agent", namespace) return utils.SidecarForJavaAgent } sidecarMode := "" diff --git a/pkg/inject/pkg/kube/inject/webhook.go b/pkg/inject/pkg/kube/inject/webhook.go index c658c944..a99be301 100644 --- a/pkg/inject/pkg/kube/inject/webhook.go +++ b/pkg/inject/pkg/kube/inject/webhook.go @@ -924,6 +924,10 @@ func (wh *Webhook) injectV1(ar *v1.AdmissionReview) *v1.AdmissionResponse { config = wh.sidecarDnsConfig tempVersion = wh.sidecarDnsTemplateVersion } + if sidecarMode == utils.SidecarForJavaAgent { + config = wh.sidecarJavaAgentConfig + tempVersion = wh.sidecarJavaAgentTemplateVersion + } if !wh.injectRequired(ignoredNamespaces, config, &pod.Spec, &pod.ObjectMeta) { log.InjectScope().Infof("[Webhook] skipping %s/%s due to policy check", pod.ObjectMeta.Namespace, podName)