This is an automated email from the ASF dual-hosted git repository.

zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git


The following commit(s) were added to refs/heads/master by this push:
     new 401587d3 [charts] Splicing templates to optimize jobs
401587d3 is described below

commit 401587d36de47c3ae3c8f97f464750cf07fffdf2
Author: mfordjody <[email protected]>
AuthorDate: Fri Oct 18 08:45:31 2024 +0800

    [charts] Splicing templates to optimize jobs
---
 .../admin/templates/admin/admin-deployment.yaml    |  7 ++++---
 .../admin/templates/admin/admin-statefulset.yaml   |  7 ++++---
 manifests/charts/admin/templates/jobs.yaml         | 16 +++++++--------
 .../charts/admin/templates/modular/_names.tpl      | 23 +++++++++++++++++++---
 4 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/manifests/charts/admin/templates/admin/admin-deployment.yaml 
b/manifests/charts/admin/templates/admin/admin-deployment.yaml
index 29c61c24..ca059770 100644
--- a/manifests/charts/admin/templates/admin/admin-deployment.yaml
+++ b/manifests/charts/admin/templates/admin/admin-deployment.yaml
@@ -95,13 +95,14 @@ spec:
           value: /var/run/secrets/dubbo.io/tls-cert
         {{- $promName := include "prom.name" . }}
         {{- $promPort := include "prom.port" . }}
+        {{- $promStationaryName := printf "-kube-prome-prometheus" }}
         {{- if $prom.enabled }}
         - name: ADMIN_PROMETHEUS_ADDRESS
-          value: {{ $promName }}:{{ $promPort }}
-        {{- $grafanaName := include "grafana.name" . }}
+          value: {{ $promName$promStationaryName }}:{{ $promPort }}
         {{- $grafanaPort := include "grafana.port" . }}
+        {{- $grafanaStationaryName := printf "-grafana" }}
         - name: ADMIN_GRAFANA_ADDRESS
-          value: {{ $grafanaName }}:{{ $grafanaPort }}
+          value: {{ $promName$grafanaStationaryName }}:{{ $grafanaPort }}
         {{- end }}
         volumeMounts:
         {{- if $admin.volumeMounts }}
diff --git a/manifests/charts/admin/templates/admin/admin-statefulset.yaml 
b/manifests/charts/admin/templates/admin/admin-statefulset.yaml
index a766afe0..b958909b 100644
--- a/manifests/charts/admin/templates/admin/admin-statefulset.yaml
+++ b/manifests/charts/admin/templates/admin/admin-statefulset.yaml
@@ -90,13 +90,14 @@ spec:
         {{- end }}
         {{- $promName := include "prom.name" . }}
         {{- $promPort := include "prom.port" . }}
+        {{- $promStationaryName := printf "-kube-prome-prometheus" }}
         {{- if $prom.enabled }}
         - name: ADMIN_PROMETHEUS_ADDRESS
-          value: {{ $promName }}:{{ $promPort }}
-        {{- $grafanaName := include "grafana.name" . }}
+          value: {{ $promName$promStationaryName }}:{{ $promPort }}
         {{- $grafanaPort := include "grafana.port" . }}
+        {{- $grafanaStationaryName := printf "-grafana" }}
         - name: ADMIN_GRAFANA_ADDRESS
-          value: {{ $grafanaName }}:{{ $grafanaPort }}
+          value: {{ $promName$grafanaStationaryName }}:{{ $grafanaPort }}
         {{- end }}
         volumeMounts:
         {{- if $admin.volumeMounts }}
diff --git a/manifests/charts/admin/templates/jobs.yaml 
b/manifests/charts/admin/templates/jobs.yaml
index ea7f8e8f..e3caeb6b 100644
--- a/manifests/charts/admin/templates/jobs.yaml
+++ b/manifests/charts/admin/templates/jobs.yaml
@@ -20,20 +20,20 @@ data:
 
     
JAEGER="https://raw.githubusercontent.com/istio/istio/release-1.23/samples/addons/jaeger.yaml";
 
-    kubectl apply -f $JAEGER
-
     kubectl get namespace istio-system >/dev/null 2>&1 || kubectl create 
namespace istio-system
 
+    kubectl apply -f $JAEGER
+
   helm.sh: |-
    #!/bin/bash
     set -eux
     ISTIO="https://istio-release.storage.googleapis.com/charts";
     PROMETHEUS="https://prometheus-community.github.io/helm-charts";
 
-    helm pull "{{ include "prom.name" . }}" --repo "$PROMETHEUS" --version "{{ 
$prom.image.tag }}" --untar
+    helm pull "{{ include "prom.stack.name" . }}" --repo "$PROMETHEUS" 
--version "{{ $prom.image.tag }}" --untar
 
     for i in {1..5}; do
-    if rm -rf "{{ include "prom.name" . }}-{{ $prom.image.tag }}.tgz"; then
+    if rm -rf "{{ include "prom.stack.name" . }}-{{ $prom.image.tag }}.tgz"; 
then
     break
     else
     echo "Attempt $i: Failed to remove directory, retrying in 2 seconds..."
@@ -41,13 +41,13 @@ data:
     fi
     done
 
-    cp -r "/files/dashboards/" "{{ include "prom.name" . }}/templates/{{ 
include "grafana.name" . }}/dashboards-{{ $prom.dashboardsVersion }}"
-    ls -la "{{ include "prom.name" . }}/templates/{{ include "grafana.name" . 
}}/dashboards-{{ $prom.dashboardsVersion }}"
+    cp -r "/files/dashboards/" "{{ include "prom.stack.name" . }}/templates/{{ 
include "grafana.name" . }}/dashboards-{{ $prom.dashboardsVersion }}"
+    ls -la "{{ include "prom.stack.name" . }}/templates/{{ include 
"grafana.name" . }}/dashboards-{{ $prom.dashboardsVersion }}"
 
     if helm ls --all | grep -q "{{ include "prom.name" . }}"; then
-    helm upgrade kube-prometheus "./{{ include "prom.name" . }}/"
+    helm upgrade {{ include "prom.name" . }} "./{{ include "prom.stack.name" . 
}}/"
     else
-    helm install kube-prometheus "./{{ include "prom.name" . }}/"
+    helm install {{ include "prom.name" . }} "./{{ include "prom.stack.name" . 
}}/"
     fi
     helm repo add istio "$ISTIO" && \
     helm repo update && \
diff --git a/manifests/charts/admin/templates/modular/_names.tpl 
b/manifests/charts/admin/templates/modular/_names.tpl
index 2ddabfc1..e1bcf39f 100644
--- a/manifests/charts/admin/templates/modular/_names.tpl
+++ b/manifests/charts/admin/templates/modular/_names.tpl
@@ -34,19 +34,36 @@ Return Traefik Name to use.
 {{- end -}}
 
 {{/*
-Return Kube-Prometheus Name to use.
+Return Kube-Prometheus-Stack Name to use.
 */}}
-{{- define "prom.name" -}}
+{{- define "prom.stack.name" -}}
 {{- printf "kube-prometheus-stack" -}}
 {{- end -}}
 
+{{/*
+Return Kube-Prometheus-Stack Name to use.
+*/}}
+{{- define "prom.name" -}}
+{{- printf "kube-prometheus" -}}
+{{- end -}}
+
+
+{{/*
+Return kube-prometheus-grafana to use.
+*/}}
+{{- define "grafana.stack.name" -}}
+{{- printf "kube-prometheus-grafana" -}}
+{{- end -}}
+
 {{/*
 Return Grafana Name to use.
 */}}
 {{- define "grafana.name" -}}
-{{- printf "kube-prometheus-grafana" -}}
+{{- printf "grafana" -}}
 {{- end -}}
 
+
+
 {{/*
 Return Job Name to use.
 */}}

Reply via email to