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:
{{ toYaml .Values.resources.inits | indent 10 }}
{{- end }}
volumeMounts:
- name: grafana-static-hooks
- name: grafana-nginx
mountPath: /run.sh
subPath: copy-datasource-plugin-json.sh
- name: grafana-static-contents
......@@ -37,14 +37,14 @@ spec:
- name: grafana-init-plugin-json-modify
image: {{ template "system_default_registry" . }}{{ .Values.image.tool.repository }}:{{ .Values.image.tool.tag }}
command:
- /usr/bin/modify-datasource-plugin-json.sh
- /run.sh
{{- if and .Values.resources .Values.resources.inits }}
resources:
{{ toYaml .Values.resources.inits | indent 10 }}
{{- end }}
volumeMounts:
- name: grafana-static-hooks
mountPath: /usr/bin/modify-datasource-plugin-json.sh
- name: grafana-nginx
mountPath: /run.sh
subPath: modify-datasource-plugin-json.sh
- name: grafana-static-contents
mountPath: /host
......@@ -128,10 +128,6 @@ spec:
securityContext:
fsGroup: 472
volumes:
- name: grafana-static-hooks
configMap:
name: {{ template "app.hooks.fullname" . }}
defaultMode: 0777
- name: grafana-static-contents
emptyDir: {}
- name: grafana-storage
......@@ -143,12 +139,17 @@ spec:
{{- end }}
- name: grafana-nginx
configMap:
defaultMode: 438
name: {{ template "app.nginx.fullname" . }}
items:
- key: nginx.conf
mode: 438
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
configMap:
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:
release: {{ .Release.Name }}
component: nginx
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: |-
user nginx;
worker_processes auto;
error_log /dev/null warn;
error_log /dev/stdout warn;
pid /var/run/nginx.pid;
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