-
Notifications
You must be signed in to change notification settings - Fork 216
/
grafana-deployment.yaml
88 lines (88 loc) · 3.27 KB
/
grafana-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: grafana
labels:
app: grafana
component: core
spec:
replicas: 1
template:
metadata:
labels:
app: grafana
component: core
spec:
containers:
- image: grafana/grafana:3.1.1
name: grafana
# env:
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 100m
memory: 100Mi
env:
# This variable is required to setup templates in Grafana.
# The following env variables are required to make Grafana accessible via
# the kubernetes api-server proxy. On production clusters, we recommend
# removing these env variables, setup auth for grafana, and expose the grafana
# service using a LoadBalancer or a public IP.
- name: GF_AUTH_BASIC_ENABLED
value: "false"
- name: GF_AUTH_ANONYMOUS_ENABLED
value: "true"
- name: GF_AUTH_ANONYMOUS_ORG_ROLE
value: Admin
# - name: GF_SERVER_ROOT_URL
# value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
volumeMounts:
- name: grafana-persistent-storage
mountPath: /var
- name: grafana-import-dashboards
image: docker
command: ["/bin/sh", "-c"]
workingDir: /opt/grafana-import-dashboards
args:
# FIXME use kubernetes probe instead of "until curl"
- >
apk --update add curl ;
until $(curl --silent --fail --show-error --output /dev/null http://localhost:3000/api/datasources); do
printf '.' ; sleep 1 ;
done ;
for file in *-datasource.json ; do
if [ -e "$file" ] ; then
echo "importing $file" &&
curl --silent --fail --show-error \
--request POST http://localhost:3000/api/datasources \
--header "Content-Type: application/json" \
--data-binary "@$file" ;
echo "" ;
fi
done ;
for file in *-dashboard.json ; do
if [ -e "$file" ] ; then
# wrap exported Grafana dashboard into valid json
echo "importing $file" &&
(echo '{"dashboard":';cat "$file";echo ',"inputs":[{"name":"DS_PROMETHEUS","pluginId":"prometheus","type":"datasource","value":"prometheus"}]}') | curl --silent --fail --show-error \
--request POST http://localhost:3000/api/dashboards/import \
--header "Content-Type: application/json" \
--data-binary @-;
echo "" ;
fi
done ;
while true; do
sleep 1m ;
done
volumeMounts:
- name: config-volume
mountPath: /opt/grafana-import-dashboards
volumes:
- name: config-volume
configMap:
name: grafana-import-dashboards
- name: grafana-persistent-storage
emptyDir: {}