add init templates and values

This commit is contained in:
Stavros kois
2023-11-13 18:08:19 +02:00
committed by Stavros Kois
parent f21a450701
commit 9edd9fffa7
8 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
dashyNetwork:
webPort: 31000
dashyRunAs:
user: 1000
group: 1000
dashyStorage:
config:
type: pvc

View File

@@ -0,0 +1,11 @@
dashyNetwork:
webPort: 31000
dashyStorage:
config:
type: pvc
additionalStorages:
- type: pvc
mountPath: /data1
- type: pvc
mountPath: /data2

View File

@@ -0,0 +1,68 @@
{{- define "dashy.workload" -}}
workload:
dashy:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.dashyNetwork.hostNetwork }}
containers:
dashy:
enabled: true
primary: true
imageSelector: image
securityContext:
runAsUser: {{ .Values.dashyRunAs.user }}
runAsGroup: {{ .Values.dashyRunAs.group }}
env:
NODE_ENV: production
IS_DOCKER: "true"
PORT: {{ .Values.dashyNetwork.webPort }}
{{ with .Values.dashyConfig.additionalEnvs }}
envList:
{{ range $env := . }}
- name: {{ $env.name }}
value: {{ $env.value }}
{{ end }}
{{ end }}
probes:
liveness:
enabled: true
type: exec
command:
- node
- /app/services/healthcheck
readiness:
enabled: true
type: exec
command:
- node
- /app/services/healthcheck
startup:
enabled: true
type: exec
command:
- node
- /app/services/healthcheck
initContainers:
init-config:
enabled: true
type: init
imageSelector: image
securityContext:
runAsUser: {{ .Values.dashyRunAs.user }}
runAsGroup: {{ .Values.dashyRunAs.group }}
command:
- /bin/sh
args:
- -c
- |
if [ -z "$(ls -A /data)" ]; then
echo "App directory is empty, copying default files"
cp -r /app/public/* /data/
exit 0
fi
echo "App directory is not empty, skipping copy"
exit 0
{{- end -}}

View File

@@ -0,0 +1,32 @@
{{- define "dashy.persistence" -}}
persistence:
config:
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.dashyStorage.config) | nindent 4 }}
targetSelector:
dashy:
dashy:
mountPath: /app/public
# Mount the same dir to different path on init container
# So we can check if `/data` is empty and copy the default
# from /app/public
init-config:
mountPath: /data
tmp:
enabled: true
type: emptyDir
targetSelector:
dashy:
dashy:
mountPath: /tmp
{{- range $idx, $storage := .Values.dashyStorage.additionalStorages }}
{{ printf "dashy-%v" (int $idx) }}:
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
targetSelector:
dashy:
dashy:
mountPath: {{ $storage.mountPath }}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,12 @@
{{- define "dashy.portal" -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: portal
data:
path: "/"
port: {{ .Values.dashyNetwork.webPort | quote }}
protocol: http
host: $node_ip
{{- end -}}

View File

@@ -0,0 +1,15 @@
{{- define "dashy.service" -}}
service:
dashy:
enabled: true
primary: true
type: NodePort
targetSelector: dashy
ports:
webui:
enabled: true
primary: true
port: {{ .Values.dashyNetwork.webPort }}
nodePort: {{ .Values.dashyNetwork.webPort }}
targetSelector: dashy
{{- end -}}

View File

@@ -0,0 +1,11 @@
{{- include "ix.v1.common.loader.init" . -}}
{{/* Merge the templates with Values */}}
{{- $_ := mustMergeOverwrite .Values (include "dashy.workload" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "dashy.service" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "dashy.persistence" $ | fromYaml) -}}
{{/* Create the configmap for portal manually*/}}
{{- include "dashy.portal" $ -}}
{{- include "ix.v1.common.loader.apply" . -}}

View File

@@ -0,0 +1,27 @@
image:
repository: lissy93/dashy
pullPolicy: IfNotPresent
tag: 2.1.1
resources:
limits:
cpu: 4000m
memory: 8Gi
dashyConfig:
additionalEnvs: []
dashyNetwork:
webPort: 31003
hostNetwork: false
dashyRunAs:
user: 568
group: 568
dashyStorage:
config:
type: ixVolume
ixVolumeConfig:
datasetName: config
additionalStorages: []