Skip to content

Commit 7873846

Browse files
authored
Merge pull request #33 from jordanbean-msft/main
Updates to Kubernetes deployment
2 parents ae9f71f + fe6e903 commit 7873846

File tree

3 files changed

+61
-9
lines changed

3 files changed

+61
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ debug_*
3232

3333
# .env files
3434
*.env
35-
elasticsearch_env
35+
elasticsearch_env
36+
aks-deployment.my.yml

deploy/aks-deployment.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,19 @@ spec:
148148
livenessProbe:
149149
httpGet:
150150
path: /api/health
151-
port: 80
151+
port: 8080
152152
initialDelaySeconds: 90
153153
periodSeconds: 30
154154
failureThreshold: 5
155155
readinessProbe:
156156
httpGet:
157157
path: /api/health
158-
port: 80
158+
port: 8080
159159
initialDelaySeconds: 30
160160
periodSeconds: 10
161+
securityContext:
162+
runAsUser: 472
163+
runAsGroup: 472
161164
volumes:
162165
- name: grafana-data
163166
persistentVolumeClaim:
@@ -173,7 +176,7 @@ spec:
173176
ports:
174177
- protocol: TCP
175178
port: 80
176-
targetPort: 80
179+
targetPort: 8080
177180
---
178181
apiVersion: networking.k8s.io/v1
179182
kind: Ingress

deploy/kubernetes.md

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ Dependent technology stack:
2020
Available [here](aks-deployment.yml).
2121

2222
## Deploy in Kubernetes
23+
2324
This document describes how to deploy the application in Kubernetes.
2425

2526
Variables used in the manifest:
26-
- `__GITHUB_PAT__`
27-
- `__GRAFANA_USERNAME__`
28-
- `__GRAFANA_PASSWORD__`
29-
- `__ORGANIZATION_SLUGS__`
27+
28+
- `__GITHUB_PAT__`
29+
- `__GRAFANA_USERNAME__`
30+
- `__GRAFANA_PASSWORD__`
31+
- `__ORGANIZATION_SLUGS__`
3032

3133
Replacement can be done using `envsubst` tool:
3234

@@ -42,6 +44,7 @@ envsubst < deploy/aks-deployment.yml | kubectl apply -f -
4244
### Deployment in Azure Kubernetes Service - AKS
4345

4446
If you're using Azure Kubernetes Service - AKS:
47+
4548
1. Enable [App Routing](https://learn.microsoft.com/en-us/azure/aks/app-routing)
4649
2. Update variables.
4750
3. Apply the manifest in your cluster.
@@ -51,4 +54,49 @@ If you're using Azure Kubernetes Service - AKS:
5154
1. Update PVC (Persitent Volume Claim) to one supported in your cluster
5255
2. Update Ingress
5356
3. Update variables.
54-
4. Apply the manifest in your cluster.
57+
4. Apply the manifest in your cluster.
58+
59+
### Troubleshooting Grafana "database is locked" Error
60+
61+
Grafana database can lock which can cause container to fail, see [Grafana, SQLite, and database is locked](https://opsverse.io/2022/12/15/grafana-sqlite-and-database-is-locked/)
62+
63+
Use following Job to unlock the database.
64+
65+
```yaml
66+
---
67+
apiVersion: batch/v1
68+
kind: Job
69+
metadata:
70+
name: fix-grafana-once
71+
spec:
72+
template:
73+
spec:
74+
containers:
75+
- name: fix-grafana
76+
image: keinos/sqlite3
77+
imagePullPolicy: IfNotPresent
78+
command:
79+
- "/bin/sh"
80+
- "-c"
81+
- "/usr/bin/sqlite3 /var/lib/grafana/grafana.db '.clone /var/lib/grafana/grafana.db.clone'; mv /var/lib/grafana/grafana.db.clone /var/lib/grafana/grafana.db; chmod a+w /var/lib/grafana/grafana.db"
82+
volumeMounts:
83+
- name: grafana-data
84+
mountPath: /var/lib/grafana
85+
subPath: grafana
86+
securityContext:
87+
runAsUser: 0
88+
resources:
89+
requests:
90+
cpu: "0.25"
91+
memory: "256Mi"
92+
limits:
93+
cpu: "0.5"
94+
memory: "512Mi"
95+
restartPolicy: Never
96+
volumes:
97+
- name: grafana-data
98+
persistentVolumeClaim:
99+
claimName: shared-pvc
100+
```
101+
102+
Force restart grafana container after to re-create.

0 commit comments

Comments
 (0)