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 ef4862da [charts] Fix jobs pull kube-prometheus error (#531)
ef4862da is described below
commit ef4862da3fa659b894ae6001f960c7d75d3d650e
Author: Jian Zhong <[email protected]>
AuthorDate: Mon Jan 13 00:02:31 2025 +0800
[charts] Fix jobs pull kube-prometheus error (#531)
---
.../admin/templates/dashboard/configmap.yaml | 40 ++++++++
.../charts/admin/templates/dashboard/job.yaml | 45 +++++++++
manifests/charts/admin/templates/extra-push.yaml | 107 ---------------------
3 files changed, 85 insertions(+), 107 deletions(-)
diff --git a/manifests/charts/admin/templates/dashboard/configmap.yaml
b/manifests/charts/admin/templates/dashboard/configmap.yaml
index 045cc31b..3ee8f587 100644
--- a/manifests/charts/admin/templates/dashboard/configmap.yaml
+++ b/manifests/charts/admin/templates/dashboard/configmap.yaml
@@ -1,4 +1,6 @@
{{- $admin := .Values -}}
+{{- $jobs := .Values.jobs -}}
+{{- $prom := .Values.kubePrometheus }}
apiVersion: v1
kind: ConfigMap
metadata:
@@ -14,3 +16,41 @@ data:
{{- if $admin.cp }}
{{ toYaml $admin.cp | nindent 4 | trim }}
{{- end -}}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "job.name" . }}-config
+ namespace: {{ template "admin.namespace" . }}
+ labels:
+ {{- include "jobs.labels" . | nindent 4 }}
+ annotations:
+ {{- include "jobs.env.annotations" . | nindent 4 }}
+data:
+ helm.sh: |-
+ #!/bin/bash
+ set -eux
+ {{- if (eq $prom.enabled true) }}
+ PROMETHEUS="https://prometheus-community.github.io/helm-charts"
+
+ helm pull {{ include "prom.stack.name" . }} --repo "$PROMETHEUS"
--version {{ $prom.image.tag }} --untar && \
+
+ for i in {1..5}; do
+ 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..."
+ sleep 2
+ fi
+ done
+ cp -r "/files/dashboards/dubbo-resources-metrics.yaml" "{{ 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 "{{ include "prom.name" . }}"; then
+ helm uninstall {{ include "prom.name" . }} -n dubbo-system && helm
install {{ include "prom.name" . }} "./{{ include "prom.stack.name" . }}/" -n
dubbo-system
+ else
+ helm install {{ include "prom.name" . }} "./{{ include "prom.stack.name"
. }}/" -n dubbo-system
+ fi
+ {{- end }}
+ dubbo-resources-metrics.yaml: |-
+ {{- .Files.Get "files/dashboards/dubbo-resources-metrics.yaml" | nindent 4
}}
\ No newline at end of file
diff --git a/manifests/charts/admin/templates/dashboard/job.yaml
b/manifests/charts/admin/templates/dashboard/job.yaml
new file mode 100644
index 00000000..467b8348
--- /dev/null
+++ b/manifests/charts/admin/templates/dashboard/job.yaml
@@ -0,0 +1,45 @@
+{{- $jobs := .Values.jobs -}}
+---
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: dubbo-job-create
+ namespace: {{ template "admin.namespace" . }}
+ labels:
+ {{- include "jobs.labels" . | nindent 4 }}
+ annotations:
+ {{- include "jobs.2.annotations" . | nindent 4 }}
+spec:
+ template:
+ metadata:
+ name: dubbo-job-create
+ spec:
+ restartPolicy: {{ $jobs.restartPolicy }}
+ dnsPolicy: None
+ dnsConfig:
+ nameservers:
+ - 8.8.8.8
+ searches:
+ - default.svc.cluster.local
+ - svc.cluster.local
+ - cluster.local
+ containers:
+ - name: helm
+ image: alpine/helm:3.16.2
+ imagePullPolicy: IfNotPresent
+ command:
+ - "/bin/sh"
+ - "-c"
+ - "sh /files/helm.sh"
+ volumeMounts:
+ - name: scripts
+ mountPath: /files/helm.sh
+ subPath: helm.sh
+ - name: scripts
+ mountPath: /files/dashboards/dubbo-resources-metrics.yaml
+ subPath: dubbo-resources-metrics.yaml
+ volumes:
+ - name: scripts
+ configMap:
+ name: {{ include "job.name" . }}-config
+ defaultMode: 0755
\ No newline at end of file
diff --git a/manifests/charts/admin/templates/extra-push.yaml
b/manifests/charts/admin/templates/extra-push.yaml
deleted file mode 100644
index 835e6348..00000000
--- a/manifests/charts/admin/templates/extra-push.yaml
+++ /dev/null
@@ -1,107 +0,0 @@
-{{- $jobs := .Values.jobs -}}
-{{- $prom := .Values.kubePrometheus }}
-apiVersion: v1
-kind: ConfigMap
-metadata:
- name: jobs-env
- namespace: {{ template "admin.namespace" . }}
- labels:
- {{- include "jobs.labels" . | nindent 4 }}
- annotations:
- {{- include "jobs.env.annotations" . | nindent 4 }}
-data:
- helm.sh: |-
- #!/bin/bash
- set -eux
- {{- if (eq $prom.enabled true) }}
- PROMETHEUS="https://prometheus-community.github.io/helm-charts"
-
- helm pull {{ include "prom.stack.name" . }} --repo "$PROMETHEUS" --version
{{ $prom.image.tag }} --untar && \
-
- for i in {1..5}; do
- 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..."
- sleep 2
- fi
- done
- cp -r "/files/dashboards/dubbo-resources-metrics.yaml" "{{ 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 "{{ include "prom.name" . }}"; then
- helm uninstall {{ include "prom.name" . }} -n dubbo-system && helm install
{{ include "prom.name" . }} "./{{ include "prom.stack.name" . }}/" -n
dubbo-system
- else
- helm install {{ include "prom.name" . }} "./{{ include "prom.stack.name" .
}}/" -n dubbo-system
- fi
- {{- end }}
- dubbo-resources-metrics.yaml: |-
- {{- .Files.Get "files/dashboards/dubbo-resources-metrics.yaml" | nindent 4
}}
----
-apiVersion: batch/v1
-kind: Job
-metadata:
- name: dubbo-job-create
- namespace: {{ template "admin.namespace" . }}
- labels:
- {{- include "jobs.labels" . | nindent 4 }}
- annotations:
- {{- include "jobs.2.annotations" . | nindent 4 }}
-spec:
- template:
- metadata:
- name: dubbo-job-create
- spec:
- serviceAccountName: job-sa
- restartPolicy: {{ $jobs.restartPolicy }}
- dnsPolicy: None
- dnsConfig:
- nameservers:
- - 8.8.8.8
- searches:
- - default.svc.cluster.local
- - svc.cluster.local
- - cluster.local
- containers:
- - name: helm
- image: alpine/helm:3.16.2
- imagePullPolicy: IfNotPresent
- command:
- - "/bin/sh"
- - "-c"
- - "sh /files/helm.sh"
- volumeMounts:
- - name: scripts
- mountPath: /files/helm.sh
- subPath: helm.sh
- - name: scripts
- mountPath: /files/dashboards/dubbo-resources-metrics.yaml
- subPath: dubbo-resources-metrics.yaml
- volumes:
- - name: scripts
- configMap:
- name: jobs-env
- defaultMode: 0755
----
-apiVersion: v1
-kind: ServiceAccount
-metadata:
- name: job-sa
- namespace: {{ template "admin.namespace" . }}
- annotations:
- {{- include "jobs.sa.annotations" . | nindent 4 }}
----
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- name: job-sa-binding
- annotations:
- {{- include "jobs.sa.annotations" . | nindent 4 }}
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: cluster-admin
-subjects:
-- kind: ServiceAccount
- name: job-sa
- namespace: {{ template "admin.namespace" . }}
\ No newline at end of file