diff --git a/library/ix-dev/community/linkding/Chart.lock b/library/ix-dev/community/linkding/Chart.lock new file mode 100644 index 0000000000..32c5c096ac --- /dev/null +++ b/library/ix-dev/community/linkding/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: common + repository: file://../../../common + version: 1.1.1 +digest: sha256:a7dbe3e4d42dbcd4325776e5e01a1d630c7f185f79e7ebf22b1b9cc80f56eed7 +generated: "2023-09-27T15:31:17.438401832+03:00" diff --git a/library/ix-dev/community/linkding/Chart.yaml b/library/ix-dev/community/linkding/Chart.yaml new file mode 100644 index 0000000000..1f2155ffca --- /dev/null +++ b/library/ix-dev/community/linkding/Chart.yaml @@ -0,0 +1,25 @@ +name: linkding +description: Linkding is a bookmark manager that you can host yourself. +annotations: + title: Linkding +type: application +version: 1.0.0 +apiVersion: v2 +appVersion: 1.21.1 +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://github.com/sissbruecker/linkding +icon: https://github.com/sissbruecker/linkding/raw/master/docs/header.svg +sources: + - https://github.com/truenas/charts/tree/master/library/ix-dev/community/linkding + - https://github.com/sissbruecker/linkding + - https://hub.docker.com/r/sissbruecker/linkding/ +keywords: + - bookmark diff --git a/library/ix-dev/community/linkding/README.md b/library/ix-dev/community/linkding/README.md new file mode 100644 index 0000000000..8d794e3861 --- /dev/null +++ b/library/ix-dev/community/linkding/README.md @@ -0,0 +1,12 @@ +# Linkding + +[Linkding](https://github.com/sissbruecker/linkding) is a bookmark manager that you can host yourself. + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `linkding` directories. +> Afterward, the `linkding` container will run as a **non**-root user (Default: `568`). +> Same applies to the `postgres` container. This will run afterwards 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 `linkding` and `postgres` data directories. diff --git a/library/ix-dev/community/linkding/app-readme.md b/library/ix-dev/community/linkding/app-readme.md new file mode 100644 index 0000000000..8d794e3861 --- /dev/null +++ b/library/ix-dev/community/linkding/app-readme.md @@ -0,0 +1,12 @@ +# Linkding + +[Linkding](https://github.com/sissbruecker/linkding) is a bookmark manager that you can host yourself. + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `linkding` directories. +> Afterward, the `linkding` container will run as a **non**-root user (Default: `568`). +> Same applies to the `postgres` container. This will run afterwards 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 `linkding` and `postgres` data directories. diff --git a/library/ix-dev/community/linkding/charts/common-1.1.1.tgz b/library/ix-dev/community/linkding/charts/common-1.1.1.tgz new file mode 100644 index 0000000000..93c25a0f46 Binary files /dev/null and b/library/ix-dev/community/linkding/charts/common-1.1.1.tgz differ diff --git a/library/ix-dev/community/linkding/ci/basic-values.yaml b/library/ix-dev/community/linkding/ci/basic-values.yaml new file mode 100644 index 0000000000..1315440759 --- /dev/null +++ b/library/ix-dev/community/linkding/ci/basic-values.yaml @@ -0,0 +1,21 @@ +linkdingNetwork: + webPort: 31000 + +linkdingRunAs: + user: 1000 + group: 1000 + +linkdingConfig: + username: admin + password: admin + +linkdingStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/data + pgData: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgData + pgBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgBackup diff --git a/library/ix-dev/community/linkding/ci/extra-values.yaml b/library/ix-dev/community/linkding/ci/extra-values.yaml new file mode 100644 index 0000000000..131805ac65 --- /dev/null +++ b/library/ix-dev/community/linkding/ci/extra-values.yaml @@ -0,0 +1,29 @@ +linkdingNetwork: + webPort: 31000 + +linkdingConfig: + enableAuthProxy: true + authProxyUsernameHeader: HTTP_REMOTE_USER + authProxyLogoutUrl: https://example.com/logout + disableBackgroundTasks: true + disableUrlValidation: true + csrfTrustedOrigins: + - https://example.com + +linkdingStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/data + pgData: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgData + pgBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgBackup + 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/linkding/ci/hostNet-values.yaml b/library/ix-dev/community/linkding/ci/hostNet-values.yaml new file mode 100644 index 0000000000..f774257aca --- /dev/null +++ b/library/ix-dev/community/linkding/ci/hostNet-values.yaml @@ -0,0 +1,18 @@ +linkdingNetwork: + webPort: 31000 + hostNetwork: true + +linkdingConfig: + username: admin + password: admin + +linkdingStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/data + pgData: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgData + pgBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Namespace }}/pgBackup diff --git a/library/ix-dev/community/linkding/item.yaml b/library/ix-dev/community/linkding/item.yaml new file mode 100644 index 0000000000..88bec52d48 --- /dev/null +++ b/library/ix-dev/community/linkding/item.yaml @@ -0,0 +1,7 @@ +icon_url: https://github.com/sissbruecker/linkding/raw/master/docs/header.svg +categories: + - productivity +screenshots: + - https://github.com/sissbruecker/linkding/raw/master/docs/linkding-screenshot.png?raw=true +tags: + - bookmark diff --git a/library/ix-dev/community/linkding/metadata.yaml b/library/ix-dev/community/linkding/metadata.yaml new file mode 100644 index 0000000000..6d6205a13f --- /dev/null +++ b/library/ix-dev/community/linkding/metadata.yaml @@ -0,0 +1,13 @@ +runAsContext: + - userName: linkding + groupName: linkding + gid: 568 + uid: 568 + description: Linkding can run as any non-root user. + - userName: postgres + groupName: postgres + gid: 999 + uid: 999 + description: Postgres runs as a non-root user. +capabilities: [] +hostMounts: [] diff --git a/library/ix-dev/community/linkding/questions.yaml b/library/ix-dev/community/linkding/questions.yaml new file mode 100644 index 0000000000..b39af61e52 --- /dev/null +++ b/library/ix-dev/community/linkding/questions.yaml @@ -0,0 +1,387 @@ +groups: + - name: Linkding Configuration + description: Configure Linkding + - name: Network Configuration + description: Configure Network for Linkding + - name: User and Group Configuration + description: Configure User and Group for Linkding + - name: Storage Configuration + description: Configure Storage for Linkding + - name: Resources Configuration + description: Configure Resources for Linkding + +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: linkdingConfig + label: "" + group: Linkding Configuration + schema: + type: dict + attrs: + - variable: username + label: Username + description: | + The username for Linkding.
+ It creates a superuser if it doesn't exist.
+ Leaving this empty will disable authentication. + schema: + type: string + default: "" + - variable: password + label: Password + description: | + The password for Linkding.
+ It creates a superuser if it doesn't exist.
+ Leaving this empty will disable authentication. + schema: + type: string + show_if: [["username", "!=", ""]] + default: "" + private: true + - variable: disableBackgroundTasks + label: Disable Background Tasks + description: | + Disables background tasks, such as creating snapshots for bookmarks + on the the Internet Archive Wayback Machine. + schema: + type: boolean + default: false + - variable: disableUrlValidation + label: Disable URL Validation + description: | + Completely disables URL validation for bookmarks. + This can be useful if you intend to store non fully qualified + domain name URLs, such as network paths, or you want to store + URLs that use another protocol than http or https. + schema: + type: boolean + default: false + - variable: enableAuthProxy + label: Enable Auth Proxy + description: | + Enable authentication proxy.
+ This will disable the built-in authentication and use the + authentication proxy instead. + schema: + type: boolean + default: false + - variable: authProxyUsernameHeader + label: Auth Proxy Username Header + description: | + The HTTP header that contains the username for the authentication + proxy. + schema: + type: string + show_if: [["enableAuthProxy", "=", true]] + default: "" + required: true + - variable: authProxyLogoutUrl + label: Auth Proxy Logout URL + description: | + The URL to redirect to when logging out of the authentication proxy. + schema: + type: string + show_if: [["enableAuthProxy", "=", true]] + default: "" + - variable: csrfTrustedOrigins + label: CSRF Trusted Origins + description: | + A list of origins that are allowed to bypass the CSRF protection. + schema: + type: list + default: [] + items: + - variable: origin + label: Origin + schema: + type: string + required: true + - variable: additionalEnvs + label: Additional Environment Variables + description: Configure additional environment variables for Linkding. + 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: linkdingNetwork + label: "" + group: Network Configuration + schema: + type: dict + attrs: + - variable: webPort + label: Web Port + description: The port for the Linkding Web UI. + schema: + type: int + default: 30083 + 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: linkdingRunAs + label: "" + group: User and Group Configuration + schema: + type: dict + attrs: + - variable: user + label: User ID + description: The user id that Linkding will run as. + schema: + type: int + min: 2 + default: 568 + required: true + - variable: group + label: Group ID + description: The group id that Linkding will run as. + schema: + type: int + min: 2 + default: 568 + required: true + + - variable: linkdingStorage + label: "" + group: Storage Configuration + schema: + type: dict + attrs: + - variable: data + label: Linkding Data Storage + description: The path to store Linkding 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: pgData + label: Postgres Data Storage + description: The path to store 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: Postgres Backup Storage + description: The path to store 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: additionalStorages + label: Additional Storage + description: Additional storage for Linkding. + 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 + group: Resources Configuration + label: "" + schema: + type: dict + attrs: + - variable: limits + label: Limits + schema: + type: dict + attrs: + - variable: cpu + label: CPU + description: CPU limit for Linkding. + 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 Linkding. + 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/linkding/templates/NOTES.txt b/library/ix-dev/community/linkding/templates/NOTES.txt new file mode 100644 index 0000000000..ba4e01146c --- /dev/null +++ b/library/ix-dev/community/linkding/templates/NOTES.txt @@ -0,0 +1 @@ +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/community/linkding/templates/_configuration.tpl b/library/ix-dev/community/linkding/templates/_configuration.tpl new file mode 100644 index 0000000000..5a7668c92e --- /dev/null +++ b/library/ix-dev/community/linkding/templates/_configuration.tpl @@ -0,0 +1,71 @@ +{{- define "linkding.configuration" -}} + {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}} + + {{- $dbHost := (printf "%s-postgres" $fullname) -}} + {{- $dbUser := "linkding" -}} + {{- $dbName := "linkding" -}} + + {{- $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 "linkdingDbPass" $dbPass -}} + {{- $_ := set .Values "linkdingDbHost" $dbHost -}} + + {{- $secret := randAlphaNum 64 -}} + {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-linkding-secret" $fullname)) -}} + {{- $secret = ((index .data "secretkey.txt") | b64dec) -}} + {{- end }} + +secret: + linkding-secret: + enabled: true + data: + secretkey.txt: {{ $secret }} + linkding: + enabled: true + data: + LD_DB_ENGINE: postgres + LD_DB_DATABASE: {{ $dbName }} + LD_DB_USER: {{ $dbUser }} + LD_DB_HOST: {{ $dbHost }} + LD_DB_PORT: "5432" + LD_DB_PASSWORD: {{ $dbPass }} + {{- with .Values.linkdingConfig.username }} + LD_SUPERUSER_NAME: {{ . }} + {{- end }} + {{- with .Values.linkdingConfig.password }} + LD_SUPERUSER_PASSWORD: {{ . }} + {{- end }} + + postgres-creds: + enabled: true + data: + POSTGRES_USER: {{ $dbUser }} + POSTGRES_DB: {{ $dbName }} + POSTGRES_PASSWORD: {{ $dbPass }} + POSTGRES_HOST: {{ $dbHost }} + POSTGRES_URL: {{ $dbURL }} + +configmap: + linkding: + enabled: true + data: + LD_SERVER_PORT: {{ .Values.linkdingNetwork.webPort | quote }} + LD_DISABLE_BACKGROUND_TASKS: {{ ternary "True" "False" .Values.linkdingConfig.disableBackgroundTasks | quote }} + LD_DISABLE_URL_VALIDATION: {{ ternary "True" "False" .Values.linkdingConfig.disableUrlValidation | quote }} + LD_ENABLE_AUTH_PROXY: {{ ternary "True" "False" .Values.linkdingConfig.enableAuthProxy | quote }} + {{- if .Values.linkdingConfig.enableAuthProxy }} + LD_AUTH_PROXY_USERNAME_HEADER: {{ .Values.linkdingConfig.authProxyUsernameHeader | quote }} + {{- with .Values.linkdingConfig.authProxyLogoutUrl }} + LD_AUTH_PROXY_LOGOUT_URL: {{ . | quote }} + {{- end -}} + {{- end -}} + {{- with .Values.linkdingConfig.csrfTrustedOrigins }} + LD_CSRF_TRUSTED_ORIGINS: {{ join "," . }} + {{- end -}} +{{- end -}} diff --git a/library/ix-dev/community/linkding/templates/_linkding.tpl b/library/ix-dev/community/linkding/templates/_linkding.tpl new file mode 100644 index 0000000000..75d5c2d0d4 --- /dev/null +++ b/library/ix-dev/community/linkding/templates/_linkding.tpl @@ -0,0 +1,54 @@ +{{- define "linkding.workload" -}} +workload: + linkding: + enabled: true + primary: true + type: Deployment + podSpec: + hostNetwork: {{ .Values.linkdingNetwork.hostNetwork }} + containers: + linkding: + enabled: true + primary: true + imageSelector: image + securityContext: + runAsUser: {{ .Values.linkdingRunAs.user }} + runAsGroup: {{ .Values.linkdingRunAs.group }} + readOnlyRootFilesystem: false + envFrom: + - secretRef: + name: linkding + - configMapRef: + name: linkding + {{ with .Values.linkdingConfig.additionalEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + liveness: + enabled: true + type: http + port: {{ .Values.linkdingNetwork.webPort }} + path: /health + readiness: + enabled: true + type: http + port: {{ .Values.linkdingNetwork.webPort }} + path: /health + startup: + enabled: true + type: http + port: {{ .Values.linkdingNetwork.webPort }} + path: /health + initContainers: + {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions" + "UID" .Values.linkdingRunAs.user + "GID" .Values.linkdingRunAs.group + "mode" "check" + "type" "init") | nindent 8 }} + {{- include "ix.v1.common.app.postgresWait" (dict "name" "02-postgres-wait" + "secretName" "postgres-creds") | nindent 8 }} +{{- end -}} diff --git a/library/ix-dev/community/linkding/templates/_persistence.tpl b/library/ix-dev/community/linkding/templates/_persistence.tpl new file mode 100644 index 0000000000..4b9cfe2fa6 --- /dev/null +++ b/library/ix-dev/community/linkding/templates/_persistence.tpl @@ -0,0 +1,76 @@ +{{- define "linkding.persistence" -}} +persistence: + data: + enabled: true + type: {{ .Values.linkdingStorage.data.type }} + datasetName: {{ .Values.linkdingStorage.data.datasetName | default "" }} + hostPath: {{ .Values.linkdingStorage.data.hostPath | default "" }} + targetSelector: + linkding: + linkding: + mountPath: /etc/linkding/data + 01-permissions: + mountPath: /mnt/directories/data + secret: + enabled: true + type: secret + objectName: linkding-secret + defaultMode: "0600" + targetSelector: + linkding: + linkding: + mountPath: /etc/linkding/secretkey.txt + subPath: secretkey.txt + tmp: + enabled: true + type: emptyDir + targetSelector: + linkding: + linkding: + mountPath: /tmp + {{- range $idx, $storage := .Values.linkdingStorage.additionalStorages }} + {{ printf "linkding-%v" (int $idx) }}: + enabled: true + type: {{ $storage.type }} + datasetName: {{ $storage.datasetName | default "" }} + hostPath: {{ $storage.hostPath | default "" }} + targetSelector: + linkding: + linkding: + mountPath: {{ $storage.mountPath }} + 01-permissions: + mountPath: /mnt/directories{{ $storage.mountPath }} + {{- end }} + + {{/* Database */}} + postgresdata: + enabled: true + type: {{ .Values.linkdingStorage.pgData.type }} + datasetName: {{ .Values.linkdingStorage.pgData.datasetName | default "" }} + hostPath: {{ .Values.linkdingStorage.pgData.hostPath | default "" }} + targetSelector: + # Postgres pod + postgres: + # Postgres container + postgres: + mountPath: /var/lib/postgresql/data + # Postgres - Permissions container + # Different than the 01-permissions + permissions: + mountPath: /mnt/directories/postgres_data + postgresbackup: + enabled: true + type: {{ .Values.linkdingStorage.pgBackup.type }} + datasetName: {{ .Values.linkdingStorage.pgBackup.datasetName | default "" }} + hostPath: {{ .Values.linkdingStorage.pgBackup.hostPath | default "" }} + targetSelector: + # Postgres backup pod + postgresbackup: + # Postgres backup container + postgresbackup: + mountPath: /postgres_backup + # Postgres - Permissions container + # Different than the 01-permissions + permissions: + mountPath: /mnt/directories/postgres_backup +{{- end -}} diff --git a/library/ix-dev/community/linkding/templates/_portal.tpl b/library/ix-dev/community/linkding/templates/_portal.tpl new file mode 100644 index 0000000000..d1bfc86e7c --- /dev/null +++ b/library/ix-dev/community/linkding/templates/_portal.tpl @@ -0,0 +1,12 @@ +{{- define "linkding.portal" -}} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: portal +data: + path: "/" + port: {{ .Values.linkdingNetwork.webPort | quote }} + protocol: "http" + host: $node_ip +{{- end -}} diff --git a/library/ix-dev/community/linkding/templates/_postgres.tpl b/library/ix-dev/community/linkding/templates/_postgres.tpl new file mode 100644 index 0000000000..0c050b6ca0 --- /dev/null +++ b/library/ix-dev/community/linkding/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/linkding/templates/_service.tpl b/library/ix-dev/community/linkding/templates/_service.tpl new file mode 100644 index 0000000000..455886e88d --- /dev/null +++ b/library/ix-dev/community/linkding/templates/_service.tpl @@ -0,0 +1,26 @@ +{{- define "linkding.service" -}} +service: + linkding: + enabled: true + primary: true + type: NodePort + targetSelector: linkding + ports: + webui: + enabled: true + primary: true + port: {{ .Values.linkdingNetwork.webPort }} + nodePort: {{ .Values.linkdingNetwork.webPort }} + targetSelector: linkding + 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/linkding/templates/_validation.tpl b/library/ix-dev/community/linkding/templates/_validation.tpl new file mode 100644 index 0000000000..14b0b18017 --- /dev/null +++ b/library/ix-dev/community/linkding/templates/_validation.tpl @@ -0,0 +1,15 @@ +{{- define "linkding.validation" -}} + + {{- if .Values.linkdingConfig.enableAuthProxy -}} + {{- if not .Values.linkdingConfig.authProxyUsernameHeader -}} + {{- fail "Linkding - [Auth Proxy Username Header] is required when [Auth Proxy] is enabled" -}} + {{- end -}} + {{- end -}} + + {{- if or .Values.linkdingConfig.username .Values.linkdingConfig.password -}} + {{- if not (and .Values.linkdingConfig.username .Values.linkdingConfig.password) -}} + {{- fail "Linkding - Expected none or both [Username] and [Password] set, but only 1 set." -}} + {{- end -}} + {{- end -}} + +{{- end -}} diff --git a/library/ix-dev/community/linkding/templates/common.yaml b/library/ix-dev/community/linkding/templates/common.yaml new file mode 100644 index 0000000000..8ec7f63946 --- /dev/null +++ b/library/ix-dev/community/linkding/templates/common.yaml @@ -0,0 +1,15 @@ +{{- include "ix.v1.common.loader.init" . -}} + +{{- include "linkding.validation" $ -}} + +{{/* Merge the templates with Values */}} +{{- $_ := mustMergeOverwrite .Values (include "linkding.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "linkding.service" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "linkding.persistence" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "linkding.configuration" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "postgres.workload" $ | fromYaml) -}} + +{{/* Create the configmap for portal manually*/}} +{{- include "linkding.portal" $ -}} + +{{- include "ix.v1.common.loader.apply" . -}} diff --git a/library/ix-dev/community/linkding/upgrade_info.json b/library/ix-dev/community/linkding/upgrade_info.json new file mode 100644 index 0000000000..767388094a --- /dev/null +++ b/library/ix-dev/community/linkding/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "values.yaml", "keys": ["image"]} diff --git a/library/ix-dev/community/linkding/upgrade_strategy b/library/ix-dev/community/linkding/upgrade_strategy new file mode 100755 index 0000000000..af685230a1 --- /dev/null +++ b/library/ix-dev/community/linkding/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+') + + +def newer_mapping(image_tags): + key = list(image_tags.keys())[0] + tags = {t: 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/linkding/values.yaml b/library/ix-dev/community/linkding/values.yaml new file mode 100644 index 0000000000..1a59206197 --- /dev/null +++ b/library/ix-dev/community/linkding/values.yaml @@ -0,0 +1,58 @@ +image: + repository: sissbruecker/linkding + pullPolicy: IfNotPresent + tag: 1.21.1 + +resources: + limits: + cpu: 4000m + memory: 8Gi + +linkdingConfig: + username: '' + password: '' + disableBackgroundTasks: false + disableUrlValidation: false + enableAuthProxy: false + authProxyUsernameHeader: '' + authProxyLogoutUrl: '' + csrfTrustedOrigins: [] + additionalEnvs: [] + +linkdingNetwork: + webPort: 30083 + hostNetwork: false + +linkdingRunAs: + user: 568 + group: 568 + +linkdingStorage: + data: + type: ixVolume + datasetName: data + additionalStorages: [] + pgData: + type: ixVolume + datasetName: pgData + pgBackup: + type: ixVolume + datasetName: pgBackup + +notes: + custom: | + ## Database + You can connect to the database using the pgAdmin App from the catalog + +
+ Database Details + + - Database: `linkding` + - Username: `linkding` + - Password: `{{ .Values.linkdingDbPass }}` + - Host: `{{ .Values.linkdingDbHost }}.{{ .Release.Namespace }}.svc.cluster.local` + - Port: `5432` + +
+ {{- $_ := unset .Values "linkdingDbPass" }} + {{- $_ := unset .Values "linkdingDbHost" }}