Selaa lähdekoodia

add init templates and values

Stavros kois 1 vuosi sitten
vanhempi
commit
9edd9fffa7

+ 10 - 0
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

+ 11 - 0
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

+ 68 - 0
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 -}}

+ 32 - 0
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 -}}

+ 12 - 0
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 -}}

+ 15 - 0
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 -}}

+ 11 - 0
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" . -}}

+ 27 - 0
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: []