Skip to content

Commit 4740c9a

Browse files
committed
chore(grafana): change deployment to statefulset
1 parent 798d0bb commit 4740c9a

9 files changed

Lines changed: 79 additions & 66 deletions

File tree

charts/grafana/templates/grafana-configmap.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ data:
3737
app_mode = production
3838
3939
[paths]
40-
data = /var/lib/grafana
40+
data = /opt/drycc/grafana/data
4141
home = /usr/share/grafana
42-
logs = /var/log/grafana
42+
logs = /opt/drycc/grafana/data/logs
4343
plugins = /usr/share/grafana/plugins
4444
provisioning = /usr/share/grafana/provisioning
4545

charts/grafana/templates/grafana-pvc.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: drycc-grafana
5+
annotations:
6+
{{- with .Values.service.annotations }}
7+
{{- toYaml . | nindent 4 }}
8+
{{- end }}
9+
labels:
10+
heritage: drycc
11+
app: drycc-grafana
12+
spec:
13+
type: ClusterIP
14+
publishNotReadyAddresses: true
15+
ports:
16+
- name: grafana-tcp
17+
port: 3000
18+
targetPort: grafana
19+
protocol: TCP
20+
- name: alerting-tcp
21+
port: 9094
22+
targetPort: alerting
23+
protocol: TCP
24+
- name: alerting-udp
25+
port: 9094
26+
targetPort: alerting
27+
protocol: UDP
28+
- name: oauth2-tcp
29+
port: 4000
30+
targetPort: oauth2
31+
protocol: TCP
32+
- name: proxy-tcp
33+
port: 80
34+
targetPort: proxy
35+
protocol: TCP
36+
selector:
37+
app: drycc-grafana

charts/grafana/templates/grafana-deployment.yaml renamed to charts/grafana/templates/grafana-statefulset.yaml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: apps/v1
2-
kind: Deployment
2+
kind: StatefulSet
33
metadata:
44
name: drycc-grafana
55
labels:
@@ -8,11 +8,9 @@ metadata:
88
component.drycc.cc/version: {{ .Values.imageTag }}
99
spec:
1010
replicas: 1
11-
strategy:
12-
rollingUpdate:
13-
maxSurge: 1
14-
maxUnavailable: 0
11+
updateStrategy:
1512
type: RollingUpdate
13+
podManagementPolicy: Parallel
1614
selector:
1715
matchLabels:
1816
app: drycc-grafana
@@ -194,7 +192,7 @@ spec:
194192
{{- toYaml . | nindent 10 }}
195193
{{- end }}
196194
ports:
197-
- containerPort: 5000
195+
- containerPort: 80
198196
name: proxy
199197
{{- include "grafana.envs" . | indent 8 }}
200198
{{- if not .Values.diagnosticMode.enabled }}
@@ -226,16 +224,26 @@ spec:
226224
successThreshold: 1
227225
{{- end }}
228226
volumeMounts:
227+
{{- if .Values.persistence.enabled }}
228+
- name: grafana-data
229+
mountPath: /opt/drycc/grafana/data
230+
{{- end }}
229231
- name: grafana-config
230232
subPath: Caddyfile
231233
readOnly: true
232234
mountPath: /usr/share/grafana/Caddyfile
233235
volumes:
234-
{{- if .Values.persistence.enabled }}
235-
- name: grafana-data
236-
persistentVolumeClaim:
237-
claimName: drycc-grafana
238-
{{- end }}
239236
- name: grafana-config
240237
configMap:
241238
name: grafana-config
239+
{{- if .Values.persistence.enabled }}
240+
volumeClaimTemplates:
241+
- metadata:
242+
name: grafana-data
243+
spec:
244+
accessModes: [ "ReadWriteOnce" ]
245+
storageClassName: {{ .Values.persistence.storageClass }}
246+
resources:
247+
requests:
248+
storage: {{ .Values.persistence.size | quote }}
249+
{{- end }}

charts/grafana/templates/grafana-svc.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

charts/grafana/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ service:
5353

5454
persistence:
5555
enabled: false
56-
accessMode: ReadWriteOnce
5756
size: 5Gi
57+
storageClass: ""
5858
# Any custom grafana environment variables
5959
# can be specified as key-value pairs under environment
6060
# this is usually a non required setting.

rootfs/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ RUN install-packages unzip fontconfig \
2525
&& chown -R ${DRYCC_UID}:${DRYCC_GID} ${DRYCC_HOME_DIR} \
2626
# set env
2727
&& echo "source ${DRYCC_HOME_DIR}/venv/bin/activate" >> /opt/drycc/python/profile.d/python.sh \
28-
# grafana plugin
28+
# grafana plugins
2929
&& mkdir ${DRYCC_HOME_DIR}/plugins \
30-
&& curl -sSL https://github.com/quickwit-oss/quickwit-datasource/releases/download/v0.4.6/quickwit-quickwit-datasource-0.4.6.zip -o quickwit.zip \
31-
&& unzip quickwit.zip -d ${DRYCC_HOME_DIR}/plugins \
32-
&& rm -rf quickwit.zip \
30+
&& grafana cli --pluginsDir=${DRYCC_HOME_DIR}/plugins --homepath=/opt/drycc/grafana plugins install grafana-llm-app \
31+
&& grafana cli --pluginsDir=${DRYCC_HOME_DIR}/plugins --homepath=/opt/drycc/grafana plugins install quickwit-quickwit-datasource \
32+
# clean
3333
&& rm -rf \
3434
/usr/share/doc \
3535
/usr/share/man \
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from .grafana import (
2-
init_org, sync_user, sync_role, sync_datasources, sync_folder, sync_dashboards, sync_alerting
2+
init_org, sync_user, sync_role, sync_default, sync_datasources, sync_dashboards, sync_alerting
33
)
44

55
startup_hooks = [init_org]
66
login_hooks = [
7-
sync_user, sync_role, sync_datasources, sync_folder, sync_dashboards, sync_alerting
7+
sync_user, sync_role, sync_default, sync_datasources, sync_dashboards, sync_alerting
88
]
99
destroy_hooks = []

rootfs/usr/share/grafana/oauth2/hook/grafana.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,26 @@ async def sync_role(context: dict, token: dict, userinfo: dict):
8282
await init_org(org_id=context["org_id"], name=userinfo["preferred_username"])
8383

8484

85-
async def sync_folder(context: dict, token: dict, userinfo: dict):
85+
async def sync_default(context: dict, token: dict, userinfo: dict):
8686
async with httpx.AsyncClient() as client:
8787
await client.post(
8888
api_url("/api/folders"),
8989
headers=api_headers(context, userinfo),
9090
json={"uid": "drycc", "title": "drycc"},
9191
)
92+
await client.post(
93+
api_url("/api/v1/provisioning/contact-points"),
94+
headers=api_headers(context, userinfo),
95+
json={
96+
"uid": "grafana-default-email",
97+
"name": "grafana-default-email",
98+
"type": "email",
99+
"settings": {
100+
"addresses": f"{userinfo["email"]}"
101+
},
102+
"disableResolveMessage": False
103+
},
104+
)
92105

93106

94107
async def sync_alerting(context: dict, token: dict, userinfo: dict):

0 commit comments

Comments
 (0)