Skip to content

Commit db851bd

Browse files
committed
🔧(helm) rework chart based on jenny helm chart
Rework Warren Helm chart based on the work done on Jenny Helm chart in PR openfun/charts#5 Changes done in this commit: - Jobs for database migration or static collection are abstracted into a single job template - Env variables are now processed in the helper template - Removed unused HorizontalPodAutoscaler - Add startup probes for migration checks - Migration jobs are now executed post helm installation/upgrade - Removed unnecessary security context variables - Add a nginx container alongside warren-app to serve static files - Rework postgresql values to have a functional Helm chart on a local cluster - Update Helm chart README.md
1 parent 839fcbb commit db851bd

33 files changed

Lines changed: 756 additions & 830 deletions

src/helm/README.md

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -102,63 +102,30 @@ Our Elasticsearch cluster is all set. In the next section, we will now deploy
102102

103103
### Deploy the LRS: Ralph
104104

105-
Ralph is also distributed as a Helm chart that can be deployed with a single
106-
line of code:
105+
Ralph is also distributed as a Helm chart. Check out the [Ralph Helm chart README](https://github.com/openfun/ralph/blob/main/src/helm/README.md) to deploy it!
107106

108-
```bash
109-
helm install \
110-
--values charts/ralph/values.yaml \
111-
--set envSecrets.RALPH_BACKENDS__DATABASE__ES__HOSTS=https://elastic:"${ELASTIC_PASSWORD}"@data-lake-es-http:9200 \
112-
lrs oci://registry-1.docker.io/openfuncharts/ralph
113-
```
114-
115-
One can check if the server is running by opening a network tunnel to the
116-
service using the `port-forward` sub-command:
117-
118-
119-
```bash
120-
kubectl port-forward svc/lrs-ralph 8080:8080
121-
```
122-
123-
And then send a request to the server using this tunnel:
124-
125-
```bash
126-
curl --user admin:password localhost:8080/whoami
127-
```
128-
129-
We expect a valid JSON response stating about the user you are using for this
130-
request.
131-
132-
If everything went well, we can send 22k xAPI statements to the LRS using:
107+
### Deploy the dashboard suite: Warren
133108

109+
Let's create the secrets needed for Warren deployment:
134110
```bash
135-
gunzip -c ../../data/statements.jsonl.gz | \
136-
sed "s/@timestamp/timestamp/g" | \
137-
jq -s . | \
138-
curl -Lk \
139-
--user admin:password \
140-
-X POST \
141-
-H "Content-Type: application/json" \
142-
http://localhost:8080/xAPI/statements/ -d @-
111+
kubectl apply -f manifests/warren-app-secrets.yaml
112+
kubectl apply -f manifests/warren-api-secrets.yaml
143113
```
144114

145-
### Deploy the dashboard suite: Warren
146-
147-
Now that the LRS is running, we can deploy warren along with its dependencies
115+
We can now deploy Warren along with its dependencies
148116
using:
149117

150118
```bash
151119
# Fetch dependencies
152-
cd warren && helm dependency build
120+
helm dependency build ./warren
153121

154-
# Deploy postgresql for Warren `app` service (Django)
122+
# Install Warren
155123
helm install warren ./warren --values development.yaml --debug --atomic
156124
```
157125

158126
If you want to upgrade your deployment (after a change in a template or a
159127
value), you can upgrade deployed version using:
160128

161129
```bash
162-
# Deploy postgresql for Warren `app` service (Django)
163130
helm upgrade --install warren ./warren --values development.yaml --debug --atomic
164131
```

src/helm/charts/ralph/values.yaml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
envSecrets:
2-
RALPH_BACKENDS__DATABASE__ES__INDEX: statements
3-
RALPH_BACKENDS__DATABASE__ES__CLIENT_OPTIONS__ca_certs: "/usr/local/share/ca-certificates/ca.crt"
4-
RALPH_BACKENDS__DATABASE__ES__CLIENT_OPTIONS__verify_certs: "true"
5-
6-
lrs:
7-
auth:
8-
- username: "admin"
9-
hash: "$2b$12$JFK.YCdbUWD2rS94fT4.m.KC/fIMzUMPMtjaD4t3t1iAfqki3ZPOq"
10-
scopes: ["example_scope"]
11-
12-
elastic:
13-
enabled: true
14-
mountCACert: true
15-
caSecretName: "data-lake-es-http-certs-public"
1+
database:
2+
tls:
3+
enabled: true
4+
certificatesSecret: "data-lake-es-http-certs-public"
5+
certificatesMountPath: "/usr/local/share/ca-certificates/"

src/helm/development.yaml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# -- Warren - app service --
44
app:
55
enabled: true
6-
allowedHosts:
7-
- "localhost"
8-
djangoConfiguration: Development
6+
django:
7+
allowedHosts:
8+
- "localhost"
9+
configuration: "Development"
910
image:
1011
pullPolicy: Always
1112
persistence:
@@ -14,7 +15,8 @@ app:
1415
# -- Warren - api service --
1516
api:
1617
enabled: true
17-
allowedHosts:
18+
fastapi:
19+
allowedHosts:
1820
- "http://localhost:8080"
1921
image:
2022
pullPolicy: Always
@@ -24,10 +26,13 @@ postgresql:
2426
enabled: true
2527
image:
2628
tag: 12.17.0-debian-11-r12
27-
28-
global:
29-
postgresql:
30-
auth:
31-
username: fun
32-
password: pass
33-
database: warren-api
29+
auth:
30+
username: fun
31+
password: pass
32+
database: warren-api
33+
primary:
34+
initdb:
35+
scripts:
36+
init.sql: |
37+
CREATE DATABASE "warren-app";
38+
GRANT ALL PRIVILEGES ON DATABASE "warren-app" TO fun;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: warren-api-db
6+
type: Opaque
7+
stringData:
8+
WARREN_API_DB_PASSWORD: pass
9+
---
10+
apiVersion: v1
11+
kind: Secret
12+
metadata:
13+
name: warren-api-lrs
14+
type: Opaque
15+
stringData:
16+
WARREN_LRS_AUTH_BASIC_PASSWORD: password
17+
---
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: warren-app-db
6+
type: Opaque
7+
stringData:
8+
WARREN_APP_DB_PASSWORD: pass
9+
---
10+
apiVersion: v1
11+
kind: Secret
12+
metadata:
13+
name: warren-app-secret-key
14+
type: Opaque
15+
stringData:
16+
WARREN_APP_SECRET_KEY: change_me_please
17+
---
18+
apiVersion: v1
19+
kind: Secret
20+
metadata:
21+
name: warren-signing-key
22+
type: Opaque
23+
stringData:
24+
WARREN_APP_SIGNING_KEY: change_me
25+
---

src/helm/manifests/warren-secrets.yaml

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

src/helm/warren/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ dependencies:
77
version: 0.1.0
88
- name: postgresql
99
repository: oci://registry-1.docker.io/bitnamicharts
10-
version: 13.2.24
11-
digest: sha256:4b13561dfdca97064192f6861fd5f75f25cdf8b4161a2bb092fbede18f879c61
12-
generated: "2023-12-07T16:42:14.91623072+01:00"
10+
version: 13.4.6
11+
digest: sha256:254a201e5c57f8ae32c527f319492b34167626947c642491343413df2bd61874
12+
generated: "2024-07-03T15:58:33.064365499+02:00"

src/helm/warren/charts/api/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ name: api
44
description: Warren HTTP API
55
type: application
66
version: 0.1.0
7-
appVersion: "0.1.0"
7+
appVersion: "0.3.2"

src/helm/warren/charts/api/templates/NOTES.txt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
1. Get the application URL by running these commands:
1+
CHART NAME: {{ .Chart.Name }}
2+
CHART VERSION: {{ .Chart.Version }}
3+
APP VERSION: {{ .Chart.AppVersion }}
4+
5+
** Please be patient while the chart is being deployed **
6+
7+
1. Access your Warren api installation:
28
{{- if .Values.ingress.enabled }}
3-
{{- range $host := .Values.ingress.hosts }}
4-
{{- range .paths }}
5-
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
9+
Connect to one of the following hosts:
10+
{{ if .Values.ingress.tls }}
11+
https://{{ .Values.ingress.host }}
12+
{{- else }}
13+
http://{{ .Values.ingress.host }}
614
{{- end }}
7-
{{- end }}
815
{{- else if contains "NodePort" .Values.service.type }}
916
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "api.fullname" . }})
1017
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11-
echo http://$NODE_IP:$NODE_PORT
18+
echo "Warren API URL: http://$NODE_IP:$NODE_PORT"
1219
{{- else if contains "LoadBalancer" .Values.service.type }}
1320
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
1421
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "api.fullname" . }}'
1522
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "api.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
1623
echo http://$SERVICE_IP:{{ .Values.service.port }}
1724
{{- else if contains "ClusterIP" .Values.service.type }}
18-
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "api.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
25+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "api.name" . }},api.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
1926
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
2027
echo "Visit http://127.0.0.1:8080 to use your application"
2128
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT

src/helm/warren/charts/api/templates/_helpers.tpl

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,76 @@ Selector labels
4848
{{- define "api.selectorLabels" -}}
4949
app.kubernetes.io/name: {{ include "api.name" . }}
5050
app.kubernetes.io/instance: {{ .Release.Name }}
51+
app.kubernetes.io/component: api
52+
app.kubernetes.io/part-of: warren
5153
{{- end }}
5254

5355
{{/*
54-
Allowed hosts string (environment variable value)
56+
Environment variables
5557
*/}}
56-
{{- define "api.allowedHosts" -}}
57-
{{- printf "%q" .Values.allowedHosts | replace " " "," | quote -}}
58+
{{- define "api.envs" -}}
59+
- name: "WARREN_API_SERVER_PORT"
60+
value: "{{ .Values.service.port }}"
61+
- name: "WARREN_API_DB_NAME"
62+
value: "{{ .Values.fastapi.db.name }}"
63+
- name: "WARREN_API_DB_USER"
64+
value: "{{ .Values.fastapi.db.user }}"
65+
- name: "WARREN_API_DB_PASSWORD"
66+
valueFrom:
67+
secretKeyRef:
68+
name: warren-api-db
69+
key: WARREN_API_DB_PASSWORD
70+
- name: "WARREN_API_DB_ENGINE"
71+
value: "{{ .Values.fastapi.db.engine }}"
72+
- name: "WARREN_API_DB_HOST"
73+
value: "{{ .Values.fastapi.db.host }}"
74+
- name: "WARREN_API_DB_PORT"
75+
value: "{{ .Values.fastapi.db.port }}"
76+
- name: "WARREN_ALLOWED_HOSTS"
77+
value: {{ printf "%q" .Values.fastapi.allowedHosts | replace " " "," | quote }}
78+
- name: "WARREN_LRS_HOSTS"
79+
value: "{{ .Values.fastapi.lrs.host }}"
80+
- name: "WARREN_LRS_AUTH_BASIC_USERNAME"
81+
value: "{{ .Values.fastapi.lrs.username }}"
82+
- name: "WARREN_LRS_AUTH_BASIC_PASSWORD"
83+
valueFrom:
84+
secretKeyRef:
85+
name: warren-api-lrs
86+
key: WARREN_LRS_AUTH_BASIC_PASSWORD
87+
- name: "WARREN_XI_LMS_BASE_URL"
88+
value: "{{ .Values.fastapi.xi.lmsBaseUrl }}"
89+
- name: "WARREN_XI_LMS_API_TOKEN"
90+
valueFrom:
91+
secretKeyRef:
92+
name: warren-api-lms
93+
key: WARREN_XI_LMS_API_TOKEN
94+
- name: "WARREN_XI_DEFAULT_LANG"
95+
value: "{{ .Values.fastapi.xi.defaultLang }}"
96+
- name: "WARREN_APP_SIGNING_ALGORITHM"
97+
value: "{{ .Values.fastapi.signingAlgorithm }}"
98+
- name: "WARREN_APP_SIGNING_KEY"
99+
valueFrom:
100+
secretKeyRef:
101+
name: warren-signing-key
102+
key: WARREN_APP_SIGNING_KEY
103+
{{- range $key, $val := .Values.env.secret }}
104+
- name: {{ $val.envName }}
105+
valueFrom:
106+
secretKeyRef:
107+
name: {{ $val.secretName }}
108+
key: {{ $val.keyName }}
109+
{{- end }}
110+
{{- end }}
111+
112+
{{/*
113+
ImagePullSecrets
114+
*/}}
115+
{{- define "fastapi.imagePullSecrets" -}}
116+
{{- $pullSecrets := .Values.imagePullSecrets }}
117+
{{- if (not (empty $pullSecrets)) }}
118+
imagePullSecrets:
119+
{{- range $pullSecrets }}
120+
- name: {{ . }}
121+
{{ end }}
122+
{{- end -}}
58123
{{- end }}

0 commit comments

Comments
 (0)