Browse Source

add templtes

Stavros kois 1 năm trước cách đây
mục cha
commit
2cfda45772

+ 14 - 0
library/ix-dev/community/vikunja/ci/basic-values.yaml

@@ -0,0 +1,14 @@
+vikunjaNetwork:
+  webPort: 31000
+
+vikunjaConfig:
+  url: http://localhost:31000
+  maxFileSize: 20
+
+vikunjaStorage:
+  data:
+    type: pvc
+  pgData:
+    type: pvc
+  pgBackup:
+    type: pvc

+ 101 - 0
library/ix-dev/community/vikunja/templates/_configuration.tpl

@@ -0,0 +1,101 @@
+{{- define "vikunja.configuration" -}}
+  {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
+
+  {{- $redisHost := (printf "%s-redis" $fullname) -}}
+  {{- $redisPass := randAlphaNum 32 -}}
+  {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-redis-creds" $fullname)) -}}
+    {{- $redisPass = ((index .data "REDIS_PASSWORD") | b64dec) -}}
+  {{- end -}}
+
+  {{- $secretKey := randAlphaNum 64 -}}
+  {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-vikunja" $fullname)) -}}
+    {{- $secretKey = ((index .data "VIKUNJA_SERVICE_JWTSECRET") | b64dec) -}}
+  {{- end -}}
+
+  {{- $dbHost := (printf "%s-postgres" $fullname) -}}
+  {{- $dbUser := "vikunja" -}}
+  {{- $dbName := "vikunja" -}}
+
+  {{- $dbPass := (randAlphaNum 32) -}}
+  {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-postgres-creds" $fullname)) -}}
+    {{- $dbPass = ((index .data "POSTGRES_PASSWORD") | b64dec) -}}
+  {{- end -}}
+
+  {{- $dbURL := (printf "postgres://%s:%s@%s:5432/%s?sslmode=disable" $dbUser $dbPass $dbHost $dbName) -}}
+  {{/* Temporary set dynamic db details on values,
+  so we can print them on the notes */}}
+  {{- $_ := set .Values "vikunjaDbPass" $dbPass -}}
+  {{- $_ := set .Values "vikunjaDbHost" $dbHost -}}
+
+secret:
+  postgres-creds:
+    enabled: true
+    data:
+      POSTGRES_USER: {{ $dbUser }}
+      POSTGRES_DB: {{ $dbName }}
+      POSTGRES_PASSWORD: {{ $dbPass }}
+      POSTGRES_HOST: {{ $dbHost }}
+      POSTGRES_URL: {{ $dbURL }}
+
+  redis-creds:
+    enabled: true
+    data:
+      ALLOW_EMPTY_PASSWORD: "no"
+      REDIS_PASSWORD: {{ $redisPass }}
+      REDIS_HOST: {{ $redisHost }}
+
+  vikunja-creds:
+    enabled: true
+    data:
+      VIKUNJA_SERVICE_JWTSECRET: {{ $secretKey }}
+      VIKUNJA_DATABASE_USER: {{ $dbUser }}
+      VIKUNJA_DATABASE_PASSWORD: {{ $dbPass }}
+      VIKUNJA_DATABASE_HOST: {{ $dbHost }}
+      VIKUNJA_DATABASE_DATABASE: {{ $dbName }}
+      VIKUNJA_REDIS_HOST: {{ printf "%s:6379" $redisHost }}
+      VIKUNJA_REDIS_PASSWORD: {{ $redisPass }}
+      VIKUNJA_REDIS_DB: "0"
+
+configmap:
+  vikunja-api:
+    enabled: true
+    data:
+      VIKUNJA_SERVICE_TIMEZONE: {{ .Values.TZ }}
+      VIKUNJA_SERVICE_INTERFACE:
+      VIKUNJA_REDIS_ENABLED: "true"
+      VIKUNJA_KEYVALUE_TYPE: redis
+      VIKUNJA_DATABASE_TYPE: postgres
+      VIKUNJA_SERVICE_INTERFACE: {{ printf ":%v" .Values.vikunjaPorts.api | quote }}
+      VIKUNJA_FILES_MAXSIZE: {{ printf "%vMB" .Values.vikunjaConfig.maxFileSize }}
+      # TODO: Check that this works
+      VIKUNJA_FILES_BASEPATH: /app/vikunja/files
+      # VIKUNJA_SERVICE_FRONTENDURL: TODO:
+
+  vikunja-frontend:
+    enabled: true
+    data:
+      VIKUNJA_HTTP_PORT: {{ .Values.vikunjaPorts.frontHttp | quote }}
+      VIKUNJA_HTTP2_PORT: {{ .Values.vikunjaPorts.frontHttp2 | quote }}
+
+  nginx-config:
+    enabled: true
+    data:
+      nginx-config: |
+        server {
+            listen {{ .Values.vikunjaNetwork.webPort }};
+
+            location /nginx-health {
+                return 200;
+            }
+
+            location / {
+                proxy_pass {{ printf "http://%s-frontend:%v" $fullname .Values.vikunjaPorts.frontHttp }};
+            }
+
+            location ~* ^/(api|dav|\.well-known)/ {
+                proxy_pass {{ printf "http://%s:%v" $fullname .Values.vikunjaPorts.api }};
+                client_max_body_size {{ printf "%vM" .Values.vikunjaConfig.maxFileSize }};
+            }
+
+        }
+{{- end -}}

+ 16 - 2
library/ix-dev/community/vikunja/templates/_persistence.tpl

@@ -7,6 +7,20 @@ persistence:
       vikunja:
         vikunja:
           mountPath: /tmp
+  nginxvar:
+    enabled: true
+    type: emptyDir
+    targetSelector:
+      vikunja-proxy:
+        vikunja-proxy:
+          mountPath: /var/cache/nginx
+  nginxrun:
+    enabled: true
+    type: emptyDir
+    targetSelector:
+      vikunja-proxy:
+        vikunja-proxy:
+          mountPath: /var/run
   data:
     enabled: true
     {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.vikunjaStorage.data) | nindent 4 }}
@@ -20,8 +34,8 @@ persistence:
     objectName: nginx-config
     defaultMode: "0600"
     targetSelector:
-      vikunja:
-        vikunja:
+      vikunja-proxy:
+        vikunja-proxy:
           mountPath: /etc/nginx/conf.d/default.conf
           subPath: nginx-config
           readOnly: true

+ 35 - 0
library/ix-dev/community/vikunja/templates/_portal.tpl

@@ -0,0 +1,35 @@
+{{- define "vikunja.portal" -}}
+  {{- $host := "$node_ip" -}}
+  {{- $port := "" -}}
+  {{- $protocol := "http" -}}
+  {{- if hasPrefix "https://" .Values.vikunjaConfig.url -}}
+    {{- $protocol = "https" -}}
+  {{- end -}}
+
+  {{- with .Values.vikunjaConfig.url -}} {{/* Trim protocol and trailing slash */}}
+    {{- $host = . | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/" -}}
+
+    {{- if contains ":" $host -}}
+      {{- $port = (split ":" $host)._1 -}}
+      {{- $host = (split ":" $host)._0 -}}
+    {{- end -}}
+
+    {{- if not $port -}}
+      {{- if eq $protocol "https" -}}
+        {{- $port = "443" -}}
+      {{- else -}}
+        {{- $port = "80" -}}
+      {{- end -}}
+    {{- end -}}
+  {{- end }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: portal
+data:
+  path: "/"
+  port: {{ $port | quote }}
+  protocol: {{ $protocol }}
+  host: {{ $host }}
+{{- end -}}

+ 1 - 1
library/ix-dev/community/vikunja/templates/_redis.tpl

@@ -1,4 +1,4 @@
-{{- define "rvikunja.redis" -}}
+{{- define "vikunja.redis" -}}
 workload:
 {{- include "ix.v1.common.app.redis" (dict  "secretName" "redis-creds"
                                             "resources" .Values.resources) | nindent 2 }}

+ 13 - 13
library/ix-dev/community/vikunja/templates/_service.tpl

@@ -1,17 +1,6 @@
 {{- define "vikunja.service" -}}
 service:
-  vikunja-proxy:
-    enabled: true
-    type: NodePort
-    targetSelector: vikunja-proxy
-    ports:
-      webui:
-        enabled: true
-        primary: true
-        port: {{ .Values.vikunjaNetwork.webPort }}
-        nodePort: {{ .Values.vikunjaNetwork.webPort }}
-        targetSelector: vikunja-proxy
-  vikunja-api:
+  vikunja:
     enabled: true
     primary: true
     type: ClusterIP
@@ -22,7 +11,18 @@ service:
         primary: true
         port: {{ .Values.vikunjaPorts.api }}
         targetSelector: vikunja-api
-  vikunja-frontend:
+  proxy:
+    enabled: true
+    type: NodePort
+    targetSelector: vikunja-proxy
+    ports:
+      webui:
+        enabled: true
+        primary: true
+        port: {{ .Values.vikunjaNetwork.webPort }}
+        nodePort: {{ .Values.vikunjaNetwork.webPort }}
+        targetSelector: vikunja-proxy
+  frontend:
     enabled: true
     type: ClusterIP
     targetSelector: vikunja-frontend

+ 57 - 0
library/ix-dev/community/vikunja/templates/_vikunja_api.tpl

@@ -0,0 +1,57 @@
+{{- define "vikunja.api" -}}
+workload:
+  vikunja-api:
+    enabled: true
+    primary: true
+    type: Deployment
+    podSpec:
+      hostNetwork: false
+      containers:
+        vikunja-api:
+          enabled: true
+          primary: true
+          imageSelector: image
+          securityContext:
+            runAsUser: 0
+            runAsGroup: 0
+            runAsNonRoot: false
+            readOnlyRootFilesystem: false
+            capabilities:
+              add:
+                - CHOWN
+                - SETGID
+                - SETUID
+          envFrom:
+            - secretRef:
+                name: vikunja-creds
+            - configMapRef:
+                name: vikunja-api
+          {{ with .Values.vikunjaConfig.additionalEnvs }}
+          envList:
+            {{ range $env := . }}
+            - name: {{ $env.name }}
+              value: {{ $env.value }}
+            {{ end }}
+          {{ end }}
+          probes:
+            liveness:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaPorts.api }}
+              path: /health
+            readiness:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaPorts.api }}
+              path: /health
+            startup:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaPorts.api }}
+              path: /health
+      initContainers:
+      {{- include "ix.v1.common.app.redisWait" (dict  "name" "01-redis-wait"
+                                                      "secretName" "redis-creds") | nindent 8 }}
+      {{- include "ix.v1.common.app.postgresWait" (dict "name" "02-postgres-wait"
+                                                        "secretName" "postgres-creds") | nindent 8 }}
+{{- end -}}

+ 41 - 0
library/ix-dev/community/vikunja/templates/_vikunja_frontend.tpl

@@ -0,0 +1,41 @@
+{{- define "vikunja.frontend" -}}
+{{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
+{{- $apiUrl := printf "http://%v:%v/health" $fullname .Values.vikunjaPorts.api }}
+workload:
+  vikunja-frontend:
+    enabled: true
+    type: Deployment
+    podSpec:
+      hostNetwork: false
+      containers:
+        vikunja-frontend:
+          enabled: true
+          primary: true
+          imageSelector: frontendImage
+          securityContext:
+            runAsUser: 101
+            runAsGroup: 101
+            # runAsNonRoot: false
+            readOnlyRootFilesystem: false
+          envFrom:
+            - configMapRef:
+                name: vikunja-frontend
+          probes:
+            liveness:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaPorts.frontHttp }}
+              path: /ready
+            readiness:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaPorts.frontHttp }}
+              path: /ready
+            startup:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaPorts.frontHttp }}
+              path: /ready
+      initContainers:
+      {{- include "vikunja.wait.init" (dict "url" $apiUrl) | indent 8 }}
+{{- end -}}

+ 36 - 0
library/ix-dev/community/vikunja/templates/_vikunja_nginx.tpl

@@ -0,0 +1,36 @@
+{{- define "vikunja.nginx" -}}
+{{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
+{{- $frontUrl := printf "http://%v-frontend:%v/ready" $fullname .Values.vikunjaPorts.frontHttp }}
+workload:
+  vikunja-proxy:
+    enabled: true
+    type: Deployment
+    podSpec:
+      hostNetwork: false
+      containers:
+        vikunja-proxy:
+          enabled: true
+          primary: true
+          imageSelector: nginxImage
+          securityContext:
+            runAsUser: 568
+            runAsGroup: 568
+          probes:
+            liveness:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaNetwork.webPort }}
+              path: /nginx-health
+            readiness:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaNetwork.webPort }}
+              path: /nginx-health
+            startup:
+              enabled: true
+              type: http
+              port: {{ .Values.vikunjaNetwork.webPort }}
+              path: /nginx-health
+      initContainers:
+      {{- include "vikunja.wait.init" (dict "url" $frontUrl) | indent 8 }}
+{{- end -}}

+ 17 - 0
library/ix-dev/community/vikunja/templates/_wait-url.tpl

@@ -0,0 +1,17 @@
+{{- define "vikunja.wait.init" -}}
+{{- $url := .url }}
+wait-url:
+  enabled: true
+  type: init
+  imageSelector: bashImage
+  command:
+    - /bin/ash
+    - -c
+    - |
+      echo "Pinging [{{ $url }}] until it is ready..."
+      until wget --spider --quiet "{{ $url }}"; do
+        echo "Waiting for [{{ $url }}] to be ready..."
+        sleep 2
+      done
+      echo "URL [{{ $url }}] is ready!"
+{{- end -}}

+ 16 - 0
library/ix-dev/community/vikunja/templates/common.yaml

@@ -0,0 +1,16 @@
+{{- include "ix.v1.common.loader.init" . -}}
+
+{{/* Merge the templates with Values */}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.persistence" $ | fromYaml) -}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.configuration" $ | fromYaml) -}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.service" $ | fromYaml) -}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.redis" $ | fromYaml) -}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.postgres" $ | fromYaml) -}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.nginx" $ | fromYaml) -}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.frontend" $ | fromYaml) -}}
+{{- $_ := mustMergeOverwrite .Values (include "vikunja.api" $ | fromYaml) -}}
+
+{{/* Create the configmap for portal manually*/}}
+{{- include "vikunja.portal" $ -}}
+
+{{- include "ix.v1.common.loader.apply" . -}}

+ 72 - 0
library/ix-dev/community/vikunja/values.yaml

@@ -0,0 +1,72 @@
+image:
+  repository: vikunja/api
+  pullPolicy: IfNotPresent
+  tag: 0.21.0
+frontendImage:
+  repository: vikunja/frontend
+  pullPolicy: IfNotPresent
+  tag: 0.21.0
+nginxImage:
+  repository: nginx
+  pullPolicy: IfNotPresent
+  tag: 1.25.3
+
+resources:
+  limits:
+    cpu: 4000m
+    memory: 8Gi
+
+# TODO: portal
+# TODO: certs?
+
+vikunjaConfig:
+  url: # TODO:
+  maxFileSize: 20
+  additionalEnvs: []
+
+vikunjaNetwork:
+  webPort: 31002
+
+vikunjaStorage:
+  additionalStorages: []
+  data:
+    type: ixVolume
+    ixVolumeConfig:
+      datasetName: data
+  pgData:
+    type: ixVolume
+    ixVolumeConfig:
+      datasetName: pgData
+  pgBackup:
+    type: ixVolume
+    ixVolumeConfig:
+      datasetName: pgBackup
+
+notes:
+  custom: |
+    Default credentials:
+      - Username: `demo@demo.demo`
+      - Password: `demo`
+
+    ## Database
+    You can connect to the database using the pgAdmin App from the catalog
+
+    <details>
+      <summary>Database Details</summary>
+
+      - Database: `vikunja`
+      - Username: `vikunja`
+      - Password: `{{ .Values.vikunjaDbPass }}`
+      - Host:     `{{ .Values.vikunjaDbHost }}.{{ .Release.Namespace }}.svc.cluster.local`
+      - Port:     `5432`
+
+    </details>
+    {{- $_ := unset .Values "vikunjaDbPass" }}
+    {{- $_ := unset .Values "vikunjaDbHost" }}
+
+# Not exposed to the user,
+# just used internally
+vikunjaPorts:
+  api: 3456
+  frontHttp: 5000
+  frontHttp2: 5001