Skip to content

Commit 2ad0681

Browse files
authored
Merge pull request #10 from esgf2-us/update-chart
Updates helm chart
2 parents e4bb387 + 2526e5b commit 2ad0681

File tree

11 files changed

+385
-257
lines changed

11 files changed

+385
-257
lines changed

chart/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: metagrid
33
description: A Helm chart for the Metagrid frontend/backend
44
type: application
5-
version: 0.1.1
5+
version: 0.1.2
66
appVersion: "v1.0.9-beta"
77
home: https://github.com/esgf2-us/metagrid-k8s
88
sources:

chart/README.md

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ helm delete my-release
5252
| external.keycloak.clientID | string | `"metagrid-llnl"` | Keycloak client ID |
5353
| external.hotjar | object | `{"id":null,"sv":null}` | [Hotjar](https://www.hotjar.com/) tracking codes, **OPTIONAL** |
5454
| external.googleAnalyticsTrackingID | string | `nil` | Google analytics tracking id, **OPTIONAL** |
55+
| projects | string | `nil` | Customize projects loaded during the initial migration, this is the value stored in [initial_projects_data.py](https://github.com/aims-group/metagrid/blob/master/backend/metagrid/initial_projects_data.py) |
56+
| imagePullSecrets | list | `[]` | List of secrets used to pull images from private registries |
5557
| django.replicaCount | int | `1` | Number of replicas |
5658
| django.debug | bool | `false` | Enable Django debugging |
5759
| django.adminURL | string | `"panel/"` | Relative path to the Django management panel |
@@ -61,49 +63,57 @@ helm delete my-release
6163
| django.image.repository | string | `"ghcr.io/aims-group/metagrid-backend"` | Django container URI |
6264
| django.image.pullPolicy | string | `"Always"` | Image pull policy |
6365
| django.image.tag | string | `"latest"` | Container tag |
64-
| django.imagePullSecrets | list | `[]` | List of image pull secrets |
6566
| django.nameOverride | string | `""` | |
6667
| django.fullnameOverride | string | `""` | |
67-
| django.migrateJob.enabled | bool | `true` | Enable database migration job |
6868
| django.podAnnotations | object | `{}` | Extra pod annotations |
69-
| django.podSecurityContext | object | `{}` | Pod security context |
70-
| django.securityContext | object | `{}` | Container security context |
71-
| django.resources | object | `{}` | Pod resources requests/limits |
69+
| django.migrateJob.enabled | bool | `true` | Enable database migration job |
70+
| django.migrateJob.restartPolicy | string | `"Never"` | |
71+
| django.affinity | object | `{}` | [Affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity), pod node scheduling constraints |
72+
| django.resources | object | `{}` | Container [resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) |
73+
| django.securityContext | object | `{}` | Container [security](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) context |
74+
| django.nodeSelector | object | `{}` | Node [selector](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) labels |
75+
| django.preemptionPolicy | string | `nil` | Pod [preemption](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#preemption) policy |
76+
| django.priority | string | `nil` | Pod scheduling [priority](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority) |
77+
| django.priorityClassName | string | `nil` | Pod scheduling [priority](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) class name |
78+
| django.podSecurityContext | object | `{}` | Pod [security](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) context |
79+
| django.tolerations | list | `[]` | Pod [tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
7280
| django.autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80}` | Horizontal pod autoscaling configuration |
73-
| django.nodeSelector | object | `{}` | Node selector |
74-
| django.tolerations | list | `[]` | Tolerations |
75-
| django.affinity | object | `{}` | Affinity |
7681
| django.service | object | `{"port":5000,"type":"ClusterIP"}` | Django service |
7782
| django.service.type | string | `"ClusterIP"` | Service type |
7883
| django.service.port | int | `5000` | Service port |
7984
| react.replicaCount | int | `1` | Number of replicas |
8085
| react.image.repository | string | `"ghcr.io/aims-group/metagrid-frontend"` | React container URI |
8186
| react.image.pullPolicy | string | `"Always"` | Container pull policy |
8287
| react.image.tag | string | `"latest"` | Container tag |
83-
| react.imagePullSecrets | list | `[]` | List of image pull secrets |
8488
| react.nameOverride | string | `""` | |
8589
| react.fullnameOverride | string | `""` | |
8690
| react.podAnnotations | object | `{}` | Extra pod annotations |
87-
| react.podSecurityContext | object | `{}` | Pod security context |
88-
| react.securityContext | object | `{}` | Container security context |
89-
| react.resources | object | `{}` | Resources requests/limits |
91+
| react.affinity | object | `{}` | [Affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity), pod node scheduling constraints |
92+
| react.resources | object | `{}` | Container [resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) |
93+
| react.securityContext | object | `{}` | Container [security](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) context |
94+
| react.nodeSelector | object | `{}` | Node [selector](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) labels |
95+
| react.preemptionPolicy | string | `nil` | Pod [preemption](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#preemption) policy |
96+
| react.priority | string | `nil` | Pod scheduling [priority](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority) |
97+
| react.priorityClassName | string | `nil` | Pod scheduling [priority](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) class name |
98+
| react.podSecurityContext | object | `{}` | Pod [security](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) context |
99+
| react.tolerations | list | `[]` | Pod [tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
90100
| react.autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80}` | Horizontal Pod autoscaling configuration |
91-
| react.nodeSelector | object | `{}` | Node selector |
92-
| react.tolerations | list | `[]` | Tolerations |
93-
| react.affinity | object | `{}` | Affinity |
94101
| react.service | object | `{"port":3000,"type":"ClusterIP"}` | React service |
95102
| react.service.type | string | `"ClusterIP"` | Service type |
96103
| react.service.port | int | `3000` | Service port |
97104
| react.monitoring | object | `{"enabled":false}` | Prometheus monitoring |
98105
| ingress.enabled | bool | `false` | Enable ingress |
99106
| ingress.annotations | object | `{}` | Extra ingress annotations |
100107
| ingress.labels | object | `{}` | Extra ingress labels |
108+
| ingress.className | string | `nil` | Override ingress class |
101109
| ingress.react | object | `{"host":null,"path":"/metagrid"}` | React ingress endpoint |
102110
| ingress.react.host | string | `nil` | Endpoint host |
103111
| ingress.react.path | string | `"/metagrid"` | Endpoint path |
104112
| ingress.django | object | `{"host":null,"path":"/metagrid-backend"}` | Django ingress endpoint |
105113
| ingress.django.host | string | `nil` | Endpoint host |
106114
| ingress.django.path | string | `"/metagrid-backend"` | Endpoint path |
115+
| ingress.tls.enabled | bool | `false` | |
116+
| ingress.tls.secretName | string | `nil` | |
107117
| postgresql | object | `{"enabled":true,"persistence":{"enabled":false},"pgpool":{"adminPassword":"pgpooladminpass","containerSecurityContext":{"enabled":false},"podSecurityContext":{"enabled":false}},"postgresql":{"containerSecurityContext":{"enabled":false},"password":"pgpass","podSecurityContext":{"enabled":false},"replicaCount":1,"repmgrPassword":"repmgrpass"}}` | Postgresql database, **REQUIRED** |
108118
| postgresql.persistence | object | `{"enabled":false}` | Enabled persistence |
109119
| postgresql.postgresql.password | string | `"pgpass"` | Postgresql password, should replace the default with something more secure |
@@ -112,8 +122,41 @@ helm delete my-release
112122
| extraManifests | object | `{}` | Extra manifests |
113123

114124
## Configuration and installation details
115-
### External TLS terminatioj
116-
Some urls are auto-generated based on the configuration of the ingress. If TLS is not configured on the ingress (handled by upstream ingress) then this may result in some misconfiguration.
125+
### Setting the initial projects
126+
The `projects` value can be used to set the initial projects loaded by the backend. The following example will create a simple `CMIP6` project.
127+
128+
```
129+
projects: |
130+
group_description = {
131+
"General": "Just a group",
132+
}
133+
projects = [
134+
{
135+
"name": "CMIP6",
136+
...
137+
"facets_by_group": {
138+
"General": ["data_node"],
139+
},
140+
]
141+
```
142+
143+
To add/remove projects after the initial migration, edit `projects` and upgrade the `Helm` chart. Next clear the existing database tables and run the migration update.
144+
145+
#### Clear existing database tables
146+
```
147+
kubectl exec -it $(kubectl get pod -oname -l app.kubernetes.io/component=django) -- python manage.py migrate projects zero
148+
```
149+
150+
#### Run the migration update
151+
```
152+
kubectl exec -it $(kubectl get pod -oname -l app.kubernetes.io/component=django) -- python manage.py migrate projects
153+
```
154+
155+
### External TLS termination
156+
The `nodeStatus` and `metagridAPIUrl` values by default are automatically generated. If using an upstream reverse-proxy that handles TLS, then these urls will be incorrect and cause
157+
the application to not work correctly.
158+
159+
To fix this both `nodeStatus` and `metagridAPIUrl` need to be overwritten, see the following example.
117160

118161
```
119162
external:

chart/README.md.gotmpl

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,41 @@ helm delete my-release
2929
{{ template "chart.valuesSection" . }}
3030

3131
## Configuration and installation details
32-
### External TLS terminatioj
33-
Some urls are auto-generated based on the configuration of the ingress. If TLS is not configured on the ingress (handled by upstream ingress) then this may result in some misconfiguration.
32+
### Setting the initial projects
33+
The `projects` value can be used to set the initial projects loaded by the backend. The following example will create a simple `CMIP6` project.
34+
35+
```
36+
projects: |
37+
group_description = {
38+
"General": "Just a group",
39+
}
40+
projects = [
41+
{
42+
"name": "CMIP6",
43+
...
44+
"facets_by_group": {
45+
"General": ["data_node"],
46+
},
47+
]
48+
```
49+
50+
To add/remove projects after the initial migration, edit `projects` and upgrade the `Helm` chart. Next clear the existing database tables and run the migration update.
51+
52+
#### Clear existing database tables
53+
```
54+
kubectl exec -it $(kubectl get pod -oname -l app.kubernetes.io/component=django) -- python manage.py migrate projects zero
55+
```
56+
57+
#### Run the migration update
58+
```
59+
kubectl exec -it $(kubectl get pod -oname -l app.kubernetes.io/component=django) -- python manage.py migrate projects
60+
```
61+
62+
### External TLS termination
63+
The `nodeStatus` and `metagridAPIUrl` values by default are automatically generated. If using an upstream reverse-proxy that handles TLS, then these urls will be incorrect and cause
64+
the application to not work correctly.
65+
66+
To fix this both `nodeStatus` and `metagridAPIUrl` need to be overwritten, see the following example.
3467

3568
```
3669
external:

chart/templates/_helpers.tpl

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,132 @@ Django ESGF node status url
123123
*/}}
124124
{{- define "metagrid.django.esgfNodeStatusUrl" -}}
125125
{{- $service := printf "127.0.0.1:%v" .Values.django.service.port }}
126+
{{- $ssl := ternary "s" "" .Values.ingress.tls.enabled }}
126127
{{- $host := ternary .Values.ingress.django.host $service .Values.ingress.enabled }}
127-
{{- $url := printf "http://%v/%v/proxy/status" $host (trimPrefix "/" .Values.ingress.django.path) }}
128+
{{- $url := printf "http%v://%v/%v/proxy/status" $ssl $host (trimPrefix "/" .Values.ingress.django.path) }}
128129
{{- printf "%v" (default $url .Values.external.nodeStatus) }}
129130
{{- end }}
130131

131132
{{- define "metagrid.react.metagridUrl" -}}
132133
{{- $service := printf "127.0.0.1:%v" .Values.django.service.port }}
134+
{{- $ssl := ternary "s" "" .Values.ingress.tls.enabled }}
133135
{{- $host := ternary .Values.ingress.django.host $service .Values.ingress.enabled }}
134-
{{- $url := printf "http://%v/%v" $host .Values.ingress.django.path }}
136+
{{- $url := printf "http%v://%v/%v" $ssl $host .Values.ingress.django.path }}
135137
{{- printf "%v" (default $url .Values.external.metagridAPIUrl) }}
136138
{{- end }}
139+
140+
{{- define "metagrid.podSpec" -}}
141+
{{- with .affinity }}
142+
affinity:
143+
{{- toYaml . | nindent 2 }}
144+
{{- end }}
145+
containers:
146+
- name: {{ .name }}
147+
{{- with .args }}
148+
args:
149+
{{- toYaml . | nindent 4 }}
150+
{{- end }}
151+
{{- with .command }}
152+
command:
153+
{{- toYaml . | nindent 4 }}
154+
{{- end }}
155+
{{- with .env }}
156+
env:
157+
{{- range $name, $value := . }}
158+
- name: {{ $name }}
159+
value: {{ tpl $value .TemplateValues | quote }}
160+
{{- end }}
161+
{{- end }}
162+
{{- with .envFrom }}
163+
envFrom:
164+
{{- toYaml . | nindent 4 }}
165+
{{- end }}
166+
image: {{ .image.repository }}:{{ .image.tag }}
167+
{{- with .image.pullPolicy }}
168+
imagePullPolicy: {{ . }}
169+
{{- end }}
170+
{{- with .livenessProbe }}
171+
livenessProbe:
172+
{{- toYaml . | nindent 4 }}
173+
{{- end }}
174+
{{- with .service }}
175+
ports:
176+
- name: {{ .name }}
177+
containerPort: {{ .port }}
178+
protocol: {{ default "TCP" .protocol }}
179+
{{- end }}
180+
{{- with .readinessProbe }}
181+
readinessProbe:
182+
{{- toYaml . | nindent 4 }}
183+
{{- end }}
184+
{{- with .resources }}
185+
resources:
186+
{{- toYaml . | nindent 4 }}
187+
{{- end }}
188+
{{- with .securityContext }}
189+
securityContext:
190+
{{- toYaml . | nindent 4 }}
191+
{{- end }}
192+
{{- with .startupProbe }}
193+
startupProbe:
194+
{{- toYaml . | nindent 4 }}
195+
{{- end }}
196+
{{- with .persistence }}
197+
volumeMounts:
198+
- mountPath: {{ .mountPath }}
199+
name: {{ .name }}
200+
readOnly: {{ default "false" .readOnly }}
201+
{{- with .subPath }}
202+
subPath: {{ . }}
203+
{{- end }}
204+
{{- end }}
205+
{{- with .dnsConfig }}
206+
dnsConfig:
207+
{{- toYaml . | nindent 2 }}
208+
{{- end }}
209+
{{- with .dnsPolicy }}
210+
dnsPolicy: {{ . }}
211+
{{- end }}
212+
{{- with .image.pullSecrets }}
213+
imagePullSecrets:
214+
- name: {{ include "metagrid.fullname" .TemplateValues }}
215+
{{- end }}
216+
{{- with .nodeSelector }}
217+
nodeSelector:
218+
{{- toYaml . | nindent 2 }}
219+
{{- end }}
220+
{{- with .preemptionPolicy }}
221+
preemptionPolicy: {{ . }}
222+
{{- end }}
223+
{{- with .priority }}
224+
priority: {{ . }}
225+
{{- end }}
226+
{{- with .priorityClassName }}
227+
priorityClassName: {{ . }}
228+
{{- end }}
229+
{{- with .restartPolicy }}
230+
restartPolicy: {{ . }}
231+
{{- end }}
232+
{{- with .runtimeClassName }}
233+
runtimeClassName: {{ . }}
234+
{{- end }}
235+
{{- with .podSecurityContext }}
236+
securityContext:
237+
{{- toYaml . | nindent 2 }}
238+
{{- end }}
239+
{{- with .tolerations }}
240+
tolerations:
241+
{{- toYaml . | nindent 2 }}
242+
{{- end }}
243+
{{- with .persistence }}
244+
volumes:
245+
{{- if eq .type "configmap" }}
246+
- configMap:
247+
name: {{ .resourceName }}
248+
{{- else if eq .type "secret" }}
249+
- secret:
250+
secretName: {{ .resourceName }}
251+
{{- end }}
252+
name: {{ .name }}
253+
{{- end }}
254+
{{- end }}

chart/templates/django/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ data:
1212
PYTHONBUFFERED: "1"
1313
DJANGO_DEBUG: {{ .Values.django.debug | quote }}
1414
DJANGO_ADMIN_URL: {{ .Values.django.adminURL }}
15-
DJANGO_ALLOWED_HOSTS: {{ include "metagrid.django_allowed_hosts" . }}
15+
DJANGO_ALLOWED_HOSTS: {{ include "metagrid.django_allowed_hosts" . | quote }}
1616
DJANGO_SECURE_SSL_REDIRECT: "False"
1717
DJANGO_SETTINGS_MODULE: config.settings.production
1818
DOMAIN_NAME: {{ default "127.0.0.1" .Values.ingress.django.host }}

chart/templates/django/deployment.yaml

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,50 +23,15 @@ spec:
2323
{{- include "metagrid.selectorLabels" . | nindent 8 }}
2424
app.kubernetes.io/component: django
2525
spec:
26-
imagePullSecrets:
27-
{{- range $name, $_ := .Values.imagePullSecrets }}
28-
- name: {{ include "metagrid.fullname" $ }}-{{ regexReplaceAll "\\W+" $name "-" }}
29-
{{- end }}
30-
securityContext:
31-
{{- toYaml .Values.django.podSecurityContext | nindent 8 }}
32-
containers:
33-
- name: {{ .Chart.Name }}
34-
args: ["/start"]
35-
securityContext:
36-
{{- toYaml .Values.django.securityContext | nindent 12 }}
37-
image: "{{ .Values.django.image.repository }}:{{ .Values.django.image.tag | default .Chart.AppVersion }}"
38-
imagePullPolicy: {{ .Values.django.image.pullPolicy }}
39-
envFrom:
40-
- configMapRef:
41-
name: {{ include "metagrid.fullname" . }}-django
42-
- secretRef:
43-
name: {{ include "metagrid.fullname" . }}-django
44-
env:
45-
{{- range $key, $value := default dict .Values.django.env}}
46-
- name: {{ tpl $key $ }}
47-
value: {{ tpl $value $ | quote }}
48-
{{- end }}
49-
ports:
50-
- name: http
51-
containerPort: {{ .Values.django.service.port }}
52-
protocol: TCP
53-
livenessProbe:
54-
tcpSocket:
55-
port: http
56-
readinessProbe:
57-
tcpSocket:
58-
port: http
59-
resources:
60-
{{- toYaml .Values.django.resources | nindent 12 }}
61-
{{- with .Values.django.nodeSelector }}
62-
nodeSelector:
63-
{{- toYaml . | nindent 8 }}
64-
{{- end }}
65-
{{- with .Values.django.affinity }}
66-
affinity:
67-
{{- toYaml . | nindent 8 }}
68-
{{- end }}
69-
{{- with .Values.django.tolerations }}
70-
tolerations:
71-
{{- toYaml . | nindent 8 }}
72-
{{- end }}
26+
{{- $django := deepCopy .Values.django }}
27+
{{- $_ := set $django "name" "django" }}
28+
{{- $_ := set $django.image "pullSecrets" .Values.imagePullSecrets }}
29+
{{- $_ := set $django "args" (list "/start") }}
30+
{{- $config := dict "configMapRef" (dict "name" (printf "%s-django" (include "metagrid.fullname" .))) }}
31+
{{- $secret := dict "secretRef" (dict "name" (printf "%s-django" (include "metagrid.fullname" .))) }}
32+
{{- $_ := set $django "envFrom" (list $config $secret) }}
33+
{{- $_ := set $django "TemplateValues" . }}
34+
{{- $_ := set $django.service "name" "http" }}
35+
{{- $_ := set $django "livenessProbe" (dict "tcpSocket" (dict "port" "http")) }}
36+
{{- $_ := set $django "readinessProbe" (dict "tcpSocket" (dict "port" "http")) }}
37+
{{- include "metagrid.podSpec" $django | nindent 6 }}

0 commit comments

Comments
 (0)