version with working front-end

This commit is contained in:
Maarten de Waard 2021-10-04 13:53:13 +02:00
parent 82abc9b73d
commit e15ac52be7
No known key found for this signature in database
GPG key ID: 1D3E893A657CC8DA
12 changed files with 266 additions and 135 deletions

View file

@ -20,39 +20,39 @@ Return the proper Docker image registry secret names
{{/*
Return true if a secret object for Admin-frontend should be created
*/}}
{{- define "adminPanel.createSecret" -}}
{{- if or (not .Values.adminPanel.existingSecret) (and (not .Values.adminPanel.smtp.existingSecret) .Values.adminPanel.smtp.password .Values.adminPanel.smtp.enabled) }}
{{- define "adminBackend.createSecret" -}}
{{- if or (not .Values.adminBackend.existingSecret) (and (not .Values.adminBackend.smtp.existingSecret) .Values.adminBackend.smtp.password .Values.adminBackend.smtp.enabled) }}
{{- true -}}
{{- end -}}
{{- end -}}
{{/*
Return the Admin-frontend secret name
Return the Admin-backend secret name
*/}}
{{- define "adminPanel.secretName" -}}
{{- if .Values.adminPanel.existingSecret }}
{{- printf "%s" .Values.adminPanel.existingSecret -}}
{{- define "adminBackend.secretName" -}}
{{- if .Values.adminBackend.existingSecret }}
{{- printf "%s" .Values.adminBackend.existingSecret -}}
{{- else -}}
{{- printf "%s-adminPanel" (include "common.names.fullname" .) -}}
{{- printf "%s-admin-backend" (include "common.names.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the Admin-frontend SMTP secret name
Return the Admin-backend SMTP secret name
*/}}
{{- define "adminPanel.smtp.secretName" -}}
{{- if .Values.adminPanel.smtp.existingSecret }}
{{- printf "%s" .Values.adminPanel.smtp.existingSecret -}}
{{- define "adminBackend.smtp.secretName" -}}
{{- if .Values.adminBackend.smtp.existingSecret }}
{{- printf "%s" .Values.adminBackend.smtp.existingSecret -}}
{{- else -}}
{{- printf "%s-adminPanel" (include "common.names.fullname" .) -}}
{{- printf "%s-admin-backend" (include "common.names.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return true if Admin-frontend SMTP uses password authentication
Return true if Admin-backend SMTP uses password authentication
*/}}
{{- define "adminPanel.smtp.password.enabled" -}}
{{- if and (or .Values.adminPanel.smtp.password .Values.adminPanel.smtp.existingSecret) .Values.adminPanel.smtp.enabled }}
{{- define "adminBackend.smtp.password.enabled" -}}
{{- if and (or .Values.adminBackend.smtp.password .Values.adminBackend.smtp.existingSecret) .Values.adminBackend.smtp.enabled }}
{{- true -}}
{{- end -}}
{{- end -}}
@ -61,11 +61,11 @@ 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 "adminPanel.serviceIP" -}}
{{- if eq .Values.service.type "ClusterIP" -}}
{{- define "adminFrontend.serviceIP" -}}
{{- if eq .Values.adminFrontend.service.type "ClusterIP" -}}
127.0.0.1
{{- else -}}
{{- .Values.service.loadBalancerIP | default "" -}}
{{- .Values.adminFrontend.service.loadBalancerIP | default "" -}}
{{- end -}}
{{- end -}}
@ -73,9 +73,44 @@ 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 "adminPanel.host" -}}
{{- $host := .Values.adminPanel.host | default "" -}}
{{- default (include "adminPanel.serviceIP" .) $host -}}
{{- define "adminFrontend.host" -}}
{{- $host := .Values.adminFrontend.host | default "" -}}
{{- default (include "adminFrontend.serviceIP" .) $host -}}
{{- end -}}
{{/*
Service name for the backend service
*/}}
{{- define "adminBackend.serviceName" -}}
{{ include "common.names.fullname" . }}-backend
{{- end -}}
{{/*
Service name for the frontend service
*/}}
{{- define "adminFrontend.serviceName" -}}
{{ include "common.names.fullname" . }}-frontend
{{- end -}}
{{/*
Get the user defined LoadBalancerIP for this release
Note, returns 127.0.0.1 if using ClusterIP.
*/}}
{{- define "adminBackend.serviceIP" -}}
{{- if eq .Values.adminBackend.service.type "ClusterIP" -}}
127.0.0.1
{{- else -}}
{{- .Values.adminBackend.service.loadBalancerIP | default "" -}}
{{- end -}}
{{- end -}}
{{/*
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 "adminBackend.host" -}}
{{- $host := .Values.adminBackend.host | default "" -}}
{{- default (include "adminBackend.serviceIP" .) $host -}}
{{- end -}}
{{/*

View file

@ -0,0 +1,42 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "adminBackend.serviceName" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if or .Values.adminBackend.service.annotations .Values.commonAnnotations}}
annotations:
{{- if .Values.adminBackend.service.annotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.service.annotations "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.adminBackend.service.type }}
{{- if (or (eq .Values.adminBackend.service.type "LoadBalancer") (eq .Values.adminBackend.service.type "NodePort")) }}
externalTrafficPolicy: {{ .Values.adminBackend.service.externalTrafficPolicy | quote }}
{{- end }}
{{- if (and (eq .Values.adminBackend.service.type "LoadBalancer") (not (empty .Values.adminBackend.service.loadBalancerIP))) }}
loadBalancerIP: {{ .Values.adminBackend.service.loadBalancerIP }}
{{- end }}
{{- if (and (eq .Values.adminBackend.service.type "LoadBalancer") .Values.adminBackend.service.loadBalancerSourceRanges) }}
loadBalancerSourceRanges:
{{ toYaml .Values.adminBackend.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports:
- name: http
port: {{ .Values.adminBackend.service.port }}
targetPort: backend-http
{{- if (and (or (eq .Values.adminBackend.service.type "NodePort") (eq .Values.adminBackend.service.type "LoadBalancer")) (not (empty .Values.adminBackend.service.nodePorts.http))) }}
nodePort: {{ .Values.adminBackend.service.nodePorts.http }}
{{- else if eq .Values.adminBackend.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if .Values.adminBackend.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminBackend.service.extraPorts "context" $) | nindent 4 }}
{{- end }}
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}

View file

@ -10,9 +10,8 @@ metadata:
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
{{- $port := .Values.service.port | toString }}
REACT_APP_API_URL: {{ .Values.adminBackend.host }}{{ .Values.adminBackend.ApiUrl }}
EXTEND_ESLINT: {{ .Values.adminFrontend.extendEslint }}
REACT_APP_API_URL: "{{ include "adminBackend.serviceName" .}}"
EXTEND_ESLINT: "{{ .Values.adminFrontend.extendEslint }}"
ADMIN_FRONTEND_HOST: "{{ include "adminFrontend.host" . }}"
ADMIN_BACKEND_HOST: "{{ include "adminBackend.host" . }}"
# Probably needed in the future:

View file

@ -1,4 +1,4 @@
{{- if and (include "adminFrontend.host" .) (include "adminBackend.host" .) -}}
{{- if include "adminFrontend.host" . -}}
apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
@ -30,7 +30,7 @@ spec:
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
{{- end }}
spec:
{{- include "adminFrontend.imagePullSecrets" . | nindent 6 }}
{{- include "adminPanel.imagePullSecrets" . | nindent 6 }}
{{- if .Values.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
{{- end }}
@ -55,7 +55,7 @@ spec:
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
{{- end }}
containers:
- name: adminFrontend
- name: admin-frontend
securityContext: {{- toYaml .Values.adminFrontend.containerSecurityContext | nindent 12 }}
image: {{ template "adminFrontend.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
@ -81,14 +81,14 @@ spec:
name: {{ .Values.adminFrontend.extraEnvVarsSecret }}
{{- end }}
ports:
- name: http
containerPort: 3000
- name: frontend-http
containerPort: 80
protocol: TCP
{{- if .Values.adminFrontend.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /srv/status
port: http
port: frontend-http
initialDelaySeconds: {{ .Values.adminFrontend.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminFrontend.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminFrontend.livenessProbe.timeoutSeconds }}
@ -101,7 +101,7 @@ spec:
readinessProbe:
httpGet:
path: /srv/status
port: http
port: frontend-http
initialDelaySeconds: {{ .Values.adminFrontend.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminFrontend.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminFrontend.readinessProbe.timeoutSeconds }}
@ -111,16 +111,13 @@ spec:
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.adminFrontend.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: adminFrontend-data
mountPath: /bitnami/adminFrontend
subPath: adminFrontend
{{- if .Values.adminFrontend.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminFrontend.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.adminFrontend.resources }}
resources: {{- toYaml .Values.adminFrontend.resources | nindent 12 }}
{{- end }}
- name: adminBackend
- name: admin-backend
securityContext: {{- toYaml .Values.adminBackend.containerSecurityContext | nindent 12 }}
image: {{ template "adminBackend.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
@ -158,14 +155,14 @@ spec:
name: {{ .Values.adminBackend.extraEnvVarsSecret }}
{{- end }}
ports:
- name: http
containerPort: 3000
- name: backend-http
containerPort: 5000
protocol: TCP
{{- if .Values.adminBackend.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /srv/status
port: http
port: backend-http
initialDelaySeconds: {{ .Values.adminBackend.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminBackend.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminBackend.livenessProbe.timeoutSeconds }}
@ -178,7 +175,7 @@ spec:
readinessProbe:
httpGet:
path: /srv/status
port: http
port: backend-http
initialDelaySeconds: {{ .Values.adminBackend.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.adminBackend.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.adminBackend.readinessProbe.timeoutSeconds }}
@ -188,9 +185,6 @@ spec:
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 }}

View file

@ -0,0 +1,42 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "adminFrontend.serviceName" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if or .Values.adminFrontend.service.annotations .Values.commonAnnotations}}
annotations:
{{- if .Values.adminFrontend.service.annotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminFrontend.service.annotations "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.adminFrontend.service.type }}
{{- if (or (eq .Values.adminFrontend.service.type "LoadBalancer") (eq .Values.adminFrontend.service.type "NodePort")) }}
externalTrafficPolicy: {{ .Values.adminFrontend.service.externalTrafficPolicy | quote }}
{{- end }}
{{- if (and (eq .Values.adminFrontend.service.type "LoadBalancer") (not (empty .Values.adminFrontend.service.loadBalancerIP))) }}
loadBalancerIP: {{ .Values.adminFrontend.service.loadBalancerIP }}
{{- end }}
{{- if (and (eq .Values.adminFrontend.service.type "LoadBalancer") .Values.adminFrontend.service.loadBalancerSourceRanges) }}
loadBalancerSourceRanges:
{{ toYaml .Values.adminFrontend.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports:
- name: http
port: {{ .Values.adminFrontend.service.port }}
targetPort: frontend-http
{{- if (and (or (eq .Values.adminFrontend.service.type "NodePort") (eq .Values.adminFrontend.service.type "LoadBalancer")) (not (empty .Values.adminFrontend.service.nodePorts.http))) }}
nodePort: {{ .Values.adminFrontend.service.nodePorts.http }}
{{- else if eq .Values.adminFrontend.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if .Values.adminFrontend.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.adminFrontend.service.extraPorts "context" $) | nindent 4 }}
{{- end }}
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}

View file

@ -40,7 +40,7 @@ spec:
{{- if eq "true" (include "common.ingress.supportsPathType" .) }}
pathType: {{ .Values.ingress.pathType }}
{{- end }}
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" .) "servicePort" "http" "context" $) | nindent 14 }}
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "adminFrontend.serviceName" .) "servicePort" "frontend-http" "context" $) | nindent 14 }}
{{- end }}
{{- range .Values.ingress.extraHosts }}
- host: {{ .name }}
@ -50,6 +50,6 @@ spec:
{{- if eq "true" (include "common.ingress.supportsPathType" $) }}
pathType: {{ default "ImplementationSpecific" .pathType }}
{{- end }}
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" $) "servicePort" "http" "context" $) | nindent 14 }}
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "adminFrontend.serviceName" $) "servicePort" "frontend-http" "context" $) | nindent 14 }}
{{- end }}
{{- end }}

View file

@ -1,5 +1,5 @@
# Disabled by default because the current admin panel does not need persistence
{{- if and (include "adminPanel.host" .) .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
{{- if and (include "adminFrontend.host" .) .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:

View file

@ -1,8 +1,8 @@
{{- if (include "adminPanel.createSecret" .) }}
{{- if (include "adminBackend.createSecret" .) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "common.names.fullname" . }}-adminPanel
name: {{ include "adminBackend.secretName" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}

View file

@ -1,42 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.names.fullname" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if or .Values.service.annotations .Values.commonAnnotations}}
annotations:
{{- if .Values.service.annotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.service.annotations "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
{{- end }}
{{- if (and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP))) }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if (and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges) }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
{{- if (and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http))) }}
nodePort: {{ .Values.service.nodePorts.http }}
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if .Values.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
{{- end }}
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}