Skip to content

Commit f7f27e8

Browse files
feat(dso-console): add new backend service that will replace server
Mostly based on current `server`. Since one is purposed to replace the other, we want to be able to use the same overall configuration for both.
1 parent fb8efe5 commit f7f27e8

File tree

13 files changed

+742
-83
lines changed

13 files changed

+742
-83
lines changed

charts/dso-console/Chart.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: cpn-console
33
description: A Helm chart to deploy Cloud Pi Native Console
44
type: application
5-
version: 2.2.19
5+
version: 2.3.0
66
appVersion: 9.13.2
77
keywords: []
88
home: https://cloud-pi-native.fr
@@ -26,6 +26,9 @@ dependencies:
2626
deprecated: false
2727
annotations: {}
2828
maintainers:
29-
- name: this-is-tobi
30-
email: thibault.colin@interieur.gouv.fr
31-
url: https://this-is-tobi.com
29+
- name: omiladi
30+
email: cloudpinative-relations@interieur.gouv.fr
31+
url: https://www.interieur.gouv.fr/
32+
- name: KepoParis
33+
email: cloudpinative-relations@interieur.gouv.fr
34+
url: https://www.interieur.gouv.fr/

charts/dso-console/README.md

Lines changed: 105 additions & 37 deletions
Large diffs are not rendered by default.

charts/dso-console/templates/_helpers.tpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ Create the name of the service account to use
2525
{{- end }}
2626
{{- end }}
2727

28+
{{- define "cpnConsole.backend.serviceAccountName" -}}
29+
{{- if .Values.backend.serviceAccount.create }}
30+
{{- default (include "cpnConsole.name" .) .Values.backend.serviceAccount.name }}
31+
{{- else }}
32+
{{- default "cpn-backend" .Values.backend.serviceAccount.name }}
33+
{{- end }}
34+
{{- end }}
2835

2936
{{/*
3037
Create image pull secret
@@ -121,6 +128,11 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
121128
{{- end }}
122129

123130

131+
{{- define "cpnConsole.backend.labels" -}}
132+
{{ include "cpnConsole.common.labels" . }}
133+
{{ include "cpnConsole.backend.selectorLabels" . }}
134+
{{- end }}
135+
124136
{{/*
125137
Selector labels
126138
*/}}
@@ -133,3 +145,8 @@ app.kubernetes.io/instance: {{ .Release.Name }}
133145
app.kubernetes.io/name: {{ include "cpnConsole.name" . }}-server
134146
app.kubernetes.io/instance: {{ .Release.Name }}
135147
{{- end }}
148+
149+
{{- define "cpnConsole.backend.selectorLabels" -}}
150+
app.kubernetes.io/name: {{ include "cpnConsole.name" . }}-backend
151+
app.kubernetes.io/instance: {{ .Release.Name }}
152+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-backend
5+
labels: {{- include "cpnConsole.backend.labels" . | nindent 4 }}
6+
rules:
7+
- apiGroups:
8+
- ""
9+
- user.openshift.io
10+
- rbac.authorization.k8s.io
11+
- argoproj.io
12+
{{- if .Values.features.vaultSecrets.enabled }}
13+
- secrets.hashicorp.com
14+
{{- end }}
15+
resources:
16+
- '*'
17+
verbs:
18+
- '*'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-backend
5+
labels: {{- include "cpnConsole.backend.labels" . | nindent 4 }}
6+
roleRef:
7+
apiGroup: rbac.authorization.k8s.io
8+
kind: ClusterRole
9+
name: {{ include "cpnConsole.fullname" . }}-backend
10+
subjects:
11+
- kind: ServiceAccount
12+
name: {{ include "cpnConsole.backend.serviceAccountName" . }}
13+
namespace: {{ $.Release.Namespace }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-backend
5+
labels: {{- include "cpnConsole.backend.labels" . | nindent 4 }}
6+
data:
7+
SERVER_PORT: {{ .Values.backend.container.port | quote }}
8+
KEYCLOAK_PROTOCOL: {{ .Values.global.keycloak.protocol.backend }}
9+
KEYCLOAK_DOMAIN: {{ .Values.global.keycloak.domain.backend }}
10+
KEYCLOAK_REALM: {{ .Values.global.keycloak.realm }}
11+
KEYCLOAK_REDIRECT_URI: {{ .Values.global.keycloak.redirectUri }}
12+
KEYCLOAK_CLIENT_ID: {{ .Values.global.keycloak.clientIds.backend }}
13+
{{- if .Values.backend.extraCa.name }}
14+
NODE_EXTRA_CA_CERTS: {{ printf "%s/%s" "/config" .Values.backend.extraCa.mountSubPath }}
15+
{{- end }}
16+
{{- if .Values.backend.disabledPlugins -}}
17+
DISABLED_PLUGINS: {{ .Values.backend.disabledPlugins }}
18+
{{- end }}
19+
{{- if .Values.global.env -}}
20+
{{- include "cpnConsole.env" .Values.global | indent 2 }}
21+
{{- end -}}
22+
{{- if .Values.backend.env -}}
23+
{{- include "cpnConsole.env" .Values.backend | indent 2 }}
24+
{{- end -}}
25+
{{- if not .Values.features.vaultSecrets.enabled }}
26+
VAULT__DISABLE_VAULT_SECRETS: "true"
27+
{{- end }}
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-backend
5+
labels:
6+
{{- include "cpnConsole.backend.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.backend.autoscaling.enabled }}
9+
replicas: {{ .Values.backend.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "cpnConsole.backend.selectorLabels" . | nindent 6 }}
14+
strategy:
15+
type: {{ .Values.backend.strategy.type }}
16+
template:
17+
metadata:
18+
annotations:
19+
{{- include "checksum" (list $ "/backend/configmap.yaml") | nindent 8 }}
20+
{{- include "checksum" (list $ "/backend/secret.yaml") | nindent 8 }}
21+
{{- include "checksum" (list $ "/backend/scripts.yaml") | nindent 8 }}
22+
{{- if .Values.config.create }}
23+
{{- include "checksum" (list $ "/config.yaml") | nindent 8 }}
24+
{{- end }}
25+
{{- with .Values.backend.podAnnotations }}
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
labels:
29+
{{- include "cpnConsole.backend.selectorLabels" . | nindent 8 }}
30+
{{- with .Values.backend.podLabels }}
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
spec:
34+
{{- if and .Values.imageCredentials.username .Values.imageCredentials.password }}
35+
imagePullSecrets:
36+
- name: {{ include "cpnConsole.name" . }}-pullsecret
37+
{{- end }}
38+
serviceAccountName: {{ include "cpnConsole.backend.serviceAccountName" . }}
39+
securityContext:
40+
{{- toYaml .Values.backend.podSecurityContext | nindent 8 }}
41+
{{- if or .Values.backend.plugins .Values.backend.initContainers }}
42+
initContainers:
43+
{{- if and .Values.backend.plugins (len .Values.backend.plugins) }}
44+
- image: {{ .Values.backend.fetchContainer.image }}
45+
name: fetch-plugins
46+
imagePullPolicy: {{ .Values.backend.fetchContainer.pullPolicy }}
47+
{{- if .Values.backend.proxy.enabled }}
48+
env:
49+
{{- toYaml .Values.backend.proxy.env | nindent 8 }}
50+
{{- end }}
51+
envFrom:
52+
- configMapRef:
53+
name: {{ include "cpnConsole.fullname" . }}-backend
54+
- secretRef:
55+
name: {{ include "cpnConsole.fullname" . }}-backend
56+
{{- if .Values.backend.envFrom }}
57+
{{- toYaml .Values.backend.envFrom | nindent 8 }}
58+
{{- end }}
59+
command:
60+
- sh
61+
- /script/fetch
62+
volumeMounts:
63+
- name: fetch-script
64+
mountPath: /script
65+
- name: plugins
66+
mountPath: /plugins
67+
{{- end }}
68+
{{- if .Values.backend.initContainers }}
69+
{{- tpl (toYaml .Values.backend.initContainers) . | nindent 8 }}
70+
{{- end }}
71+
{{- end }}
72+
containers:
73+
- name: backend
74+
securityContext:
75+
{{- toYaml .Values.backend.container.securityContext | nindent 12 }}
76+
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag | default .Chart.AppVersion }}"
77+
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
78+
{{- if .Values.backend.container.command }}
79+
command:
80+
{{- range .Values.backend.container.command }}
81+
- {{ . | quote }}
82+
{{- end }}
83+
{{- end }}
84+
{{- if .Values.backend.container.args }}
85+
args:
86+
{{- range .Values.backend.container.args }}
87+
- {{ . | quote }}
88+
{{- end }}
89+
{{- end }}
90+
ports:
91+
- containerPort: {{ .Values.backend.service.port }}
92+
protocol: TCP
93+
envFrom:
94+
- configMapRef:
95+
name: {{ include "cpnConsole.fullname" . }}-backend
96+
- secretRef:
97+
name: {{ include "cpnConsole.fullname" . }}-backend
98+
{{- if .Values.backend.envFrom }}
99+
{{- toYaml .Values.backend.envFrom | nindent 8 }}
100+
{{- end }}
101+
{{- if .Values.backend.startupProbe.enabled }}
102+
{{- if .Values.global.postgresql.cnpgSecretName }}
103+
env:
104+
- name: DB_URL
105+
valueFrom:
106+
secretKeyRef:
107+
name: {{ .Values.global.postgresql.cnpgSecretName }}
108+
key: uri
109+
{{- end }}
110+
startupProbe:
111+
httpGet:
112+
path: {{ .Values.backend.healthcheckPath }}
113+
port: {{ .Values.backend.container.port }}
114+
initialDelaySeconds: {{ .Values.backend.startupProbe.initialDelaySeconds }}
115+
successThreshold: {{ .Values.backend.startupProbe.successThreshold }}
116+
failureThreshold: {{ .Values.backend.startupProbe.failureThreshold }}
117+
periodSeconds: {{ .Values.backend.startupProbe.periodSeconds }}
118+
timeoutSeconds: {{ .Values.backend.startupProbe.timeoutSeconds }}
119+
{{- end }}
120+
{{- if .Values.backend.readinessProbe.enabled }}
121+
readinessProbe:
122+
httpGet:
123+
path: {{ .Values.backend.healthcheckPath }}
124+
port: {{ .Values.backend.container.port }}
125+
initialDelaySeconds: {{ .Values.backend.readinessProbe.initialDelaySeconds }}
126+
successThreshold: {{ .Values.backend.readinessProbe.successThreshold }}
127+
failureThreshold: {{ .Values.backend.readinessProbe.failureThreshold }}
128+
periodSeconds: {{ .Values.backend.readinessProbe.periodSeconds }}
129+
timeoutSeconds: {{ .Values.backend.readinessProbe.timeoutSeconds }}
130+
{{- end }}
131+
{{- if .Values.backend.livenessProbe.enabled }}
132+
livenessProbe:
133+
httpGet:
134+
path: {{ .Values.backend.healthcheckPath }}
135+
port: {{ .Values.backend.container.port }}
136+
initialDelaySeconds: {{ .Values.backend.livenessProbe.initialDelaySeconds }}
137+
successThreshold: {{ .Values.backend.livenessProbe.successThreshold }}
138+
failureThreshold: {{ .Values.backend.livenessProbe.failureThreshold }}
139+
periodSeconds: {{ .Values.backend.livenessProbe.periodSeconds }}
140+
timeoutSeconds: {{ .Values.backend.livenessProbe.timeoutSeconds }}
141+
{{- end }}
142+
{{- if .Values.backend.hostAliases }}
143+
hostAliases:
144+
{{- toYaml .Values.backend.hostAliases | nindent 8 }}
145+
{{- end }}
146+
resources:
147+
{{- toYaml .Values.backend.resources | nindent 10 }}
148+
volumeMounts:
149+
- name: config
150+
mountPath: /config
151+
{{- if .Values.backend.dbDataCm }}
152+
- name: imports
153+
mountPath: /app/dist/init/db/imports
154+
{{- end }}
155+
{{- if and .Values.backend.plugins (len .Values.backend.plugins) }}
156+
- name: plugins
157+
mountPath: /plugins
158+
{{- end }}
159+
{{- range $volumeMount := .Values.backend.extraVolumeMounts }}
160+
- name: {{ $volumeMount.name }}
161+
mountPath: {{ $volumeMount.mountPath }}
162+
{{- end }}
163+
{{- if .Values.backend.extraContainers }}
164+
{{- tpl (toYaml .Values.backend.extraContainers) . | nindent 8 }}
165+
{{- end }}
166+
{{- with .Values.backend.nodeSelector }}
167+
nodeSelector:
168+
{{- toYaml . | nindent 8 }}
169+
{{- end }}
170+
{{- with .Values.backend.affinity }}
171+
affinity:
172+
{{- toYaml . | nindent 8 }}
173+
{{- end }}
174+
{{- with .Values.backend.tolerations }}
175+
tolerations:
176+
{{- toYaml . | nindent 8 }}
177+
{{- end }}
178+
volumes:
179+
- name: config
180+
{{- if .Values.backend.extraCa.name }}
181+
projected:
182+
sources:
183+
- configMap:
184+
name: {{ .Values.backend.extraCa.name }}
185+
items:
186+
- key: {{ .Values.backend.extraCa.key }}
187+
path: {{ .Values.backend.extraCa.mountSubPath }}
188+
{{- end }}
189+
{{- if .Values.backend.dbDataCm }}
190+
- name: imports
191+
configMap:
192+
name: {{ .Values.backend.dbDataCm }}
193+
{{- end }}
194+
{{- if and .Values.backend.plugins (len .Values.backend.plugins) }}
195+
- name: plugins
196+
emptyDir: {}
197+
- name: fetch-script
198+
configMap:
199+
name: {{ include "cpnConsole.fullname" . }}-fetch-script
200+
{{- end }}
201+
{{- range $volume := .Values.backend.extraVolumes }}
202+
- name: {{ $volume.name }}
203+
{{- if eq $volume.type "hostPath" }}
204+
hostPath:
205+
path: {{ $volume.path }}
206+
{{- end }}
207+
{{- if eq $volume.type "configMap" }}
208+
configMap:
209+
name: {{ $volume.name }}
210+
{{- end }}
211+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.backend.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "cpnConsole.fullname" . }}-backend
6+
labels:
7+
{{- include "cpnConsole.backend.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "cpnConsole.fullname" . }}-backend
13+
minReplicas: {{ .Values.backend.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.backend.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.backend.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.backend.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.backend.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.backend.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.backend.plugins }}
2+
kind: ConfigMap
3+
apiVersion: v1
4+
metadata:
5+
name: {{ include "cpnConsole.fullname" . }}-fetch-script
6+
labels: {{- include "cpnConsole.backend.labels" . | nindent 4 }}
7+
data:
8+
fetch: |
9+
#!/bin/bash
10+
cd /tmp
11+
{{- range $i, $val := .Values.backend.plugins }}
12+
wget {{ $val }} -O {{ $i }}.zip;
13+
mkdir -p /plugins/{{ $i }}
14+
unzip -o {{ $i }}.zip -d /plugins/{{ $i }}
15+
{{- end }}
16+
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
kind: Secret
2+
apiVersion: v1
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-backend
5+
labels: {{- include "cpnConsole.backend.labels" . | nindent 4 }}
6+
data:
7+
SESSION_SECRET: {{ .Values.global.keycloak.sessionSecret | b64enc }}
8+
KEYCLOAK_CLIENT_SECRET: {{ .Values.global.keycloak.clientSecrets.backend | b64enc }}
9+
{{- if not .Values.global.postgresql.cnpgSecretName }}
10+
DB_URL: {{ include "cpnConsole.dbUrlValue" . | b64enc }}
11+
{{- end -}}
12+
{{- if .Values.global.secrets -}}
13+
{{- include "cpnConsole.secret" .Values.global | indent 2 }}
14+
{{- end -}}
15+
{{- if .Values.backend.secrets -}}
16+
{{- include "cpnConsole.secret" .Values.backend | indent 2 }}
17+
{{- end -}}

0 commit comments

Comments
 (0)