Commit 7085404a by Frank Mai Committed by orangedeng

Merge hooks-configmap.yaml into nginx-configmap.yaml of Grafana

parent c2bc5b9f
...@@ -29,7 +29,7 @@ spec: ...@@ -29,7 +29,7 @@ spec:
{{ toYaml .Values.resources.inits | indent 10 }} {{ toYaml .Values.resources.inits | indent 10 }}
{{- end }} {{- end }}
volumeMounts: volumeMounts:
- name: grafana-static-hooks - name: grafana-nginx
mountPath: /run.sh mountPath: /run.sh
subPath: copy-datasource-plugin-json.sh subPath: copy-datasource-plugin-json.sh
- name: grafana-static-contents - name: grafana-static-contents
...@@ -37,14 +37,14 @@ spec: ...@@ -37,14 +37,14 @@ spec:
- name: grafana-init-plugin-json-modify - name: grafana-init-plugin-json-modify
image: {{ template "system_default_registry" . }}{{ .Values.image.tool.repository }}:{{ .Values.image.tool.tag }} image: {{ template "system_default_registry" . }}{{ .Values.image.tool.repository }}:{{ .Values.image.tool.tag }}
command: command:
- /usr/bin/modify-datasource-plugin-json.sh - /run.sh
{{- if and .Values.resources .Values.resources.inits }} {{- if and .Values.resources .Values.resources.inits }}
resources: resources:
{{ toYaml .Values.resources.inits | indent 10 }} {{ toYaml .Values.resources.inits | indent 10 }}
{{- end }} {{- end }}
volumeMounts: volumeMounts:
- name: grafana-static-hooks - name: grafana-nginx
mountPath: /usr/bin/modify-datasource-plugin-json.sh mountPath: /run.sh
subPath: modify-datasource-plugin-json.sh subPath: modify-datasource-plugin-json.sh
- name: grafana-static-contents - name: grafana-static-contents
mountPath: /host mountPath: /host
...@@ -128,10 +128,6 @@ spec: ...@@ -128,10 +128,6 @@ spec:
securityContext: securityContext:
fsGroup: 472 fsGroup: 472
volumes: volumes:
- name: grafana-static-hooks
configMap:
name: {{ template "app.hooks.fullname" . }}
defaultMode: 0777
- name: grafana-static-contents - name: grafana-static-contents
emptyDir: {} emptyDir: {}
- name: grafana-storage - name: grafana-storage
...@@ -143,12 +139,17 @@ spec: ...@@ -143,12 +139,17 @@ spec:
{{- end }} {{- end }}
- name: grafana-nginx - name: grafana-nginx
configMap: configMap:
defaultMode: 438 name: {{ template "app.nginx.fullname" . }}
items: items:
- key: nginx.conf - key: nginx.conf
mode: 438 mode: 438
path: nginx.conf path: nginx.conf
name: {{ template "app.nginx.fullname" . }} - key: copy-datasource-plugin-json.sh
mode: 0777
path: copy-datasource-plugin-json.sh
- key: modify-datasource-plugin-json.sh
mode: 0777
path: modify-datasource-plugin-json.sh
- name: grafana-dashboards - name: grafana-dashboards
configMap: configMap:
name: {{ template "app.dashboards.fullname" . }} name: {{ template "app.dashboards.fullname" . }}
......
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: {{ template "app.name" . }}
chart: {{ template "app.version" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "app.hooks.fullname" . }}
data:
copy-datasource-plugin-json.sh: |-
#!/bin/bash
srcpath="/usr/share/grafana/public/app/plugins/datasource/prometheus/plugin.json"
dstpath="/host/grafana/raw-plugin.json"
if [[ -f $srcpath ]] && [[ -d /host ]]; then
mkdir -p /host/grafana
cp -f $srcpath $dstpath
exit 0
fi
exit 1
modify-datasource-plugin-json.sh: |-
#!/bin/sh
srcpath="/host/grafana/raw-plugin.json"
dstpath="/host/grafana/plugin.json"
if [ -f $srcpath ] && [ -d /host ]; then
mkdir -p /host/grafana
token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
cat $srcpath | K8S_BEARERTOKEN="Bearer $token" jq 'to_entries | . + [{"key":"routes","value":[{"path":"api/v1","url":"{{ .Values.prometheusDatasourceURL }}/api/v1","headers":[{"name":"Authorization","content":env.K8S_BEARERTOKEN}]}]}] | from_entries' > $dstpath
exit 0
fi
exit 1
...@@ -9,10 +9,43 @@ metadata: ...@@ -9,10 +9,43 @@ metadata:
release: {{ .Release.Name }} release: {{ .Release.Name }}
component: nginx component: nginx
data: data:
copy-datasource-plugin-json.sh: |-
#!/bin/bash
srcpath="/usr/share/grafana/public/app/plugins/datasource/prometheus/plugin.json"
dstpath="/host/grafana/raw-plugin.json"
if [[ -f $srcpath ]] && [[ -d /host ]]; then
mkdir -p /host/grafana
cp -f $srcpath $dstpath
exit 0
fi
exit 1
modify-datasource-plugin-json.sh: |-
#!/bin/sh
srcpath="/host/grafana/raw-plugin.json"
dstpath="/host/grafana/plugin.json"
if [ -f $srcpath ] && [ -d /host ]; then
mkdir -p /host/grafana
token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
cat $srcpath | K8S_BEARERTOKEN="Bearer $token" jq 'to_entries | . + [{"key":"routes","value":[{"path":"api/v1","url":"{{ .Values.prometheusDatasourceURL }}/api/v1","headers":[{"name":"Authorization","content":env.K8S_BEARERTOKEN}]}]}] | from_entries' > $dstpath
exit 0
fi
exit 1
nginx.conf: |- nginx.conf: |-
user nginx; user nginx;
worker_processes auto; worker_processes auto;
error_log /dev/null warn; error_log /dev/stdout warn;
pid /var/run/nginx.pid; pid /var/run/nginx.pid;
events { events {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment