add admin backend stuff

This commit is contained in:
Maarten de Waard 2021-09-30 16:03:54 +02:00
parent 4087d1b0d3
commit 82abc9b73d
No known key found for this signature in database
GPG key ID: 1D3E893A657CC8DA
9 changed files with 362 additions and 261 deletions

View file

@ -2,7 +2,7 @@
{{/*
Create the name of the service account to use
*/}}
{{- define "adminFrontend.serviceAccountName" -}}
{{- define "adminPanel.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
@ -13,15 +13,15 @@ Create the name of the service account to use
{{/*
Return the proper Docker image registry secret names
*/}}
{{- define "adminFrontend.imagePullSecrets" -}}
{{- define "adminPanel.imagePullSecrets" -}}
{{ include "common.images.pullSecrets" (dict "images" (list .Values.image) "global" .Values.global) }}
{{- end -}}
{{/*
Return true if a secret object for Admin-frontend should be created
*/}}
{{- define "adminFrontend.createSecret" -}}
{{- if or (not .Values.adminFrontend.existingSecret) (and (not .Values.adminFrontend.smtp.existingSecret) .Values.adminFrontend.smtp.password .Values.adminFrontend.smtp.enabled) }}
{{- define "adminPanel.createSecret" -}}
{{- if or (not .Values.adminPanel.existingSecret) (and (not .Values.adminPanel.smtp.existingSecret) .Values.adminPanel.smtp.password .Values.adminPanel.smtp.enabled) }}
{{- true -}}
{{- end -}}
{{- end -}}
@ -29,30 +29,30 @@ Return true if a secret object for Admin-frontend should be created
{{/*
Return the Admin-frontend secret name
*/}}
{{- define "adminFrontend.secretName" -}}
{{- if .Values.adminFrontend.existingSecret }}
{{- printf "%s" .Values.adminFrontend.existingSecret -}}
{{- define "adminPanel.secretName" -}}
{{- if .Values.adminPanel.existingSecret }}
{{- printf "%s" .Values.adminPanel.existingSecret -}}
{{- else -}}
{{- printf "%s-adminFrontend" (include "common.names.fullname" .) -}}
{{- printf "%s-adminPanel" (include "common.names.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the Admin-frontend SMTP secret name
*/}}
{{- define "adminFrontend.smtp.secretName" -}}
{{- if .Values.adminFrontend.smtp.existingSecret }}
{{- printf "%s" .Values.adminFrontend.smtp.existingSecret -}}
{{- define "adminPanel.smtp.secretName" -}}
{{- if .Values.adminPanel.smtp.existingSecret }}
{{- printf "%s" .Values.adminPanel.smtp.existingSecret -}}
{{- else -}}
{{- printf "%s-adminFrontend" (include "common.names.fullname" .) -}}
{{- printf "%s-adminPanel" (include "common.names.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return true if Admin-frontend SMTP uses password authentication
*/}}
{{- define "adminFrontend.smtp.password.enabled" -}}
{{- if and (or .Values.adminFrontend.smtp.password .Values.adminFrontend.smtp.existingSecret) .Values.adminFrontend.smtp.enabled }}
{{- define "adminPanel.smtp.password.enabled" -}}
{{- if and (or .Values.adminPanel.smtp.password .Values.adminPanel.smtp.existingSecret) .Values.adminPanel.smtp.enabled }}
{{- true -}}
{{- end -}}
{{- end -}}
@ -61,7 +61,7 @@ Return true if Admin-frontend SMTP uses password authentication
Get the user defined LoadBalancerIP for this release
Note, returns 127.0.0.1 if using ClusterIP.
*/}}
{{- define "adminFrontend.serviceIP" -}}
{{- define "adminPanel.serviceIP" -}}
{{- if eq .Values.service.type "ClusterIP" -}}
127.0.0.1
{{- else -}}
@ -73,21 +73,27 @@ Note, returns 127.0.0.1 if using ClusterIP.
Gets the host to be used for this application.
If not using ClusterIP, or if a host or LoadBalancerIP is not defined, the value will be empty
*/}}
{{- define "adminFrontend.host" -}}
{{- $host := .Values.adminFrontend.host | default "" -}}
{{- default (include "adminFrontend.serviceIP" .) $host -}}
{{- define "adminPanel.host" -}}
{{- $host := .Values.adminPanel.host | default "" -}}
{{- default (include "adminPanel.serviceIP" .) $host -}}
{{- end -}}
{{/*
Return the proper Admin-frontend image name
*/}}
{{- define "adminFrontend.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{ include "common.images.image" (dict "imageRoot" .Values.adminFrontend.image "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper Admin-backend image name
*/}}
{{- define "adminBackend.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.adminBackend.image "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper Storage Class
*/}}
{{- define "adminFrontend.storageClass" -}}
{{- define "adminPanel.storageClass" -}}
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) -}}
{{- end -}}

View file

@ -11,22 +11,23 @@ metadata:
{{- end }}
data:
{{- $port := .Values.service.port | toString }}
REACT_APP_API_URL: {{ .Values.adminFrontend.reactAppApiUrl }}
REACT_APP_API_URL: {{ .Values.adminBackend.host }}{{ .Values.adminBackend.ApiUrl }}
EXTEND_ESLINT: {{ .Values.adminFrontend.extendEslint }}
ADMIN_FRONTEND_HOST: "{{ include "adminFrontend.host" . }}"
ADMIN_BACKEND_HOST: "{{ include "adminBackend.host" . }}"
# Probably needed in the future:
# ADMIN_FRONTEND_USERNAME: {{ .Values.adminFrontend.username | quote }}
# ADMIN_FRONTEND_EMAIL: {{ .Values.adminFrontend.email | quote }}
# {{- if .Values.adminFrontend.smtp.enabled }}
# ADMIN_FRONTEND_SMTP_HOST: {{ .Values.adminFrontend.smtp.host | quote }}
# ADMIN_FRONTEND_SMTP_PORT: {{ .Values.adminFrontend.smtp.port | quote }}
# {{- if .Values.adminFrontend.smtp.user }}
# ADMIN_FRONTEND_SMTP_USER: {{ .Values.adminFrontend.smtp.user | quote }}
# ADMIN_BACKEND_USERNAME: {{ .Values.adminBackend.username | quote }}
# ADMIN_BACKEND_EMAIL: {{ .Values.adminBackend.email | quote }}
# {{- if .Values.adminBackend.smtp.enabled }}
# ADMIN_BACKEND_SMTP_HOST: {{ .Values.adminBackend.smtp.host | quote }}
# ADMIN_BACKEND_SMTP_PORT: {{ .Values.adminBackend.smtp.port | quote }}
# {{- if .Values.adminBackend.smtp.user }}
# ADMIN_BACKEND_SMTP_USER: {{ .Values.adminBackend.smtp.user | quote }}
# {{- end }}
# {{- if .Values.adminFrontend.smtp.protocol }}
# ADMIN_FRONTEND_SMTP_PROTOCOL: {{ .Values.adminFrontend.smtp.protocol | quote }}
# {{- if .Values.adminBackend.smtp.protocol }}
# ADMIN_BACKEND_SMTP_PROTOCOL: {{ .Values.adminBackend.smtp.protocol | quote }}
# {{- end }}
# {{- if .Values.adminFrontend.smtp.auth }}
# ADMIN_FRONTEND_SMTP_AUTH: {{ .Values.adminFrontend.smtp.auth | quote }}
# {{- if .Values.adminBackend.smtp.auth }}
# ADMIN_BACKEND_SMTP_AUTH: {{ .Values.adminBackend.smtp.auth | quote }}
# {{- end }}
# {{- end }}

View file

@ -1,10 +1,10 @@
{{- if (include "adminFrontend.host" .) -}}
{{- if and (include "adminFrontend.host" .) (include "adminBackend.host" .) -}}
apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
component: adminFrontend
component: adminPanel
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
@ -15,14 +15,14 @@ spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
component: adminFrontend
component: adminPanel
{{- if .Values.updateStrategy }}
strategy: {{- toYaml .Values.updateStrategy | nindent 4 }}
{{- end }}
template:
metadata:
labels: {{- include "common.labels.standard" . | nindent 8 }}
component: adminFrontend
component: adminPanel
{{- if .Values.podLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
{{- end }}
@ -48,31 +48,12 @@ spec:
{{- if .Values.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "adminFrontend.serviceAccountName" . }}
serviceAccountName: {{ include "adminPanel.serviceAccountName" . }}
securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
{{- end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
- name: volume-permissions
image: {{ include "adminFrontend.image" . }}
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
command:
- sh
- -c
- |
mkdir -p "/bitnami/adminFrontend"
chown -R "adminFrontend:root" "/bitnami/adminFrontend"
securityContext:
runAsUser: 0
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
{{- end }}
volumeMounts:
- name: adminFrontend-data
mountPath: /bitnami/adminFrontend
{{- end }}
containers:
- name: adminFrontend
securityContext: {{- toYaml .Values.adminFrontend.containerSecurityContext | nindent 12 }}
@ -85,18 +66,6 @@ spec:
args: {{- include "common.tplvalues.render" (dict "value" .Values.adminFrontend.args "context" $) | nindent 12 }}
{{- end }}
env:
- name: ADMIN_FRONTEND_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "adminFrontend.secretName" . }}
key: adminFrontend-password
{{- if (include "adminFrontend.smtp.password.enabled" .) }}
- name: ADMIN_FRONTEND_SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "adminFrontend.smtp.secretName" . }}
key: smtp-password
{{- end }}
{{- if .Values.adminFrontend.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminFrontend.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
@ -151,6 +120,83 @@ spec:
{{- if .Values.adminFrontend.resources }}
resources: {{- toYaml .Values.adminFrontend.resources | nindent 12 }}
{{- end }}
- name: adminBackend
securityContext: {{- toYaml .Values.adminBackend.containerSecurityContext | nindent 12 }}
image: {{ template "adminBackend.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.adminBackend.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.adminBackend.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.args "context" $) | nindent 12 }}
{{- end }}
env:
- name: ADMIN_PANEL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "adminBackend.secretName" . }}
key: adminBackend-password
{{- if (include "adminBackend.smtp.password.enabled" .) }}
- name: ADMIN_PANEL_SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "adminBackend.smtp.secretName" . }}
key: smtp-password
{{- end }}
{{- if .Values.adminBackend.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ include "common.names.fullname" . }}
{{- if .Values.adminBackend.extraEnvVarsCM }}
- configMapRef:
name: {{ .Values.adminBackend.extraEnvVarsCM }}
{{- end }}
{{- if .Values.adminBackend.extraEnvVarsSecret }}
- secretRef:
name: {{ .Values.adminBackend.extraEnvVarsSecret }}
{{- end }}
ports:
- name: http
containerPort: 3000
protocol: TCP
{{- if .Values.adminBackend.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /srv/status
port: http
initialDelaySeconds: {{ .Values.adminBackend.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminBackend.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminBackend.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.adminBackend.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.adminBackend.livenessProbe.failureThreshold }}
{{- else if .Values.adminBackend.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.adminBackend.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /srv/status
port: http
initialDelaySeconds: {{ .Values.adminBackend.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminBackend.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminBackend.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.adminBackend.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.adminBackend.readinessProbe.failureThreshold }}
{{- else if .Values.adminBackend.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: adminBackend-data
mountPath: /bitnami/adminBackend
subPath: adminBackend
{{- if .Values.adminBackend.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.adminBackend.resources }}
resources: {{- toYaml .Values.adminBackend.resources | nindent 12 }}
{{- end }}
{{- if .Values.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
{{- end }}

View file

@ -1,5 +1,5 @@
# Disabled by default because the current admin panel does not need persistence
{{- if and (include "adminFrontend.host" .) .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
{{- if and (include "adminPanel.host" .) .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
@ -17,7 +17,7 @@ spec:
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{ include "adminFrontend.storageClass" . }}
{{ include "adminPanel.storageClass" . }}
{{- if .Values.persistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 4 }}
{{- end -}}

View file

@ -0,0 +1,23 @@
{{- if (include "adminPanel.createSecret" .) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "common.names.fullname" . }}-adminPanel
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- if and (.Values.adminBackend.password) (not .Values.adminBackend.existingSecret) }}
adminBackend-password: {{ .Values.adminBackend.password | b64enc | quote }}
{{- else if not .Values.adminBackend.existingSecret }}
adminBackend-password: {{ randAlphaNum 10 | b64enc | quote }}
{{- end }}
{{- if and (.Values.adminBackend.smtp.password) (.Values.adminBackend.smtp.enabled) (not .Values.adminBackend.smtp.existingSecret) }}
smtp-password: {{ .Values.adminBackend.smtp.password | b64enc | quote }}
{{- end }}
{{- end }}

View file

@ -1,23 +0,0 @@
{{- if (include "adminFrontend.createSecret" .) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "common.names.fullname" . }}-adminFrontend
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- if and (.Values.adminFrontend.password) (not .Values.adminFrontend.existingSecret) }}
adminFrontend-password: {{ .Values.adminFrontend.password | b64enc | quote }}
{{- else if not .Values.adminFrontend.existingSecret }}
adminFrontend-password: {{ randAlphaNum 10 | b64enc | quote }}
{{- end }}
{{- if and (.Values.adminFrontend.smtp.password) (.Values.adminFrontend.smtp.enabled) (not .Values.adminFrontend.smtp.existingSecret) }}
smtp-password: {{ .Values.adminFrontend.smtp.password | b64enc | quote }}
{{- end }}
{{- end }}

View file

@ -2,7 +2,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "adminFrontend.serviceAccountName" . }}
name: {{ include "adminPanel.serviceAccountName" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}