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)