From 9edd9fffa7a7bcfd1c275a6c37a636c7b2a8c514 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Mon, 13 Nov 2023 18:08:19 +0200 Subject: [PATCH] add init templates and values --- .../community/dashy/ci/basic-values.yaml | 10 +++ .../community/dashy/ci/extra-values.yaml | 11 +++ .../community/dashy/templates/_dashy.tpl | 68 +++++++++++++++++++ .../dashy/templates/_persistence.tpl | 32 +++++++++ .../community/dashy/templates/_portal.tpl | 12 ++++ .../community/dashy/templates/_service.tpl | 15 ++++ .../community/dashy/templates/common.yaml | 11 +++ library/ix-dev/community/dashy/values.yaml | 27 ++++++++ 8 files changed, 186 insertions(+) create mode 100644 library/ix-dev/community/dashy/ci/basic-values.yaml create mode 100644 library/ix-dev/community/dashy/ci/extra-values.yaml create mode 100644 library/ix-dev/community/dashy/templates/_dashy.tpl create mode 100644 library/ix-dev/community/dashy/templates/_persistence.tpl create mode 100644 library/ix-dev/community/dashy/templates/_portal.tpl create mode 100644 library/ix-dev/community/dashy/templates/_service.tpl create mode 100644 library/ix-dev/community/dashy/templates/common.yaml create mode 100644 library/ix-dev/community/dashy/values.yaml diff --git a/library/ix-dev/community/dashy/ci/basic-values.yaml b/library/ix-dev/community/dashy/ci/basic-values.yaml new file mode 100644 index 0000000000..5d4fe5e5f7 --- /dev/null +++ b/library/ix-dev/community/dashy/ci/basic-values.yaml @@ -0,0 +1,10 @@ +dashyNetwork: + webPort: 31000 + +dashyRunAs: + user: 1000 + group: 1000 + +dashyStorage: + config: + type: pvc diff --git a/library/ix-dev/community/dashy/ci/extra-values.yaml b/library/ix-dev/community/dashy/ci/extra-values.yaml new file mode 100644 index 0000000000..c89307258e --- /dev/null +++ b/library/ix-dev/community/dashy/ci/extra-values.yaml @@ -0,0 +1,11 @@ +dashyNetwork: + webPort: 31000 + +dashyStorage: + config: + type: pvc + additionalStorages: + - type: pvc + mountPath: /data1 + - type: pvc + mountPath: /data2 diff --git a/library/ix-dev/community/dashy/templates/_dashy.tpl b/library/ix-dev/community/dashy/templates/_dashy.tpl new file mode 100644 index 0000000000..b5c8ce6760 --- /dev/null +++ b/library/ix-dev/community/dashy/templates/_dashy.tpl @@ -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 -}} diff --git a/library/ix-dev/community/dashy/templates/_persistence.tpl b/library/ix-dev/community/dashy/templates/_persistence.tpl new file mode 100644 index 0000000000..97fd73af0e --- /dev/null +++ b/library/ix-dev/community/dashy/templates/_persistence.tpl @@ -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 -}} diff --git a/library/ix-dev/community/dashy/templates/_portal.tpl b/library/ix-dev/community/dashy/templates/_portal.tpl new file mode 100644 index 0000000000..bcf8e5c19a --- /dev/null +++ b/library/ix-dev/community/dashy/templates/_portal.tpl @@ -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 -}} diff --git a/library/ix-dev/community/dashy/templates/_service.tpl b/library/ix-dev/community/dashy/templates/_service.tpl new file mode 100644 index 0000000000..c0d3c7f15e --- /dev/null +++ b/library/ix-dev/community/dashy/templates/_service.tpl @@ -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 -}} diff --git a/library/ix-dev/community/dashy/templates/common.yaml b/library/ix-dev/community/dashy/templates/common.yaml new file mode 100644 index 0000000000..5d246767c2 --- /dev/null +++ b/library/ix-dev/community/dashy/templates/common.yaml @@ -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" . -}} diff --git a/library/ix-dev/community/dashy/values.yaml b/library/ix-dev/community/dashy/values.yaml new file mode 100644 index 0000000000..0443e68c89 --- /dev/null +++ b/library/ix-dev/community/dashy/values.yaml @@ -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: []