Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ed4d61e

Browse files
authored
Merge pull request #22 from GemeenteUtrecht/open-notificaties-enhancements
Open-Notificaties Enhancements
2 parents 5e0cbd6 + a4201e6 commit ed4d61e

File tree

13 files changed

+267
-7
lines changed

13 files changed

+267
-7
lines changed

charts/open-notificaties/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: open-notificaties
33
description: API voor het routeren van notificaties
44

55
type: application
6-
version: 0.5.0
6+
version: 0.6.0
77
appVersion: "1.2.3"
88

99
dependencies:

charts/open-notificaties/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,20 @@ table below describes the supported versions
4646
| `image.repository` | The repository of the Docker image | `openzaak/open-notificaties` |
4747
| `image.tag` | The tag of the Docker image | `""` (uses `.Chart.AppVersion` by default) |
4848
| `replicaCount` | The number of replicas | `1` |
49+
| `podLabels` | Additional labels to be set on the open-notification API pods | `{}` |
4950
| `ingress.enabled` | Expose the application through an ingress | `false` |
5051
| `ingress.annotations` | Additional annotations on the API ingress | `{}` |
5152
| `ingress.hosts` | Ingress hosts | `"{open-notificaties.gemeente.nl}"` |
5253
| `ingress.tls` | Ingress TLS settings | `"[]"` |
54+
| `existingSecret` | Refer to an existing secret to avoid managing secrets through Helm. See templates/secret.yaml for required contents of your existing secret. This secret is also used for the Worker and Flower components. | `null` |
5355
| `settings.allowedHosts` | A comma-separated list of hosts allowed by the application | `"open-notificaties.gemeente.nl"` |
5456
| `settings.secretKey` | The secret key of the application | `"SOME-RANDOM-SECRET"` |
5557
| `settings.database.host` | The hostname of PostgreSQL | `"open-notificaties-postgresql"` |
5658
| `settings.database.port` | The port of PostgreSQL | `5432` |
5759
| `settings.database.username` | The username of PostgreSQL | `"postgres"` |
5860
| `settings.database.password` | The password of PostgreSQL | `"SUPER-SECRET"` |
5961
| `settings.database.name` | The database name of PostgreSQL | `"open-notificaties"` |
62+
| `settings.database.sslmode` | The SSL-mode used by the postgres client. See [docs](https://www.postgresql.org/docs/current/libpq-ssl.html) for more info | `"prefer"` |
6063
| `settings.cache.default` | The Redis cache for the default cache | `"open-notificaties-redis-master:6379/0"` |
6164
| `settings.cache.axes` | The Redis cache for the axes cache | `"open-notificaties-redis-master:6379/0"` |
6265
| `settings.email.host` | The hostname of the SMTP server | `"localhost"` |
@@ -69,11 +72,23 @@ table below describes the supported versions
6972
| `settings.celery.resultBackend` | The URL to the Celery result backend | `"redis://open-notificaties-redis-master:6379/1"` |
7073
| `settings.isHttps` | Used to construct absolute URLs and controls a variety of security settings | `true` |
7174
| `settings.debug` | Only set this to True on a local development environment. Various other security settings are derived from this setting | `false` |
75+
| `settings.flower.urlPrefix` | If enabled, deploy Flower on a non-root URL | `""` |
76+
| `settings.flower.basicAuth` | Secure Flower with [Basic Authentication](https://flower.readthedocs.io/en/latest/config.html#basic-auth). This is a comma-separated list of `username:password`. You should configure this when `flower.ingress.enabled` is set to true. | `""` |
77+
| `worker.podLabels` | Additional labels to be set on the open-notification worker pods | `{}` |
7278
| `postgresql.persistence.enabled` | Enable PostgreSQL persistency | `false` |
7379
| `postgresql.persistence.size` | Configure PostgreSQL size | `"1Gi"` |
7480
| `postgresql.persistence.existingClaim` | Use an existing persistent volume claim | `null` |
7581
| `postgresql.postgresqlDatabase` | The PostgreSQL database name | `"open-notificaties"` |
7682
| `postgresql.postgresqlPassword` | The PostgreSQL administrative password | `"SUPER-SECRET"` |
83+
| `flower.enabled` | Whether or not to deploy the [Flower](https://flower.readthedocs.io/en/latest/) component, which is a monitoring tool for Celery | `false` |
84+
| `flower.replicaCount` | The number of replicas for Celery Flower | `1` |
85+
| `flower.podLabels` | Additional labels to be set for Celery Flower | `{}` |
86+
| `flower.extraEnvVars` | Configure Flower through additional environment variables. For a full list of possibilities, see [Flower config docs](https://flower.readthedocs.io/en/latest/config.html) | `{}` |
87+
| `flower.extraEnvVarsSecret` | Configure Flower through additional environment variables. This property should contain secrets like basic-auth. For a full list of possibilities, see [Flower config docs](https://flower.readthedocs.io/en/latest/config.html) | `{}` |
88+
| `flower.ingress.enabled` | Use a dedicated Ingress for Flower, which can act as a Management Ingress. When `Values.ingress.enabled` is set to true and this parameter to false, then Flower will be exposed on the main Ingress. | `false` |
89+
| `flower.ingress.annotations` | Additional annotations on the Flower Ingress | `{}` |
90+
| `flower.ingress.hosts` | Flower Ingress hosts | `"{open-notificaties-flower.gemeente.nl}"` |
91+
| `flower.ingress.tls` | Flower Ingress TLS settings | `"[]"` |
7792
| `redis.usePassword` | Use a Redis password | `false` |
7893
| `redis.cluster.enabled` | Enable Redis cluster | `false` |
7994
| `redis.persistence.existingClaim` | Use existing persistent volume claim for Redis | `""` |

charts/open-notificaties/templates/_helpers.tpl

+32
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,35 @@ Worker selector labels
9999
app.kubernetes.io/name: {{ include "open-notificaties.workerName" . }}
100100
app.kubernetes.io/instance: {{ .Release.Name }}
101101
{{- end }}
102+
103+
{{/*
104+
Create a name for Flower
105+
We truncate at 56 chars in order to provide space for the "-flower" suffix
106+
*/}}
107+
{{- define "open-notificaties.flowerName" -}}
108+
{{ include "open-notificaties.name" . | trunc 56 | trimSuffix "-" }}-flower
109+
{{- end }}
110+
111+
{{/*
112+
Create a default fully qualified name for Flower.
113+
We truncate at 56 chars in order to provide space for the "-flower" suffix
114+
*/}}
115+
{{- define "open-notificaties.flowerFullname" -}}
116+
{{ include "open-notificaties.fullname" . | trunc 56 | trimSuffix "-" }}-flower
117+
{{- end }}
118+
119+
{{/*
120+
Flower labels
121+
*/}}
122+
{{- define "open-notificaties.flowerLabels" -}}
123+
{{ include "open-notificaties.commonLabels" . }}
124+
{{ include "open-notificaties.flowerSelectorLabels" . }}
125+
{{- end }}
126+
127+
{{/*
128+
Flower selector labels
129+
*/}}
130+
{{- define "open-notificaties.flowerSelectorLabels" -}}
131+
app.kubernetes.io/name: {{ include "open-notificaties.flowerName" . }}
132+
app.kubernetes.io/instance: {{ .Release.Name }}
133+
{{- end }}

charts/open-notificaties/templates/configmap.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ data:
1212
DB_HOST: {{ .Values.settings.database.host | toString | quote }}
1313
DB_PORT: {{ .Values.settings.database.port | toString | quote }}
1414
DB_USER: {{ .Values.settings.database.username | toString | quote }}
15+
PGSSLMODE: {{ .Values.settings.database.sslmode | toString | quote }}
1516
DEBUG: {{ if .Values.settings.debug }}"True"{{ else }}"False"{{ end }}
1617
EMAIL_HOST: {{ .Values.settings.email.host | toString | quote }}
1718
{{- if .Values.settings.email.username }}
@@ -21,4 +22,12 @@ data:
2122
EMAIL_USE_TLS: "True"
2223
{{- end }}
2324
IS_HTTPS: {{ if .Values.settings.isHttps }}"True"{{ else }}"False"{{ end }}
24-
RABBITMQ_HOST: {{ .Values.settings.messageBroker.host }}
25+
RABBITMQ_HOST: {{ .Values.settings.messageBroker.host }}
26+
{{- if .Values.settings.flower.urlPrefix }}
27+
FLOWER_URL_PREFIX: {{ .Values.settings.flower.urlPrefix }}
28+
{{- end }}
29+
{{- if .Values.flower.enabled }}
30+
{{- range $index, $index_value := .Values.flower.extraEnvVars }}
31+
{{ $index }}: {{ $index_value | toString | quote }}
32+
{{- end }}
33+
{{- end }}

charts/open-notificaties/templates/deployment.yaml

+82-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ spec:
2121
{{- end }}
2222
labels:
2323
{{- include "open-notificaties.selectorLabels" . | nindent 8 }}
24+
{{- with .Values.podLabels }}
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
2427
spec:
2528
{{- with .Values.imagePullSecrets }}
2629
imagePullSecrets:
@@ -37,7 +40,7 @@ spec:
3740
imagePullPolicy: {{ .Values.image.pullPolicy }}
3841
envFrom:
3942
- secretRef:
40-
name: {{ include "open-notificaties.fullname" . }}
43+
name: {{ .Values.existingSecret | default (include "open-notificaties.fullname" .) }}
4144
- configMapRef:
4245
name: {{ include "open-notificaties.fullname" . }}
4346
ports:
@@ -98,6 +101,9 @@ spec:
98101
{{- end }}
99102
labels:
100103
{{- include "open-notificaties.workerSelectorLabels" . | nindent 8 }}
104+
{{- with .Values.worker.podLabels }}
105+
{{- toYaml . | nindent 8 }}
106+
{{- end }}
101107
spec:
102108
{{- with .Values.imagePullSecrets }}
103109
imagePullSecrets:
@@ -114,7 +120,7 @@ spec:
114120
imagePullPolicy: {{ .Values.image.pullPolicy }}
115121
envFrom:
116122
- secretRef:
117-
name: {{ include "open-notificaties.fullname" . }}
123+
name: {{ .Values.existingSecret | default (include "open-notificaties.fullname" .) }}
118124
- configMapRef:
119125
name: {{ include "open-notificaties.fullname" . }}
120126
resources:
@@ -133,5 +139,77 @@ spec:
133139
tolerations:
134140
{{- toYaml . | nindent 8 }}
135141
{{- end }}
136-
137-
142+
---
143+
{{- if .Values.flower.enabled -}}
144+
apiVersion: apps/v1
145+
kind: Deployment
146+
metadata:
147+
name: {{ include "open-notificaties.flowerFullname" . }}
148+
labels:
149+
{{- include "open-notificaties.flowerLabels" . | nindent 4 }}
150+
spec:
151+
replicas: {{ .Values.flower.replicaCount }}
152+
selector:
153+
matchLabels:
154+
{{- include "open-notificaties.flowerSelectorLabels" . | nindent 6 }}
155+
template:
156+
metadata:
157+
annotations:
158+
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
159+
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
160+
{{- with .Values.podAnnotations }}
161+
{{- toYaml . | nindent 8 }}
162+
{{- end }}
163+
labels:
164+
{{- include "open-notificaties.flowerSelectorLabels" . | nindent 8 }}
165+
{{- with .Values.flower.podLabels }}
166+
{{- toYaml . | nindent 8 }}
167+
{{- end }}
168+
spec:
169+
{{- with .Values.imagePullSecrets }}
170+
imagePullSecrets:
171+
{{- toYaml . | nindent 8 }}
172+
{{- end }}
173+
serviceAccountName: {{ include "open-notificaties.serviceAccountName" . }}
174+
securityContext:
175+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
176+
containers:
177+
- name: {{ .Chart.Name }}-flower
178+
securityContext:
179+
{{- toYaml .Values.securityContext | nindent 12 }}
180+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
181+
imagePullPolicy: {{ .Values.image.pullPolicy }}
182+
envFrom:
183+
- secretRef:
184+
name: {{ .Values.existingSecret | default (include "open-notificaties.fullname" .) }}
185+
- configMapRef:
186+
name: {{ include "open-notificaties.fullname" . }}
187+
ports:
188+
- name: http
189+
containerPort: 5555
190+
protocol: TCP
191+
livenessProbe:
192+
tcpSocket:
193+
port: 5555
194+
{{- toYaml .Values.flower.livenessProbe | nindent 12 }}
195+
readinessProbe:
196+
tcpSocket:
197+
port: 5555
198+
{{- toYaml .Values.flower.readinessProbe | nindent 12 }}
199+
resources:
200+
{{- toYaml .Values.flower.resources | nindent 12 }}
201+
command:
202+
- /celery_flower.sh
203+
{{- with .Values.nodeSelector }}
204+
nodeSelector:
205+
{{- toYaml . | nindent 8 }}
206+
{{- end }}
207+
{{- with .Values.affinity }}
208+
affinity:
209+
{{- toYaml . | nindent 8 }}
210+
{{- end }}
211+
{{- with .Values.tolerations }}
212+
tolerations:
213+
{{- toYaml . | nindent 8 }}
214+
{{- end }}
215+
{{- end }}

charts/open-notificaties/templates/ingress.yaml

+53
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{{- if .Values.ingress.enabled -}}
22
{{- $fullName := include "open-notificaties.fullname" . -}}
33
{{- $svcPort := .Values.service.port -}}
4+
{{- $flowerEnabled := .Values.flower.enabled }}
5+
{{- $flowerIngressEnabled := .Values.flower.ingress.enabled }}
6+
{{- $flowerFullName := include "open-notificaties.flowerFullname" . -}}
7+
{{- $flowerSvcPort := .Values.flower.service.port -}}
8+
{{- $flowerUrlPrefix := .Values.settings.flower.urlPrefix -}}
49
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
510
apiVersion: networking.k8s.io/v1beta1
611
{{- else -}}
@@ -35,5 +40,53 @@ spec:
3540
backend:
3641
serviceName: {{ $fullName }}
3742
servicePort: {{ $svcPort }}
43+
{{- if and ($flowerEnabled) (not $flowerIngressEnabled) }}
44+
- path: /{{ $flowerUrlPrefix }}
45+
backend:
46+
serviceName: {{ $flowerFullName }}
47+
servicePort: {{ $flowerSvcPort }}
48+
{{- end }}
49+
{{- end }}
50+
{{- end }}
51+
52+
---
53+
{{- if .Values.flower.ingress.enabled -}}
54+
{{- $fullName := include "open-notificaties.flowerFullname" . -}}
55+
{{- $svcPort := .Values.flower.service.port -}}
56+
{{- $flowerUrlPrefix := .Values.settings.flower.urlPrefix -}}
57+
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
58+
apiVersion: networking.k8s.io/v1beta1
59+
{{- else -}}
60+
apiVersion: extensions/v1beta1
61+
{{- end }}
62+
kind: Ingress
63+
metadata:
64+
name: {{ $fullName }}
65+
labels:
66+
{{- include "open-notificaties.labels" . | nindent 4 }}
67+
{{- with .Values.flower.ingress.annotations }}
68+
annotations:
69+
{{- toYaml . | nindent 4 }}
70+
{{- end }}
71+
spec:
72+
{{- if .Values.flower.ingress.tls }}
73+
tls:
74+
{{- range .Values.flower.ingress.tls }}
75+
- hosts:
76+
{{- range .hosts }}
77+
- {{ . | quote }}
78+
{{- end }}
79+
secretName: {{ .secretName }}
80+
{{- end }}
81+
{{- end }}
82+
rules:
83+
{{- range .Values.flower.ingress.hosts }}
84+
- host: {{ . | quote }}
85+
http:
86+
paths:
87+
- path: /{{ $flowerUrlPrefix }}
88+
backend:
89+
serviceName: {{ $fullName }}
90+
servicePort: {{ $svcPort }}
3891
{{- end }}
3992
{{- end }}

charts/open-notificaties/templates/secret.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.existingSecret }}
12
apiVersion: v1
23
kind: Secret
34
metadata:
@@ -18,3 +19,10 @@ data:
1819
{{- if .Values.settings.sentry.dsn }}
1920
SENTRY_DSN: {{ .Values.settings.sentry.dsn | toString | b64enc | quote }}
2021
{{- end }}
22+
{{- if .Values.flower.enabled }}
23+
FLOWER_BASIC_AUTH: {{ .Values.settings.flower.basicAuth | toString | b64enc | quote }}
24+
{{- range $index, $index_value := .Values.flower.extraEnvVarsSecret }}
25+
{{ $index }}: {{ $index_value | toString | b64enc | quote }}
26+
{{- end }}
27+
{{- end }}
28+
{{- end }}

charts/open-notificaties/templates/service.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,21 @@ spec:
1313
name: http
1414
selector:
1515
{{- include "open-notificaties.selectorLabels" . | nindent 4 }}
16+
---
17+
{{- if .Values.flower.enabled -}}
18+
apiVersion: v1
19+
kind: Service
20+
metadata:
21+
name: {{ include "open-notificaties.flowerFullname" . }}
22+
labels:
23+
{{- include "open-notificaties.flowerLabels" . | nindent 4 }}
24+
spec:
25+
type: {{ .Values.flower.service.type }}
26+
ports:
27+
- port: {{ .Values.flower.service.port }}
28+
targetPort: 5555
29+
protocol: TCP
30+
name: http
31+
selector:
32+
{{- include "open-notificaties.flowerSelectorLabels" . | nindent 4 }}
33+
{{- end }}

0 commit comments

Comments
 (0)