From bdabec5d5587273ea58e1c3035b97abf31719bfe Mon Sep 17 00:00:00 2001 From: liaochuntao Date: Thu, 1 Feb 2024 20:57:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Djavaagent=E9=BB=98?= =?UTF-8?q?=E8=AE=A4properties=E6=96=87=E4=BB=B6=E7=9A=84key=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helm/templates/controller-configmap-javaagent.yaml | 7 ++++--- .../kubernetes_v1.21/kubernetes/javaagent-configmap.yaml | 7 ++++--- .../helm/templates/controller-configmap-javaagent.yaml | 6 +++--- .../kubernetes_v1.22/kubernetes/javaagent-configmap.yaml | 6 +++--- pkg/inject/pkg/kube/inject/apply/javaagent/patch.go | 8 +++++--- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/deploy/kubernetes_v1.21/helm/templates/controller-configmap-javaagent.yaml b/deploy/kubernetes_v1.21/helm/templates/controller-configmap-javaagent.yaml index 0db0e3c9..6bf29631 100644 --- a/deploy/kubernetes_v1.21/helm/templates/controller-configmap-javaagent.yaml +++ b/deploy/kubernetes_v1.21/helm/templates/controller-configmap-javaagent.yaml @@ -6,7 +6,7 @@ metadata: labels: app: sidecar-injector data: - springcloud2020-default-properties: |+ + spring-cloud2020-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -56,7 +56,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloud2021-default-properties: |+ + spring-cloud2021-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -106,7 +106,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloudhoxton-default-properties: |+ + spring-cloudhoxton-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -155,3 +155,4 @@ data: spring.cloud.polaris.stat.port=0 # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics + diff --git a/deploy/kubernetes_v1.21/kubernetes/javaagent-configmap.yaml b/deploy/kubernetes_v1.21/kubernetes/javaagent-configmap.yaml index 0db0e3c9..6bf29631 100644 --- a/deploy/kubernetes_v1.21/kubernetes/javaagent-configmap.yaml +++ b/deploy/kubernetes_v1.21/kubernetes/javaagent-configmap.yaml @@ -6,7 +6,7 @@ metadata: labels: app: sidecar-injector data: - springcloud2020-default-properties: |+ + spring-cloud2020-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -56,7 +56,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloud2021-default-properties: |+ + spring-cloud2021-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -106,7 +106,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloudhoxton-default-properties: |+ + spring-cloudhoxton-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -155,3 +155,4 @@ data: spring.cloud.polaris.stat.port=0 # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics + diff --git a/deploy/kubernetes_v1.22/helm/templates/controller-configmap-javaagent.yaml b/deploy/kubernetes_v1.22/helm/templates/controller-configmap-javaagent.yaml index 28328c56..6bf29631 100644 --- a/deploy/kubernetes_v1.22/helm/templates/controller-configmap-javaagent.yaml +++ b/deploy/kubernetes_v1.22/helm/templates/controller-configmap-javaagent.yaml @@ -6,7 +6,7 @@ metadata: labels: app: sidecar-injector data: - springcloud2020-default-properties: |+ + spring-cloud2020-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -56,7 +56,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloud2021-default-properties: |+ + spring-cloud2021-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -106,7 +106,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloudhoxton-default-properties: |+ + spring-cloudhoxton-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 diff --git a/deploy/kubernetes_v1.22/kubernetes/javaagent-configmap.yaml b/deploy/kubernetes_v1.22/kubernetes/javaagent-configmap.yaml index 0e91c4b5..34072536 100644 --- a/deploy/kubernetes_v1.22/kubernetes/javaagent-configmap.yaml +++ b/deploy/kubernetes_v1.22/kubernetes/javaagent-configmap.yaml @@ -6,7 +6,7 @@ metadata: labels: app: sidecar-injector data: - springcloud2020-default-properties: |+ + spring-cloud2020-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -56,7 +56,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloud2021-default-properties: |+ + spring-cloud2021-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 @@ -106,7 +106,7 @@ data: # 指标上报暴露的 http path spring.cloud.polaris.stat.path=/metrics - springcloudhoxton-default-properties: |+ + spring-cloudhoxton-default-properties: |+ # 应用名称 spring.application.name={{ .MicroserviceName }} # 配置北极星服务端地址 diff --git a/pkg/inject/pkg/kube/inject/apply/javaagent/patch.go b/pkg/inject/pkg/kube/inject/apply/javaagent/patch.go index f0c1c7e7..b7c5c9f8 100644 --- a/pkg/inject/pkg/kube/inject/apply/javaagent/patch.go +++ b/pkg/inject/pkg/kube/inject/apply/javaagent/patch.go @@ -84,11 +84,13 @@ func (pb *PodPatchBuilder) PatchContainer(req *inject.OperateContainerRequest) ( func (pb *PodPatchBuilder) handleJavaAgentInit(opt *inject.PatchOptions, pod *corev1.Pod, add *corev1.Container) error { annonations := pod.Annotations - log.InjectScope().Infof("handle polaris-javaagent-init inject for pod=[%s, %s] annonations: %#v", - pod.Namespace, pod.Name, pod.Annotations) + log.InjectScope().Infof("handle polaris-javaagent-init inject for pod=[%s, %s] annonations: %#v image: %s", + pod.Namespace, pod.Name, pod.Annotations, add.Image) // 判断用户是否自定义了 javaagent 的版本 oldImageInfo := strings.Split(add.Image, ":") - opt.ExternalInfo[customJavaAgentVersion] = oldImageInfo[1] + if len(oldImageInfo) > 1 { + opt.ExternalInfo[customJavaAgentVersion] = oldImageInfo[1] + } if val, ok := annonations[customJavaAgentVersion]; ok { add.Image = fmt.Sprintf("%s:%s", oldImageInfo[0], val) opt.ExternalInfo[customJavaAgentVersion] = val