diff --git a/library/ix-dev/community/joplin/Chart.lock b/library/ix-dev/community/joplin/Chart.lock new file mode 100644 index 0000000000..ab870c6b40 --- /dev/null +++ b/library/ix-dev/community/joplin/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: common + repository: file://../../../common + version: 1.1.0 +digest: sha256:752ce76025f5b61094bd2b18ca11693eb9d26d0dde4eb2e63cd2330cbffe9e73 +generated: "2023-08-24T18:43:23.380249283+03:00" diff --git a/library/ix-dev/community/joplin/Chart.yaml b/library/ix-dev/community/joplin/Chart.yaml new file mode 100644 index 0000000000..046e27b7d6 --- /dev/null +++ b/library/ix-dev/community/joplin/Chart.yaml @@ -0,0 +1,25 @@ +name: joplin +description: Joplin is an open source note-taking app. Capture your thoughts and securely access them from any device +annotations: + title: Joplin +type: application +version: 1.0.0 +apiVersion: v2 +appVersion: 2.12.1-beta +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.0 +home: https://joplinapp.org/ +icon: https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/LinuxIcons/256x256.png +sources: + - https://github.com/laurent22/joplin + - https://github.com/truenas/charts/tree/master/library/ix-dev/community/joplin + - https://hub.docker.com/r/joplin/server/ +keywords: + - notes diff --git a/library/ix-dev/community/joplin/README.md b/library/ix-dev/community/joplin/README.md new file mode 100644 index 0000000000..465075c91a --- /dev/null +++ b/library/ix-dev/community/joplin/README.md @@ -0,0 +1,11 @@ +# Joplin + +[Joplin](https://joplinapp.org) is an open source note-taking app. Capture your thoughts and securely access them from any device + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `postgres` directories. +> Afterward, the `postgres` container will run as a **non**-root user (`999`). +> On each upgrade, a container will be launched with **root** privileges in order to apply the correct +> permissions to the `postgres` **backups** directory. Container that performs the backup will run as a **non**-root user (`999`) afterwards. +> Keep in mind the permissions on the backup directory will be changed to `999:999` on **every** update. +> But will only be changed once for the `postgres` data directories. diff --git a/library/ix-dev/community/joplin/app-readme.md b/library/ix-dev/community/joplin/app-readme.md new file mode 100644 index 0000000000..465075c91a --- /dev/null +++ b/library/ix-dev/community/joplin/app-readme.md @@ -0,0 +1,11 @@ +# Joplin + +[Joplin](https://joplinapp.org) is an open source note-taking app. Capture your thoughts and securely access them from any device + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `postgres` directories. +> Afterward, the `postgres` container will run as a **non**-root user (`999`). +> On each upgrade, a container will be launched with **root** privileges in order to apply the correct +> permissions to the `postgres` **backups** directory. Container that performs the backup will run as a **non**-root user (`999`) afterwards. +> Keep in mind the permissions on the backup directory will be changed to `999:999` on **every** update. +> But will only be changed once for the `postgres` data directories. diff --git a/library/ix-dev/community/joplin/charts/common-1.1.0.tgz b/library/ix-dev/community/joplin/charts/common-1.1.0.tgz new file mode 100644 index 0000000000..ccc20d3039 Binary files /dev/null and b/library/ix-dev/community/joplin/charts/common-1.1.0.tgz differ diff --git a/library/ix-dev/community/joplin/ci/basic-values.yaml b/library/ix-dev/community/joplin/ci/basic-values.yaml new file mode 100644 index 0000000000..d537894cbc --- /dev/null +++ b/library/ix-dev/community/joplin/ci/basic-values.yaml @@ -0,0 +1,10 @@ +joplinNetwork: + webPort: 31000 + +joplinStorage: + pgData: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgData + pgBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgBackup diff --git a/library/ix-dev/community/joplin/ci/hostNet-values.yaml b/library/ix-dev/community/joplin/ci/hostNet-values.yaml new file mode 100644 index 0000000000..c14b819c0e --- /dev/null +++ b/library/ix-dev/community/joplin/ci/hostNet-values.yaml @@ -0,0 +1,11 @@ +joplinNetwork: + webPort: 31000 + hostNetwork: true + +joplinStorage: + pgData: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgData + pgBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgBackup diff --git a/library/ix-dev/community/joplin/item.yaml b/library/ix-dev/community/joplin/item.yaml new file mode 100644 index 0000000000..57b880c20b --- /dev/null +++ b/library/ix-dev/community/joplin/item.yaml @@ -0,0 +1,9 @@ +icon_url: https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/LinuxIcons/256x256.png +categories: + - productivity +screenshots: + - https://joplinapp.org/images/home-top-img-2x.webp + - https://joplinapp.org/images/multimedia-notes-img.png + - https://joplinapp.org/images/save-web-img.png +tags: + - notes diff --git a/library/ix-dev/community/joplin/metadata.yaml b/library/ix-dev/community/joplin/metadata.yaml new file mode 100644 index 0000000000..1bfd02fc01 --- /dev/null +++ b/library/ix-dev/community/joplin/metadata.yaml @@ -0,0 +1,8 @@ +runAsContext: + - userName: joplin + groupName: joplin + gid: 1001 + uid: 1001 + description: Joplin can run as a non-root user. +capabilities: [] +hostMounts: [] diff --git a/library/ix-dev/community/joplin/questions.yaml b/library/ix-dev/community/joplin/questions.yaml new file mode 100644 index 0000000000..f15aa85850 --- /dev/null +++ b/library/ix-dev/community/joplin/questions.yaml @@ -0,0 +1,207 @@ +groups: + - name: Joplin Configuration + description: Configure Joplin + - name: Network Configuration + description: Configure Network for Joplin + - name: Storage Configuration + description: Configure Storage for Joplin + - name: Resources Configuration + description: Configure Resources for Joplin + +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" + +questions: + - variable: joplinConfig + label: "" + group: Joplin Configuration + schema: + type: dict + attrs: + - variable: baseUrl + label: Base URL + description: | + The base URL for Joplin.
+ Examples:
+ https://joplin.example.com + http://192.168.1.100:30062 + schema: + type: uri + default: "" + required: true + - variable: additionalEnvs + label: Additional Environment Variables + description: Configure additional environment variables for Joplin. + 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: joplinNetwork + label: "" + group: Network Configuration + schema: + type: dict + attrs: + - variable: webPort + label: Web Port + description: The port for the Joplin Web UI. + schema: + type: int + default: 30062 + min: 9000 + max: 65535 + required: true + - variable: hostNetwork + label: Host Network + description: | + Bind to the host network. It's recommended to keep this disabled.
+ schema: + type: boolean + default: false + + - variable: joplinStorage + label: "" + group: Storage Configuration + schema: + type: dict + attrs: + - variable: pgData + label: Joplin Postgres Data Storage + description: The path to store Joplin Postgres 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: pgData + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + - variable: pgBackup + label: Joplin Postgres Backup Storage + description: The path to store Joplin Postgres 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: pgBackup + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + + - variable: resources + group: Resources Configuration + label: "" + schema: + type: dict + attrs: + - variable: limits + label: Limits + schema: + type: dict + attrs: + - variable: cpu + label: CPU + description: CPU limit for Joplin. + 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 Joplin. + 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/joplin/templates/NOTES.txt b/library/ix-dev/community/joplin/templates/NOTES.txt new file mode 100644 index 0000000000..ba4e01146c --- /dev/null +++ b/library/ix-dev/community/joplin/templates/NOTES.txt @@ -0,0 +1 @@ +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/community/joplin/templates/_configuration.tpl b/library/ix-dev/community/joplin/templates/_configuration.tpl new file mode 100644 index 0000000000..5b2aec6441 --- /dev/null +++ b/library/ix-dev/community/joplin/templates/_configuration.tpl @@ -0,0 +1,29 @@ +{{- define "joplin.configuration" -}} + {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}} + + {{- $dbHost := (printf "%s-postgres" $fullname) -}} + {{- $dbUser := "joplin" -}} + {{- $dbName := "joplin" -}} + + {{- $dbPass := randAlphaNum 32 -}} + {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-postgres-creds" $fullname)) -}} + {{- $dbPass = ((index .data "POSTGRES_PASSWORD") | b64dec) -}} + {{- end -}} + + {{/* Temporary set dynamic db details on values, + so we can print them on the notes */}} + {{- $_ := set .Values "joplinDbPass" $dbPass -}} + {{- $_ := set .Values "joplinDbHost" $dbHost -}} + + {{- $dbURL := (printf "postgres://%s:%s@%s:5432/%s?sslmode=disable" $dbUser $dbPass $dbHost $dbName) }} + +secret: + postgres-creds: + enabled: true + data: + POSTGRES_USER: {{ $dbUser }} + POSTGRES_DB: {{ $dbName }} + POSTGRES_PASSWORD: {{ $dbPass }} + POSTGRES_HOST: {{ $dbHost }} + POSTGRES_URL: {{ $dbURL }} +{{- end -}} diff --git a/library/ix-dev/community/joplin/templates/_joplin.tpl b/library/ix-dev/community/joplin/templates/_joplin.tpl new file mode 100644 index 0000000000..1a5211aae9 --- /dev/null +++ b/library/ix-dev/community/joplin/templates/_joplin.tpl @@ -0,0 +1,71 @@ +{{- define "joplin.workload" -}} +workload: + joplin: + enabled: true + primary: true + type: Deployment + podSpec: + hostNetwork: {{ .Values.joplinNetwork.hostNetwork }} + containers: + joplin: + enabled: true + primary: true + imageSelector: image + securityContext: + runAsUser: 1001 + runAsGroup: 1001 + readOnlyRootFilesystem: false + env: + APP_PORT: {{ .Values.joplinNetwork.webPort }} + APP_BASE_URL: {{ .Values.joplinConfig.baseUrl }} + DB_CLIENT: pg + POSTGRES_PORT: 5432 + POSTGRES_HOST: + secretKeyRef: + name: postgres-creds + key: POSTGRES_HOST + POSTGRES_DATABASE: + secretKeyRef: + name: postgres-creds + key: POSTGRES_DB + POSTGRES_USER: + secretKeyRef: + name: postgres-creds + key: POSTGRES_USER + POSTGRES_PASSWORD: + secretKeyRef: + name: postgres-creds + key: POSTGRES_PASSWORD + {{ with .Values.joplinConfig.additionalEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + liveness: + enabled: true + type: http + port: {{ .Values.joplinNetwork.webPort }} + path: /api/ping + httpHeaders: + Host: '{{ .Values.joplinConfig.baseUrl | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/" }}' + readiness: + enabled: true + type: http + port: {{ .Values.joplinNetwork.webPort }} + path: /api/ping + httpHeaders: + Host: '{{ .Values.joplinConfig.baseUrl | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/" }}' + startup: + enabled: true + type: http + port: {{ .Values.joplinNetwork.webPort }} + path: /api/ping + httpHeaders: + Host: '{{ .Values.joplinConfig.baseUrl | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/" }}' + initContainers: + {{- include "ix.v1.common.app.postgresWait" (dict "name" "postgres-wait" + "secretName" "postgres-creds") | nindent 8 }} +{{- end -}} diff --git a/library/ix-dev/community/joplin/templates/_persistence.tpl b/library/ix-dev/community/joplin/templates/_persistence.tpl new file mode 100644 index 0000000000..280a05a7ff --- /dev/null +++ b/library/ix-dev/community/joplin/templates/_persistence.tpl @@ -0,0 +1,31 @@ +{{- define "joplin.persistence" -}} +persistence: + postgresdata: + enabled: true + type: {{ .Values.joplinStorage.pgData.type }} + datasetName: {{ .Values.joplinStorage.pgData.datasetName | default "" }} + hostPath: {{ .Values.joplinStorage.pgData.hostPath | default "" }} + targetSelector: + # Postgres pod + postgres: + # Postgres container + postgres: + mountPath: /var/lib/postgresql/data + # Postgres - Permissions container + permissions: + mountPath: /mnt/directories/postgres_data + postgresbackup: + enabled: true + type: {{ .Values.joplinStorage.pgBackup.type }} + datasetName: {{ .Values.joplinStorage.pgBackup.datasetName | default "" }} + hostPath: {{ .Values.joplinStorage.pgBackup.hostPath | default "" }} + targetSelector: + # Postgres backup pod + postgresbackup: + # Postgres backup container + postgresbackup: + mountPath: /postgres_backup + # Postgres - Permissions container + permissions: + mountPath: /mnt/directories/postgres_backup +{{- end -}} diff --git a/library/ix-dev/community/joplin/templates/_portal.tpl b/library/ix-dev/community/joplin/templates/_portal.tpl new file mode 100644 index 0000000000..b26c6cae49 --- /dev/null +++ b/library/ix-dev/community/joplin/templates/_portal.tpl @@ -0,0 +1,25 @@ +{{- define "joplin.portal" -}} + {{ $prot := "http" }} + {{ if hasPrefix "https://" .Values.joplinConfig.baseUrl }} + {{ $prot = "https" }} + {{ end }} + {{ $host := "$node_ip" }} + {{ $port := .Values.joplinNetwork.webPort }} + {{ with .Values.joplinConfig.baseUrl }} + {{ $host = . | trimPrefix "http://" | trimPrefix "https://" | trimSuffix "/" }} + {{ if contains ":" $host }} + {{ $port = (split ":" $host)._1 }} + {{ $host = (split ":" $host)._0 }} + {{ end }} + {{ end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: portal +data: + port: {{ $port | quote }} + path: "/" + protocol: {{ $prot }} + host: {{ $host }} +{{- end -}} diff --git a/library/ix-dev/community/joplin/templates/_postgres.tpl b/library/ix-dev/community/joplin/templates/_postgres.tpl new file mode 100644 index 0000000000..0c050b6ca0 --- /dev/null +++ b/library/ix-dev/community/joplin/templates/_postgres.tpl @@ -0,0 +1,6 @@ +{{- define "postgres.workload" -}} +workload: +{{- include "ix.v1.common.app.postgres" (dict "secretName" "postgres-creds" + "resources" .Values.resources + "ixChartContext" .Values.ixChartContext) | nindent 2 }} +{{- end -}} diff --git a/library/ix-dev/community/joplin/templates/_service.tpl b/library/ix-dev/community/joplin/templates/_service.tpl new file mode 100644 index 0000000000..2ddc561a33 --- /dev/null +++ b/library/ix-dev/community/joplin/templates/_service.tpl @@ -0,0 +1,26 @@ +{{- define "joplin.service" -}} +service: + joplin: + enabled: true + primary: true + type: NodePort + targetSelector: joplin + ports: + webui: + enabled: true + primary: true + port: {{ .Values.joplinNetwork.webPort }} + nodePort: {{ .Values.joplinNetwork.webPort }} + targetSelector: joplin + postgres: + enabled: true + type: ClusterIP + targetSelector: postgres + ports: + postgres: + enabled: true + primary: true + port: 5432 + targetPort: 5432 + targetSelector: postgres +{{- end -}} diff --git a/library/ix-dev/community/joplin/templates/common.yaml b/library/ix-dev/community/joplin/templates/common.yaml new file mode 100644 index 0000000000..b85d295bd4 --- /dev/null +++ b/library/ix-dev/community/joplin/templates/common.yaml @@ -0,0 +1,13 @@ +{{- include "ix.v1.common.loader.init" . -}} + +{{/* Merge the templates with Values */}} +{{- $_ := mustMergeOverwrite .Values (include "joplin.service" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "joplin.persistence" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "joplin.configuration" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "postgres.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "joplin.workload" $ | fromYaml) -}} + +{{/* Create the configmap for portal manually*/}} +{{- include "joplin.portal" $ -}} + +{{- include "ix.v1.common.loader.apply" . -}} diff --git a/library/ix-dev/community/joplin/upgrade_info.json b/library/ix-dev/community/joplin/upgrade_info.json new file mode 100644 index 0000000000..767388094a --- /dev/null +++ b/library/ix-dev/community/joplin/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "values.yaml", "keys": ["image"]} diff --git a/library/ix-dev/community/joplin/upgrade_strategy b/library/ix-dev/community/joplin/upgrade_strategy new file mode 100755 index 0000000000..e455e68fbf --- /dev/null +++ b/library/ix-dev/community/joplin/upgrade_strategy @@ -0,0 +1,31 @@ +#!/usr/bin/python3 +import json +import re +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + + +RE_STABLE_VERSION = re.compile(r'\d+\.\d+\.\d+-beta') + + +def newer_mapping(image_tags): + key = list(image_tags.keys())[0] + tags = {t.strip("-beta"): t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)} + version = semantic_versioning(list(tags)) + if not version: + return {} + + return { + 'tags': {key: tags[version]}, + 'app_version': version, + } + + +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/joplin/values.yaml b/library/ix-dev/community/joplin/values.yaml new file mode 100644 index 0000000000..a74371ff61 --- /dev/null +++ b/library/ix-dev/community/joplin/values.yaml @@ -0,0 +1,47 @@ +image: + repository: joplin/server + pullPolicy: IfNotPresent + tag: 2.12.1-beta + +resources: + limits: + cpu: 4000m + memory: 8Gi + +joplinConfig: + baseUrl: http://localhost:30063 + additionalEnvs: [] + +joplinNetwork: + webPort: 30063 + hostNetwork: false + +joplinStorage: + pgData: + type: ixVolume + datasetName: pgData + pgBackup: + type: ixVolume + datasetName: pgBackup + +notes: + custom: | + ## Default Credentials + - Username: `admin@localhost` + - Password: `admin` + + ## Database + You can connect to the database using the pgAdmin App from the catalog + +
+ Database Details + + - Database: `joplin` + - Username: `joplin` + - Password: `{{ .Values.joplinDbPass }}` + - Host: `{{ .Values.joplinDbHost }}.{{ .Release.Namespace }}.svc.cluster.local` + - Port: `5432` + +
+ {{- $_ := unset .Values "joplinDbPass" }} + {{- $_ := unset .Values "joplinDbHost" }}