From 109e370fcc3c1fb60c4fbb85a2ac6f84729b1021 Mon Sep 17 00:00:00 2001 From: fumingwei Date: Mon, 26 Jun 2023 20:49:04 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:TSG-15631:=E4=BF=AE=E5=A4=8DTSG-X?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=8F=91=E9=80=81telegraf=20device=5Fid?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/helm/templates/_config.tpl | 6 ++++++ .../files/helm/templates/deployment-firewall.yaml | 14 ++++++++++++-- .../files/helm/templates/deployment-proxy.yaml | 7 ++++++- .../templates/deployment-service-chaining.yaml | 7 ++++++- .../files/helm/templates/deployment-shaping.yaml | 7 ++++++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/ansible/roles/traffic-engine/files/helm/templates/_config.tpl b/ansible/roles/traffic-engine/files/helm/templates/_config.tpl index 465f6dc7..4a1072f3 100644 --- a/ansible/roles/traffic-engine/files/helm/templates/_config.tpl +++ b/ansible/roles/traffic-engine/files/helm/templates/_config.tpl @@ -571,3 +571,9 @@ enable_breakpad_upload=0 - name: dev-shm mountPath: /dev/shm {{- end -}} + +{{- define "traffic-engine.telegraf.read.device-id" -}} + export device_id=`ipmitool fru list |grep 'Product Serial' | awk '{ print $4}'` + if [ -z "$device_id" ]; then export device_id="unknown"; fi + echo "export device_id=${device_id}" > /etc/profile.d/device_id.sh +{{- end -}} \ No newline at end of file diff --git a/ansible/roles/traffic-engine/files/helm/templates/deployment-firewall.yaml b/ansible/roles/traffic-engine/files/helm/templates/deployment-firewall.yaml index 22983160..bab9ef87 100644 --- a/ansible/roles/traffic-engine/files/helm/templates/deployment-firewall.yaml +++ b/ansible/roles/traffic-engine/files/helm/templates/deployment-firewall.yaml @@ -99,7 +99,12 @@ spec: - name: telegraf image: "registry.gdnt-cloud.website/tsg-telegraf:{{ .Chart.AppVersion }}" imagePullPolicy: Never - command: ["/usr/bin/telegraf", "-config", "/etc/telegraf/telegraf_statistic.conf", "-config-directory", "/etc/telegraf/telegraf_statistic.d"] + command: + - "bash" + - "-ec" + - | + {{ template "traffic-engine.telegraf.read.device-id" . }} + /usr/bin/telegraf -config /etc/telegraf/telegraf_statistic.conf -config-directory /etc/telegraf/telegraf_statistic.d securityContext: privileged: true volumeMounts: @@ -117,7 +122,12 @@ spec: - name: telegraf-security image: "registry.gdnt-cloud.website/tsg-telegraf:{{ .Chart.AppVersion }}" imagePullPolicy: Never - command: ["/usr/bin/telegraf", "-config", "/etc/telegraf/telegraf_security.conf", "-config-directory", "/etc/telegraf/telegraf_statistic.d"] + command: + - "bash" + - "-ec" + - | + {{ template "traffic-engine.telegraf.read.device-id" . }} + /usr/bin/telegraf -config /etc/telegraf/telegraf_security.conf -config-directory /etc/telegraf/telegraf_statistic.d securityContext: privileged: true volumeMounts: diff --git a/ansible/roles/traffic-engine/files/helm/templates/deployment-proxy.yaml b/ansible/roles/traffic-engine/files/helm/templates/deployment-proxy.yaml index 74c5b3ac..c299537b 100644 --- a/ansible/roles/traffic-engine/files/helm/templates/deployment-proxy.yaml +++ b/ansible/roles/traffic-engine/files/helm/templates/deployment-proxy.yaml @@ -141,7 +141,12 @@ spec: - name: telegraf-proxy image: "registry.gdnt-cloud.website/tsg-telegraf:{{ .Chart.AppVersion }}" imagePullPolicy: Never - command: ["/usr/bin/telegraf", "-config", "/etc/telegraf/telegraf_proxy.conf", "-config-directory", "/etc/telegraf/telegraf_statistic.d"] + command: + - "bash" + - "-ec" + - | + {{ template "traffic-engine.telegraf.read.device-id" . }} + /usr/bin/telegraf -config /etc/telegraf/telegraf_proxy.conf -config-directory /etc/telegraf/telegraf_statistic.d securityContext: privileged: true volumeMounts: diff --git a/ansible/roles/traffic-engine/files/helm/templates/deployment-service-chaining.yaml b/ansible/roles/traffic-engine/files/helm/templates/deployment-service-chaining.yaml index 0ca5838d..6ca54a65 100644 --- a/ansible/roles/traffic-engine/files/helm/templates/deployment-service-chaining.yaml +++ b/ansible/roles/traffic-engine/files/helm/templates/deployment-service-chaining.yaml @@ -131,7 +131,12 @@ spec: - name: telegraf-sce image: "registry.gdnt-cloud.website/tsg-telegraf:{{ .Chart.AppVersion }}" imagePullPolicy: Never - command: ["/usr/bin/telegraf", "-config", "/etc/telegraf/telegraf_sce.conf", "-config-directory", "/etc/telegraf/telegraf_statistic.d"] + command: + - "bash" + - "-ec" + - | + {{ template "traffic-engine.telegraf.read.device-id" . }} + /usr/bin/telegraf -config /etc/telegraf/telegraf_sce.conf -config-directory /etc/telegraf/telegraf_statistic.d securityContext: privileged: true volumeMounts: diff --git a/ansible/roles/traffic-engine/files/helm/templates/deployment-shaping.yaml b/ansible/roles/traffic-engine/files/helm/templates/deployment-shaping.yaml index bc08ab79..155b7f13 100644 --- a/ansible/roles/traffic-engine/files/helm/templates/deployment-shaping.yaml +++ b/ansible/roles/traffic-engine/files/helm/templates/deployment-shaping.yaml @@ -104,7 +104,12 @@ spec: - name: telegraf-shaping image: "registry.gdnt-cloud.website/tsg-telegraf:{{ .Chart.AppVersion }}" imagePullPolicy: Never - command: ["/usr/bin/telegraf", "-config", "/etc/telegraf/telegraf_shaping.conf", "-config-directory", "/etc/telegraf/telegraf_statistic.d"] + command: + - "bash" + - "-ec" + - | + {{ template "traffic-engine.telegraf.read.device-id" . }} + /usr/bin/telegraf -config /etc/telegraf/telegraf_shaping.conf -config-directory /etc/telegraf/telegraf_statistic.d securityContext: privileged: true volumeMounts: