diff --git a/library/ix-dev/community/castopod/Chart.lock b/library/ix-dev/community/castopod/Chart.lock new file mode 100644 index 0000000000..b4cb622f48 --- /dev/null +++ b/library/ix-dev/community/castopod/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: common + repository: file://../../../common + version: 1.1.1 +digest: sha256:a7dbe3e4d42dbcd4325776e5e01a1d630c7f185f79e7ebf22b1b9cc80f56eed7 +generated: "2023-10-02T16:38:49.597098778+03:00" diff --git a/library/ix-dev/community/castopod/Chart.yaml b/library/ix-dev/community/castopod/Chart.yaml new file mode 100644 index 0000000000..9ea7a353e1 --- /dev/null +++ b/library/ix-dev/community/castopod/Chart.yaml @@ -0,0 +1,25 @@ +name: castopod +description: Castopod is an open-source hosting platform made for podcasters who want engage and interact with their audience. +annotations: + title: Castopod +type: application +version: 1.0.0 +apiVersion: v2 +appVersion: 1.6.5 +kubeVersion: '>=1.16.0-0' +maintainers: + - name: truenas + url: https://www.truenas.com/ + email: dev@ixsystems.com +dependencies: + - name: common + repository: file://../../../common + version: 1.1.1 +home: https://castopod.org +icon: https://docs.castopod.org/images/castopod-logo-inline.svg +sources: + - https://hub.docker.com/r/castopod/castopod + - https://github.com/truenas/charts/tree/master/community/castopod + - https://code.castopod.org/adaures/castopod +keywords: + - podcast diff --git a/library/ix-dev/community/castopod/README.md b/library/ix-dev/community/castopod/README.md new file mode 100644 index 0000000000..df0ef2734f --- /dev/null +++ b/library/ix-dev/community/castopod/README.md @@ -0,0 +1,3 @@ +# Castopod + +[Castopod](https://castopod.org) is an open-source hosting platform made for podcasters who want engage and interact with their audience. diff --git a/library/ix-dev/community/castopod/app-readme.md b/library/ix-dev/community/castopod/app-readme.md new file mode 100644 index 0000000000..df0ef2734f --- /dev/null +++ b/library/ix-dev/community/castopod/app-readme.md @@ -0,0 +1,3 @@ +# Castopod + +[Castopod](https://castopod.org) is an open-source hosting platform made for podcasters who want engage and interact with their audience. diff --git a/library/ix-dev/community/castopod/charts/common-1.1.1.tgz b/library/ix-dev/community/castopod/charts/common-1.1.1.tgz new file mode 100644 index 0000000000..7e717968ec Binary files /dev/null and b/library/ix-dev/community/castopod/charts/common-1.1.1.tgz differ diff --git a/library/ix-dev/community/castopod/ci/2fa-values.yaml b/library/ix-dev/community/castopod/ci/2fa-values.yaml new file mode 100644 index 0000000000..fa2d8e108b --- /dev/null +++ b/library/ix-dev/community/castopod/ci/2fa-values.yaml @@ -0,0 +1,17 @@ +castopodConfig: + baseUrl: http://localhost:31000 + enable2fa: true + +castopodNetwork: + webPort: 31000 + +castopodStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/data + mariadbData: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbData + mariadbBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbBackup diff --git a/library/ix-dev/community/castopod/ci/basic-values.yaml b/library/ix-dev/community/castopod/ci/basic-values.yaml new file mode 100644 index 0000000000..0e988852c7 --- /dev/null +++ b/library/ix-dev/community/castopod/ci/basic-values.yaml @@ -0,0 +1,16 @@ +castopodConfig: + baseUrl: http://localhost:31000 + +castopodNetwork: + webPort: 31000 + +castopodStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/data + mariadbData: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbData + mariadbBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbBackup diff --git a/library/ix-dev/community/castopod/ci/extra-values.yaml b/library/ix-dev/community/castopod/ci/extra-values.yaml new file mode 100644 index 0000000000..eaea090c01 --- /dev/null +++ b/library/ix-dev/community/castopod/ci/extra-values.yaml @@ -0,0 +1,23 @@ +castopodConfig: + baseUrl: http://localhost:31000 + +castopodNetwork: + webPort: 31000 + +castopodStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/data + mariadbData: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbData + mariadbBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbBackup + additionalStorages: + - type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/data1 + mountPath: /data1 + - type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/data2 + mountPath: /data2 diff --git a/library/ix-dev/community/castopod/ci/https-redirect-values.yaml b/library/ix-dev/community/castopod/ci/https-redirect-values.yaml new file mode 100644 index 0000000000..480df6d36e --- /dev/null +++ b/library/ix-dev/community/castopod/ci/https-redirect-values.yaml @@ -0,0 +1,18 @@ +castopodConfig: + baseUrl: http://localhost:31000 + disableHttpsRedirect: false + enable2fa: true + +castopodNetwork: + webPort: 31000 + +castopodStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/data + mariadbData: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbData + mariadbBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbBackup diff --git a/library/ix-dev/community/castopod/item.yaml b/library/ix-dev/community/castopod/item.yaml new file mode 100644 index 0000000000..b92a8c6989 --- /dev/null +++ b/library/ix-dev/community/castopod/item.yaml @@ -0,0 +1,7 @@ +icon_url: https://docs.castopod.org/images/castopod-logo-inline.svg +categories: + - media +screenshots: + - https://castopod.org/_astro/castopod-activity-screen.71de6d2e.webp +tags: + - podcast diff --git a/library/ix-dev/community/castopod/metadata.yaml b/library/ix-dev/community/castopod/metadata.yaml new file mode 100644 index 0000000000..06f61373a4 --- /dev/null +++ b/library/ix-dev/community/castopod/metadata.yaml @@ -0,0 +1,18 @@ +runAsContext: + - userName: root + groupName: root + gid: 0 + uid: 0 + description: Castopod run as root user +capabilities: + - name: CHOWN + description: Castopod is able to chown files. + - name: DAC_OVERRIDE + description: Castopod is able to bypass permission checks. + - name: FOWNER + description: Castopod is able bypass permission checks for it's sub-processes. + - name: SETGID + description: Castopod is able to set group ID for it's sub-processes. + - name: SETUID + description: Castopod is able to set user ID for it's sub-processes. +hostMounts: [] diff --git a/library/ix-dev/community/castopod/questions.yaml b/library/ix-dev/community/castopod/questions.yaml new file mode 100644 index 0000000000..03f53ca883 --- /dev/null +++ b/library/ix-dev/community/castopod/questions.yaml @@ -0,0 +1,332 @@ +groups: + - name: Castopod Configuration + description: Configure Castopod + - name: Network Configuration + description: Configure Network for Castopod + - name: Storage Configuration + description: Configure Storage for Castopod + - name: Resources Configuration + description: Configure Resources for Castopod + +portals: + web_portal: + protocols: + - "$kubernetes-resource_configmap_portal_protocol" + host: + - "$kubernetes-resource_configmap_portal_host" + ports: + - "$kubernetes-resource_configmap_portal_port" + path: "$kubernetes-resource_configmap_portal_path" + admin: + protocols: + - "$kubernetes-resource_configmap_portal_protocol" + host: + - "$kubernetes-resource_configmap_portal_host" + ports: + - "$kubernetes-resource_configmap_portal_port" + path: "$kubernetes-resource_configmap_portal_admin" + +questions: + - variable: castopodConfig + label: "" + group: Castopod Configuration + schema: + type: dict + attrs: + - variable: baseUrl + label: Base URL + description: | + The base URL for Castopod.
+ Example: http://your.server.ip:30085 + schema: + type: uri + required: true + default: "" + - variable: webTimeout + label: Web Timeout + description: The timeout for Castopod requests in seconds. + schema: + type: int + required: true + default: 900 + min: 1 + - variable: webMaxBodySize + label: Web Max Body Size + description: The maximum body size for Castopod requests in megabytes. + schema: + type: int + required: true + default: 512 + min: 1 + - variable: phpMemoryLimit + label: PHP Memory Limit + description: The PHP memory limit for Castopod. + schema: + type: int + required: true + default: 512 + min: 1 + - variable: enable2fa + label: Enable 2FA + description: Enable 2FA for Castopod. + schema: + type: boolean + default: false + - variable: disableHttpsRedirect + label: Disable HTTPS Redirect + description: | + Disable HTTPS redirect for Castopod.
+ This is useful if you are using a reverse proxy with HTTPS. + schema: + type: boolean + default: true + - variable: additionalEnvs + label: Additional Environment Variables + description: Configure additional environment variables for Castopod. + schema: + type: list + default: [] + items: + - variable: env + label: Environment Variable + schema: + type: dict + attrs: + - variable: name + label: Name + schema: + type: string + required: true + - variable: value + label: Value + schema: + type: string + required: true + + - variable: castopodNetwork + label: "" + group: Network Configuration + schema: + type: dict + attrs: + - variable: webPort + label: Web Port + description: The port for the Castopod WebUI. + schema: + type: int + default: 30085 + min: 9000 + max: 65535 + required: true + + - variable: castopodStorage + label: "" + group: Storage Configuration + schema: + type: dict + attrs: + - variable: data + label: Castopod Data Storage + description: The path to store Castopod data. + schema: + type: dict + attrs: + - variable: type + label: Type + description: | + ixVolume: Is dataset created automatically by the system.
+ Host Path: Is a path that already exists on the system. + schema: + type: string + required: true + default: ixVolume + enum: + - value: hostPath + description: Host Path (Path that already exists on the system) + - value: ixVolume + description: ixVolume (Dataset created automatically by the system) + - variable: datasetName + label: Dataset Name + schema: + type: string + show_if: [["type", "=", "ixVolume"]] + required: true + hidden: true + immutable: true + default: "data" + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + - variable: mariadbData + label: Castopod MariaDB Data Storage + description: The path to store Castopod MariaDB Data. + schema: + type: dict + attrs: + - variable: type + label: Type + description: | + ixVolume: Is dataset created automatically by the system.
+ Host Path: Is a path that already exists on the system. + schema: + type: string + required: true + default: ixVolume + enum: + - value: hostPath + description: Host Path (Path that already exists on the system) + - value: ixVolume + description: ixVolume (Dataset created automatically by the system) + - variable: datasetName + label: Dataset Name + schema: + type: string + show_if: [["type", "=", "ixVolume"]] + required: true + hidden: true + immutable: true + default: mariadbData + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + - variable: mariadbBackup + label: Castopod MariaDB Backup Storage + description: The path to store Castopod MariaDB Backup. + schema: + type: dict + attrs: + - variable: type + label: Type + description: | + ixVolume: Is dataset created automatically by the system.
+ Host Path: Is a path that already exists on the system. + schema: + type: string + required: true + default: ixVolume + enum: + - value: hostPath + description: Host Path (Path that already exists on the system) + - value: ixVolume + description: ixVolume (Dataset created automatically by the system) + - variable: datasetName + label: Dataset Name + schema: + type: string + show_if: [["type", "=", "ixVolume"]] + required: true + hidden: true + immutable: true + default: mariadbBackup + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + - variable: additionalStorages + label: Additional Storage + description: Additional storage for Castopod. + schema: + type: list + default: [] + items: + - variable: storageEntry + label: Storage Entry + schema: + type: dict + attrs: + - variable: type + label: Type + description: | + ixVolume: Is dataset created automatically by the system.
+ Host Path: Is a path that already exists on the system. + schema: + type: string + required: true + default: "ixVolume" + enum: + - value: "hostPath" + description: Host Path (Path that already exists on the system) + - value: "ixVolume" + description: ixVolume (Dataset created automatically by the system) + - variable: mountPath + label: Mount Path + description: The path inside the container to mount the storage. + schema: + type: path + required: true + - variable: hostPath + label: Host Path + description: The host path to use for storage. + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + required: true + - variable: datasetName + label: Dataset Name + description: The name of the dataset to use for storage. + schema: + type: string + show_if: [["type", "=", "ixVolume"]] + required: true + immutable: true + default: "storage_entry" + $ref: + - "normalize/ixVolume" + + - variable: resources + label: "" + group: Resources Configuration + schema: + type: dict + attrs: + - variable: limits + label: Limits + schema: + type: dict + attrs: + - variable: cpu + label: CPU + description: CPU limit for Castopod. + schema: + type: string + max_length: 6 + valid_chars: '^(0\.[1-9]|[1-9][0-9]*)(\.[0-9]|m?)$' + valid_chars_error: | + Valid CPU limit formats are
+ - Plain Integer - eg. 1
+ - Float - eg. 0.5
+ - Milicpu - eg. 500m + default: "4000m" + required: true + - variable: memory + label: Memory + description: Memory limit for Castopod. + schema: + type: string + max_length: 12 + valid_chars: '^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$' + valid_chars_error: | + Valid Memory limit formats are
+ - Suffixed with E/P/T/G/M/K - eg. 1G
+ - Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi
+ - Plain Integer in bytes - eg. 1024
+ - Exponent - eg. 134e6 + default: "8Gi" + required: true diff --git a/library/ix-dev/community/castopod/templates/NOTES.txt b/library/ix-dev/community/castopod/templates/NOTES.txt new file mode 100644 index 0000000000..ba4e01146c --- /dev/null +++ b/library/ix-dev/community/castopod/templates/NOTES.txt @@ -0,0 +1 @@ +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/community/castopod/templates/_castopod.tpl b/library/ix-dev/community/castopod/templates/_castopod.tpl new file mode 100644 index 0000000000..77a317dec1 --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_castopod.tpl @@ -0,0 +1,56 @@ +{{- define "castopod.workload" -}} +workload: + castopod: + enabled: true + primary: true + type: Deployment + podSpec: + hostNetwork: false + containers: + castopod: + enabled: true + primary: true + imageSelector: image + securityContext: + runAsUser: 0 + runAsGroup: 0 + runAsNonRoot: false + readOnlyRootFilesystem: false + capabilities: + add: + - CHOWN + - DAC_OVERRIDE + - FOWNER + - SETGID + - SETUID + envFrom: + - secretRef: + name: castopod-creds + - configMapRef: + name: castopod-config + {{ with .Values.castopodConfig.additionalEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + liveness: + enabled: true + type: tcp + port: 9000 + readiness: + enabled: true + type: tcp + port: 9000 + startup: + enabled: true + type: tcp + port: 9000 + initContainers: + {{- include "ix.v1.common.app.redisWait" (dict "name" "01-redis-wait" + "secretName" "redis-creds") | nindent 8 }} + {{- include "ix.v1.common.app.mariadbWait" (dict "name" "02-mariadb-wait" + "secretName" "mariadb-creds") | nindent 8 }} +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/_configuration.tpl b/library/ix-dev/community/castopod/templates/_configuration.tpl new file mode 100644 index 0000000000..fca41cd76c --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_configuration.tpl @@ -0,0 +1,68 @@ +{{- define "castopod.configuration" -}} + + {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}} + + {{- $saltKey := randAlphaNum 64 -}} + {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-castopod-creds" $fullname)) -}} + {{- $saltKey = ((index .data "CP_ANALYTICS_SALT") | b64dec) -}} + {{- end -}} + + {{- $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 -}} + + {{- $dbHost := (printf "%s-mariadb" $fullname) -}} + {{- $dbUser := "castopod" -}} + {{- $dbName := "castopod" -}} + + {{- $dbPass := (randAlphaNum 32) -}} + {{- $dbRootPass := (randAlphaNum 32) -}} + {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-mariadb-creds" $fullname)) -}} + {{- $dbPass = ((index .data "MARIADB_PASSWORD") | b64dec) -}} + {{- $dbRootPass = ((index .data "MARIADB_ROOT_PASSWORD") | b64dec) -}} + {{- end }} +secret: + mariadb-creds: + enabled: true + data: + MARIADB_USER: {{ $dbUser }} + MARIADB_DATABASE: {{ $dbName }} + MARIADB_PASSWORD: {{ $dbPass }} + MARIADB_ROOT_PASSWORD: {{ $dbRootPass }} + MARIADB_HOST: {{ $dbHost }} + redis-creds: + enabled: true + data: + ALLOW_EMPTY_PASSWORD: "no" + REDIS_PASSWORD: {{ $redisPass }} + REDIS_HOST: {{ $redisHost }} + + castopod-creds: + enabled: true + data: + CP_ANALYTICS_SALT: {{ $saltKey }} + CP_DATABASE_HOSTNAME: {{ $dbHost }} + CP_DATABASE_NAME: {{ $dbName }} + CP_DATABASE_USERNAME: {{ $dbUser }} + CP_DATABASE_PASSWORD: {{ $dbPass }} + CP_CACHE_HANDLER: redis + CP_REDIS_HOST: {{ $redisHost }} + CP_REDIS_PASSWORD: {{ $redisPass }} + CP_REDIS_PORT: "6379" + CP_REDIS_DATABASE: "0" + +configmap: + castopod-config: + enabled: true + data: + CP_TIMEOUT: {{ .Values.castopodConfig.webTimeout | quote }} + CP_MAX_BODY_SIZE: {{ printf "%vM" .Values.castopodConfig.webMaxBodySize }} + CP_PHP_MEMORY_LIMIT: {{ printf "%vM" .Values.castopodConfig.phpMemoryLimit }} + CP_BASEURL: {{ .Values.castopodConfig.baseUrl }} + CP_MEDIAURL: {{ .Values.castopodConfig.baseUrl }} + CP_DISABLE_HTTPS: {{ ternary "1" "0" .Values.castopodConfig.disableHttpsRedirect | quote }} + CP_ENABLE_2FA: {{ .Values.castopodConfig.enable2fa | quote }} +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/_mariadb.tpl b/library/ix-dev/community/castopod/templates/_mariadb.tpl new file mode 100644 index 0000000000..8a4c2bb771 --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_mariadb.tpl @@ -0,0 +1,6 @@ +{{- define "mariadb.workload" -}} +workload: +{{- include "ix.v1.common.app.mariadb" (dict "secretName" "mariadb-creds" + "resources" .Values.resources + "ixChartContext" .Values.ixChartContext) | nindent 2 }} +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/_persistance.tpl b/library/ix-dev/community/castopod/templates/_persistance.tpl new file mode 100644 index 0000000000..7bb6110d60 --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_persistance.tpl @@ -0,0 +1,62 @@ +{{- define "castopod.persistence" -}} +persistence: + data: + enabled: true + type: {{ .Values.castopodStorage.data.type }} + datasetName: {{ .Values.castopodStorage.data.datasetName | default "" }} + hostPath: {{ .Values.castopodStorage.data.hostPath | default "" }} + targetSelector: + castopod: + castopod: + mountPath: /var/www/castopod/public/media + web: + web: + mountPath: /var/www/html/media + tmp: + enabled: true + type: emptyDir + targetSelector: + castopod: + castopod: + mountPath: /tmp + {{- range $idx, $storage := .Values.castopodStorage.additionalStorages }} + {{ printf "castopod-%v" (int $idx) }}: + enabled: true + type: {{ $storage.type }} + datasetName: {{ $storage.datasetName | default "" }} + hostPath: {{ $storage.hostPath | default "" }} + targetSelector: + castopod: + castopod: + mountPath: {{ $storage.mountPath }} + {{- end }} + + mariadbdata: + enabled: true + type: {{ .Values.castopodStorage.mariadbData.type }} + datasetName: {{ .Values.castopodStorage.mariadbData.datasetName | default "" }} + hostPath: {{ .Values.castopodStorage.mariadbData.hostPath | default "" }} + targetSelector: + # MariaDB pod + mariadb: + # MariaDB container + mariadb: + mountPath: /var/lib/mysql + # MariaDB - Permissions container + permissions: + mountPath: /mnt/directories/mariadb_data + mariadbbackup: + enabled: true + type: {{ .Values.castopodStorage.mariadbBackup.type }} + datasetName: {{ .Values.castopodStorage.mariadbBackup.datasetName | default "" }} + hostPath: {{ .Values.castopodStorage.mariadbBackup.hostPath | default "" }} + targetSelector: + # MariaDB backup pod + mariadbbackup: + # MariaDB backup container + mariadbbackup: + mountPath: /mariadb_backup + # MariaDB - Permissions container + permissions: + mountPath: /mnt/directories/mariadb_backup +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/_portal.tpl b/library/ix-dev/community/castopod/templates/_portal.tpl new file mode 100644 index 0000000000..b2e90fc853 --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_portal.tpl @@ -0,0 +1,41 @@ +{{- define "castopod.portal" -}} + {{- $adminPath := "/cp-admin" -}} + {{- if $.Release.IsInstall -}} + {{- $adminPath = "/cp-install" -}} + {{- end -}} + + {{- $host := "$node_ip" -}} + {{- $port := "" -}} + {{- $protocol := "http" -}} + {{- if hasPrefix "https://" .Values.castopodConfig.baseUrl -}} + {{- $protocol = "https" -}} + {{- end -}} + + {{- with .Values.castopodConfig.baseUrl -}} {{/* 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: / + admin: {{ $adminPath }} + port: {{ $port | quote }} + protocol: {{ $protocol }} + host: {{ $host }} +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/_redis.tpl b/library/ix-dev/community/castopod/templates/_redis.tpl new file mode 100644 index 0000000000..c90b61b2be --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_redis.tpl @@ -0,0 +1,6 @@ +{{- define "redis.workload" -}} +workload: +{{- include "ix.v1.common.app.redis" (dict "secretName" "redis-creds" + "resources" .Values.resources) | nindent 2 }} + +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/_service.tpl b/library/ix-dev/community/castopod/templates/_service.tpl new file mode 100644 index 0000000000..33488a3fd3 --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_service.tpl @@ -0,0 +1,49 @@ +{{- define "castopod.service" -}} +service: + castopod-web: + enabled: true + primary: true + type: NodePort + targetSelector: web + ports: + webui: + enabled: true + primary: true + port: {{ .Values.castopodNetwork.webPort }} + nodePort: {{ .Values.castopodNetwork.webPort }} + targetPort: 80 + targetSelector: web + castopod-api: + enabled: true + type: ClusterIP + targetSelector: castopod + ports: + api: + enabled: true + primary: true + port: 9000 + targetPort: 9000 + targetSelector: castopod + mariadb: + enabled: true + type: ClusterIP + targetSelector: mariadb + ports: + mariadb: + enabled: true + primary: true + port: 3306 + targetPort: 3306 + targetSelector: mariadb + redis: + enabled: true + type: ClusterIP + targetSelector: redis + ports: + redis: + enabled: true + primary: true + port: 6379 + targetPort: 6379 + targetSelector: redis +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/_web.tpl b/library/ix-dev/community/castopod/templates/_web.tpl new file mode 100644 index 0000000000..ed60bac320 --- /dev/null +++ b/library/ix-dev/community/castopod/templates/_web.tpl @@ -0,0 +1,60 @@ +{{- define "castopod.web.workload" -}} +{{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}} +{{- $backend := printf "%s-castopod-api" $fullname }} +workload: + web: + enabled: true + type: Deployment + podSpec: + hostNetwork: false + containers: + web: + enabled: true + primary: true + imageSelector: webImage + securityContext: + runAsUser: 0 + runAsGroup: 0 + runAsNonRoot: false + readOnlyRootFilesystem: false + capabilities: + add: + - CHOWN + - SETGID + - SETUID + env: + CP_APP_HOSTNAME: {{ $backend }} + CP_TIMEOUT: {{ .Values.castopodConfig.webTimeout }} + CP_MAX_BODY_SIZE: {{ printf "%vM" .Values.castopodConfig.webMaxBodySize }} + probes: + liveness: + enabled: true + type: http + path: /health + port: 80 + readiness: + enabled: true + type: http + path: /health + port: 80 + startup: + enabled: true + type: http + path: /health + port: 80 + initContainers: + wait-server: + enabled: true + type: init + imageSelector: bashImage + command: + - bash + args: + - -c + - | + echo "Waiting for backend to be ready at [{{ $backend }}:9000]" + until nc -vz -w 5 "{{ $backend }}" 9000; do + echo "Waiting for backend to be ready at [{{ $backend }}:9000]" + sleep 1 + done +{{- end -}} diff --git a/library/ix-dev/community/castopod/templates/common.yaml b/library/ix-dev/community/castopod/templates/common.yaml new file mode 100644 index 0000000000..b8424ebaa1 --- /dev/null +++ b/library/ix-dev/community/castopod/templates/common.yaml @@ -0,0 +1,15 @@ +{{- include "ix.v1.common.loader.init" . -}} + +{{/* Merge the templates with Values */}} +{{- $_ := mustMergeOverwrite .Values (include "castopod.configuration" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "castopod.persistence" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "castopod.service" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "castopod.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "castopod.web.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "mariadb.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "redis.workload" $ | fromYaml) -}} + +{{/* Create the configmap for portal manually*/}} +{{- include "castopod.portal" $ -}} + +{{- include "ix.v1.common.loader.apply" . -}} diff --git a/library/ix-dev/community/castopod/upgrade_info.json b/library/ix-dev/community/castopod/upgrade_info.json new file mode 100644 index 0000000000..940e7d9cb3 --- /dev/null +++ b/library/ix-dev/community/castopod/upgrade_info.json @@ -0,0 +1 @@ +{ "filename": "values.yaml", "keys": ["image", "webImage"] } diff --git a/library/ix-dev/community/castopod/upgrade_strategy b/library/ix-dev/community/castopod/upgrade_strategy new file mode 100755 index 0000000000..fe7ae7d195 --- /dev/null +++ b/library/ix-dev/community/castopod/upgrade_strategy @@ -0,0 +1,51 @@ +#!/usr/bin/python3 +import json +import re +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + +RE_STABLE_VERSION_BASE = r'\d+\.\d+\.\d+' +ENUMS = { + 'image': { + 'RE_STABLE_VERSION': re.compile(rf'{RE_STABLE_VERSION_BASE}'), + }, + 'webImage': { + 'RE_STABLE_VERSION': re.compile(rf'{RE_STABLE_VERSION_BASE}'), + }, +} + + +def newer_mapping(image_tags): + output = { + "tags": {}, + "app_version": "" + } + + for key in image_tags.keys(): + RE_STABLE_VERSION = ENUMS[key].get('RE_STABLE_VERSION', None) if key in ENUMS else None + + if (RE_STABLE_VERSION is None): + continue + + tags = {t: t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)} + version = semantic_versioning(list(tags)) + + if not version: + continue + + if key == 'image': + output['app_version'] = version + + output['tags'][key] = tags[version] + + return output + + +if __name__ == '__main__': + try: + versions_json = json.loads(sys.stdin.read()) + except ValueError: + raise ValueError('Invalid json specified') + + print(json.dumps(newer_mapping(versions_json))) diff --git a/library/ix-dev/community/castopod/values.yaml b/library/ix-dev/community/castopod/values.yaml new file mode 100644 index 0000000000..9412e58a15 --- /dev/null +++ b/library/ix-dev/community/castopod/values.yaml @@ -0,0 +1,37 @@ +image: + repository: castopod/app + pullPolicy: IfNotPresent + tag: 1.6.5 +webImage: + repository: castopod/web-server + pullPolicy: IfNotPresent + tag: 1.6.5 + +resources: + limits: + cpu: 4000m + memory: 8Gi + +castopodConfig: + baseUrl: http://localhost:30085 + webTimeout: 900 + webMaxBodySize: 512 + phpMemoryLimit: 512 + enable2fa: false + disableHttpsRedirect: true + additionalEnvs: [] + +castopodNetwork: + webPort: 30085 + +castopodStorage: + data: + type: ixVolume + datasetName: data + mariadbData: + type: ixVolume + datasetName: mariadbData + mariadbBackup: + type: ixVolume + datasetName: mariadbBackup + additionalStorages: []