diff --git a/library/ix-dev/community/firefly-iii/Chart.lock b/library/ix-dev/community/firefly-iii/Chart.lock new file mode 100644 index 0000000000..6ee7574d29 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: common + repository: file://../../../common + version: 1.1.0 +digest: sha256:752ce76025f5b61094bd2b18ca11693eb9d26d0dde4eb2e63cd2330cbffe9e73 +generated: "2023-08-28T18:32:28.064951481+03:00" diff --git a/library/ix-dev/community/firefly-iii/Chart.yaml b/library/ix-dev/community/firefly-iii/Chart.yaml new file mode 100644 index 0000000000..01ecbda95f --- /dev/null +++ b/library/ix-dev/community/firefly-iii/Chart.yaml @@ -0,0 +1,25 @@ +name: firefly-iii +description: Firefly III is a personal finances manager +annotations: + title: Firefly III +type: application +version: 1.0.0 +apiVersion: v2 +appVersion: '6.0.20' +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://www.firefly-iii.org/ +icon: https://raw.githubusercontent.com/firefly-iii/firefly-iii/develop/.github/assets/img/logo-small.png +sources: + - https://hub.docker.com/r/fireflyiii/core/ + - https://github.com/truenas/charts/tree/master/community/firefly-iii + - https://github.com/firefly-iii/firefly-iii +keywords: + - finance diff --git a/library/ix-dev/community/firefly-iii/README.md b/library/ix-dev/community/firefly-iii/README.md new file mode 100644 index 0000000000..a992ac1f51 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/README.md @@ -0,0 +1,11 @@ +# Firefly III + +[Firefly III](https://www.firefly-iii.org/) is a personal finances manager + +> 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/firefly-iii/app-readme.md b/library/ix-dev/community/firefly-iii/app-readme.md new file mode 100644 index 0000000000..a992ac1f51 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/app-readme.md @@ -0,0 +1,11 @@ +# Firefly III + +[Firefly III](https://www.firefly-iii.org/) is a personal finances manager + +> 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/firefly-iii/charts/common-1.1.0.tgz b/library/ix-dev/community/firefly-iii/charts/common-1.1.0.tgz new file mode 100644 index 0000000000..b9a326999f Binary files /dev/null and b/library/ix-dev/community/firefly-iii/charts/common-1.1.0.tgz differ diff --git a/library/ix-dev/community/firefly-iii/ci/basic-values.yaml b/library/ix-dev/community/firefly-iii/ci/basic-values.yaml new file mode 100644 index 0000000000..2f7fe58c05 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/ci/basic-values.yaml @@ -0,0 +1,14 @@ +fireflyNetwork: + appUrl: http://localhost:31000 + webPort: 31000 + +fireflyStorage: + uploads: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/uploads + pgData: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/pgData + pgBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/pgBackup diff --git a/library/ix-dev/community/firefly-iii/ci/importer-values.yaml b/library/ix-dev/community/firefly-iii/ci/importer-values.yaml new file mode 100644 index 0000000000..c367a2c2e4 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/ci/importer-values.yaml @@ -0,0 +1,18 @@ +fireflyConfig: + appUrl: http://localhost:31000 + enableImporter: true + +fireflyNetwork: + webPort: 31000 + importerPort: 31001 + +fireflyStorage: + uploads: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/uploads + pgData: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/pgData + pgBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/pgBackup diff --git a/library/ix-dev/community/firefly-iii/item.yaml b/library/ix-dev/community/firefly-iii/item.yaml new file mode 100644 index 0000000000..6fc262770b --- /dev/null +++ b/library/ix-dev/community/firefly-iii/item.yaml @@ -0,0 +1,10 @@ +icon_url: https://raw.githubusercontent.com/firefly-iii/firefly-iii/develop/.github/assets/img/logo-small.png +categories: + - productivity +screenshots: + - https://docs.firefly-iii.org/firefly-iii/about-firefly-iii/images/index.png + - https://docs.firefly-iii.org/firefly-iii/about-firefly-iii/images/account.png + - https://docs.firefly-iii.org/firefly-iii/about-firefly-iii/images/budgets.png + - https://docs.firefly-iii.org/firefly-iii/about-firefly-iii/images/tiny/report.png +tags: + - finance diff --git a/library/ix-dev/community/firefly-iii/metadata.yaml b/library/ix-dev/community/firefly-iii/metadata.yaml new file mode 100644 index 0000000000..11cdc63863 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/metadata.yaml @@ -0,0 +1,31 @@ +runAsContext: + - userName: root + groupName: root + gid: 0 + uid: 0 + description: Firefly III runs as root user + - userName: root + groupName: root + gid: 0 + uid: 0 + description: Firefly III Data Importer runs as root user + - userName: postgres + groupName: postgres + gid: 999 + uid: 999 + description: Postgres runs as a non-root user. + - userName: redis + groupName: redis + gid: 1001 + uid: 0 + description: Redis runs as a non-root user and root group. +capabilities: + - name: CHOWN + description: Firefly III and Firefly Data Importer is able to chown files. + - name: FOWNER + description: Firefly III and Firefly Data Importer is able to bypass permission checks. + - name: SETUID + description: Firefly III and Firefly Data Importer is able to set user ID for it's sub-processes. + - name: SETGID + description: Firefly III and Firefly Data Importer is able to set group ID for it's sub-processes. +hostMounts: [] diff --git a/library/ix-dev/community/firefly-iii/questions.yaml b/library/ix-dev/community/firefly-iii/questions.yaml new file mode 100644 index 0000000000..76b07bdd82 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/questions.yaml @@ -0,0 +1,284 @@ +groups: + - name: Firefly III Configuration + description: Configure Firefly III + - name: Network Configuration + description: Configure Network for Firefly III + - name: Storage Configuration + description: Configure Storage for Firefly III + - name: Resources Configuration + description: Configure Resources for Firefly III + +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: fireflyConfig + label: "" + group: Firefly III Configuration + schema: + type: dict + attrs: + - variable: appUrl + label: Firefly III URL + description: | + The base URL for Firefly III.
+ Examples:
+ https://firefly.example.com
+ http://192.168.1.100:30064 + schema: + type: uri + default: "" + required: true + - variable: additionalEnvs + label: Additional Environment Variables + description: Configure additional environment variables for Firefly III. + 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: enableImporter + label: Enable Firefly III Data Importer + description: Enable Firefly III Data Importer. + schema: + type: boolean + default: false + - variable: additionalImporterEnvs + label: Additional Data Importer Environment Variables + description: Configure additional environment variables for Firefly III Data Importer. + schema: + type: list + show_if: [["enableImporter", "=", true]] + 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: fireflyNetwork + label: "" + group: Network Configuration + schema: + type: dict + attrs: + - variable: webPort + label: Web Port + description: The port for the Firefly III WebUI. + schema: + type: int + default: 30064 + min: 9000 + max: 65535 + required: true + - variable: importerPort + label: Data Importer Port + description: The port for the Firefly III Data Importer WebUI. + schema: + type: int + default: 30065 + 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: fireflyStorage + label: "" + group: Storage Configuration + schema: + type: dict + attrs: + - variable: uploads + label: Firefly III Uploads Storage + description: The path to store Firefly III uploads. + 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: uploads + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + - variable: pgData + label: Firefly III Postgres Data Storage + description: The path to store Firefly III 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: Firefly III Postgres Backup Storage + description: The path to store Firefly III 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 + label: "" + group: Resources Configuration + schema: + type: dict + attrs: + - variable: limits + label: Limits + schema: + type: dict + attrs: + - variable: cpu + label: CPU + description: CPU limit for Firefly III. + 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 Firefly III. + 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/firefly-iii/templates/NOTES.txt b/library/ix-dev/community/firefly-iii/templates/NOTES.txt new file mode 100644 index 0000000000..ba4e01146c --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/NOTES.txt @@ -0,0 +1 @@ +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/community/firefly-iii/templates/_configuration.tpl b/library/ix-dev/community/firefly-iii/templates/_configuration.tpl new file mode 100644 index 0000000000..d0d421fd3e --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/_configuration.tpl @@ -0,0 +1,78 @@ +{{- define "firefly.configuration" -}} + + {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}} + + {{- $dbHost := (printf "%s-postgres" $fullname) -}} + {{- $dbUser := "firefly" -}} + {{- $dbName := "firefly" -}} + + {{- $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 "fireflyDbPass" $dbPass -}} + {{- $_ := set .Values "fireflyDbHost" $dbHost -}} + + {{- $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 -}} + + {{- $appKey := (randAlphaNum 32) -}} + {{- $cronToken := (randAlphaNum 32) -}} + {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-firefly-config" $fullname)) -}} + {{- $appKey = ((index .data "APP_KEY") | b64dec) -}} + {{- $cronToken = ((index .data "STATIC_CRON_TOKEN") | b64dec) -}} + {{- end -}} + + {{- $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 }} + + redis-creds: + enabled: true + data: + ALLOW_EMPTY_PASSWORD: "no" + REDIS_PASSWORD: {{ $redisPass }} + REDIS_HOST: {{ $redisHost }} + + firefly-config: + enabled: true + data: + DB_CONNECTION: pgsql + DB_HOST: {{ $dbHost }} + DB_PORT: "5432" + DB_DATABASE: {{ $dbName }} + DB_USERNAME: {{ $dbUser }} + DB_PASSWORD: {{ $dbPass }} + CACHE_DRIVER: redis + SESSION_DRIVER: redis + REDIS_HOST: {{ $redisHost }} + REDIS_PORT: "6379" + REDIS_USERNAME: default + REDIS_PASSWORD: {{ $redisPass }} + REDIS_DB: "0" + REDIS_CACHE_DB: "1" + APP_URL: {{ .Values.fireflyConfig.appUrl | trimSuffix "/" }} + APP_KEY: {{ $appKey }} + STATIC_CRON_TOKEN: {{ $cronToken }} + + importer-config: + enabled: {{ .Values.fireflyConfig.enableImporter }} + data: + FIREFLY_III_URL: http://{{ $fullname }}:{{ .Values.fireflyNetwork.webPort }} + EXPECT_SECURE_URL: "false" + VANITY_URL: {{ .Values.fireflyConfig.appUrl | trimSuffix "/" }} +{{- end -}} diff --git a/library/ix-dev/community/firefly-iii/templates/_firefly.tpl b/library/ix-dev/community/firefly-iii/templates/_firefly.tpl new file mode 100644 index 0000000000..74b9b313d3 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/_firefly.tpl @@ -0,0 +1,56 @@ +{{- define "firefly.workload" -}} +workload: + firefly: + enabled: true + primary: true + type: Deployment + podSpec: + hostNetwork: {{ .Values.fireflyNetwork.hostNetwork }} + containers: + firefly: + enabled: true + primary: true + imageSelector: image + securityContext: + runAsUser: 0 + runAsGroup: 0 + runAsNonRoot: false + readOnlyRootFilesystem: false + capabilities: + add: + - CHOWN + - FOWNER + - SETUID + - SETGID + envFrom: + - secretRef: + name: firefly-config + {{ with .Values.fireflyConfig.additionalEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + liveness: + enabled: true + type: http + path: /health + port: 8080 + readiness: + enabled: true + type: http + path: /health + port: 8080 + startup: + enabled: true + type: http + path: /health + port: 8080 + initContainers: + {{- include "ix.v1.common.app.postgresWait" (dict "name" "postgres-wait" + "secretName" "postgres-creds") | nindent 8 }} + {{- include "ix.v1.common.app.redisWait" (dict "name" "redis-wait" + "secretName" "redis-creds") | nindent 8 }} +{{- end -}} diff --git a/library/ix-dev/community/firefly-iii/templates/_firefly_cron.tpl b/library/ix-dev/community/firefly-iii/templates/_firefly_cron.tpl new file mode 100644 index 0000000000..6bfb54af05 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/_firefly_cron.tpl @@ -0,0 +1,46 @@ +{{- define "firefly.cron" -}} +{{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) }} +workload: + firefly-cron: + enabled: true + type: CronJob + schedule: "0 3 * * *" + podSpec: + restartPolicy: Never + backoffLimit: 2 + containers: + firefly-cron: + enabled: true + primary: true + imageSelector: bashImage + env: + CRON_TOKEN: + secretKeyRef: + name: firefly-config + key: STATIC_CRON_TOKEN + probes: + startup: + enabled: false + readiness: + enabled: false + liveness: + enabled: false + command: + - bash + args: + - -c + - | + until wget --spider --quiet --timeout=3 --tries=1 \ + {{ $fullname }}:{{ .Values.fireflyNetwork.webPort }}/health; do + echo "Waiting for Firefly to start..." + sleep 2 + done + if wget --spider --quiet --timeout=3 --tries=1 \ + {{ $fullname }}:{{ .Values.fireflyNetwork.webPort }}/api/v1/cron/$(CRON_TOKEN); + then + echo "Cron job successfully executed" + else + echo "Cron job failed" + exit 1 + fi +{{- end -}} diff --git a/library/ix-dev/community/firefly-iii/templates/_firefly_importer.tpl b/library/ix-dev/community/firefly-iii/templates/_firefly_importer.tpl new file mode 100644 index 0000000000..5fbdba2a2d --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/_firefly_importer.tpl @@ -0,0 +1,67 @@ +{{- define "firefly.importer" -}} +{{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) }} +workload: + firefly-importer: + enabled: true + type: Deployment + podSpec: + containers: + firefly-importer: + enabled: true + primary: true + imageSelector: importerImage + securityContext: + runAsUser: 0 + runAsGroup: 0 + runAsNonRoot: false + readOnlyRootFilesystem: false + capabilities: + add: + - CHOWN + - FOWNER + - SETUID + - SETGID + envFrom: + - secretRef: + name: importer-config + {{ with .Values.fireflyConfig.additionalImporterEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + liveness: + enabled: true + type: http + path: /health + port: 8080 + readiness: + enabled: true + type: http + path: /health + port: 8080 + startup: + enabled: true + type: http + path: /health + port: 8080 + initContainers: + firefly-wait: + enabled: true + type: init + imageSelector: bashImage + command: + - bash + args: + - -c + - | + until wget --spider --quiet --timeout=3 --tries=1 \ + http://{{ $fullname }}:{{ .Values.fireflyNetwork.webPort }}/health; + do + echo "Waiting for Firefly III to be ready..." + sleep 2 + done + +{{- end -}} diff --git a/library/ix-dev/community/firefly-iii/templates/_persistence.tpl b/library/ix-dev/community/firefly-iii/templates/_persistence.tpl new file mode 100644 index 0000000000..54ab538217 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/_persistence.tpl @@ -0,0 +1,52 @@ +{{- define "firefly.persistence" -}} +persistence: + uploads: + enabled: true + type: {{ .Values.fireflyStorage.uploads.type }} + datasetName: {{ .Values.fireflyStorage.uploads.datasetName | default "" }} + hostPath: {{ .Values.fireflyStorage.uploads.hostPath | default "" }} + targetSelector: + firefly: + firefly: + mountPath: /var/www/html/storage/upload + tmp: + enabled: true + type: emptyDir + targetSelector: + firefly: + firefly: + mountPath: /tmp + firefly-importer: + firefly-importer: + mountPath: /tmp + + # Postgres + postgresdata: + enabled: true + type: {{ .Values.fireflyStorage.pgData.type }} + datasetName: {{ .Values.fireflyStorage.pgData.datasetName | default "" }} + hostPath: {{ .Values.fireflyStorage.pgData.hostPath | default "" }} + targetSelector: + # Postgres pod + postgres: + # Postgres container + postgres: + mountPath: /var/lib/postgresql/data + # Permissions container + permissions: + mountPath: /mnt/directories/postgres_data + postgresbackup: + enabled: true + type: {{ .Values.fireflyStorage.pgBackup.type }} + datasetName: {{ .Values.fireflyStorage.pgBackup.datasetName | default "" }} + hostPath: {{ .Values.fireflyStorage.pgBackup.hostPath | default "" }} + targetSelector: + # Postgres backup pod + postgresbackup: + # Postgres backup container + postgresbackup: + mountPath: /postgres_backup + # Permissions container + permissions: + mountPath: /mnt/directories/postgres_backup +{{- end -}} diff --git a/library/ix-dev/community/firefly-iii/templates/_portal.tpl b/library/ix-dev/community/firefly-iii/templates/_portal.tpl new file mode 100644 index 0000000000..bd4f3f1fce --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/_portal.tpl @@ -0,0 +1,25 @@ +{{- define "firefly.portal" -}} + {{ $prot := "http" }} + {{ if hasPrefix "https://" .Values.fireflyConfig.appUrl }} + {{ $prot = "https" }} + {{ end }} + {{ $host := "$node_ip" }} + {{ $port := .Values.fireflyNetwork.webPort }} + {{ with .Values.fireflyConfig.appUrl }} + {{ $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/firefly-iii/templates/_postgres.tpl b/library/ix-dev/community/firefly-iii/templates/_postgres.tpl new file mode 100644 index 0000000000..0c050b6ca0 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/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/firefly-iii/templates/_redis.tpl b/library/ix-dev/community/firefly-iii/templates/_redis.tpl new file mode 100644 index 0000000000..c90b61b2be --- /dev/null +++ b/library/ix-dev/community/firefly-iii/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/firefly-iii/templates/_service.tpl b/library/ix-dev/community/firefly-iii/templates/_service.tpl new file mode 100644 index 0000000000..3fa9e9f8bc --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/_service.tpl @@ -0,0 +1,50 @@ +{{- define "firefly.service" -}} +service: + firefly: + enabled: true + primary: true + type: NodePort + targetSelector: firefly + ports: + webui: + enabled: true + primary: true + port: {{ .Values.fireflyNetwork.webPort }} + nodePort: {{ .Values.fireflyNetwork.webPort }} + targetPort: 8080 + targetSelector: firefly + firefly-importer: + enabled: {{ .Values.fireflyConfig.enableImporter }} + type: NodePort + targetSelector: firefly-importer + ports: + webui: + enabled: true + primary: true + port: {{ .Values.fireflyNetwork.importerPort }} + nodePort: {{ .Values.fireflyNetwork.importerPort }} + targetPort: 8080 + targetSelector: firefly-importer + redis: + enabled: true + type: ClusterIP + targetSelector: redis + ports: + redis: + enabled: true + primary: true + port: 6379 + targetPort: 6379 + targetSelector: redis + # Postgres + postgres: + enabled: true + type: ClusterIP + targetSelector: postgres + ports: + postgres: + enabled: true + primary: true + port: 5432 + targetSelector: postgres +{{- end -}} diff --git a/library/ix-dev/community/firefly-iii/templates/common.yaml b/library/ix-dev/community/firefly-iii/templates/common.yaml new file mode 100644 index 0000000000..6f829918ed --- /dev/null +++ b/library/ix-dev/community/firefly-iii/templates/common.yaml @@ -0,0 +1,18 @@ +{{- include "ix.v1.common.loader.init" . -}} + +{{/* Merge the templates with Values */}} +{{- $_ := mustMergeOverwrite .Values (include "firefly.configuration" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "firefly.service" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "firefly.persistence" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "firefly.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "firefly.cron" $ | fromYaml) -}} +{{- if .Values.fireflyConfig.enableImporter -}} + {{- $_ := mustMergeOverwrite .Values (include "firefly.importer" $ | fromYaml) -}} +{{- end -}} +{{- $_ := mustMergeOverwrite .Values (include "postgres.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "redis.workload" $ | fromYaml) -}} + +{{/* Create the configmap for portal manually*/}} +{{- include "firefly.portal" $ -}} + +{{- include "ix.v1.common.loader.apply" . -}} diff --git a/library/ix-dev/community/firefly-iii/upgrade_info.json b/library/ix-dev/community/firefly-iii/upgrade_info.json new file mode 100644 index 0000000000..a07425305d --- /dev/null +++ b/library/ix-dev/community/firefly-iii/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "values.yaml", "keys": ["image", "importerImage"]} diff --git a/library/ix-dev/community/firefly-iii/upgrade_strategy b/library/ix-dev/community/firefly-iii/upgrade_strategy new file mode 100755 index 0000000000..5b71ea0446 --- /dev/null +++ b/library/ix-dev/community/firefly-iii/upgrade_strategy @@ -0,0 +1,38 @@ +#!/usr/bin/python3 +import json +import re +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + + +RE_STABLE_VERSION = re.compile(r'version-[0-9]+\.[0-9]+\.[0-9]+') + + +def newer_mapping(image_tags): + output = { + "tags": {}, + "app_version": "" + } + + for key in image_tags.keys(): + tags = {t.strip('version-'): 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/firefly-iii/values.yaml b/library/ix-dev/community/firefly-iii/values.yaml new file mode 100644 index 0000000000..252fefaa4a --- /dev/null +++ b/library/ix-dev/community/firefly-iii/values.yaml @@ -0,0 +1,61 @@ +image: + repository: fireflyiii/core + pullPolicy: IfNotPresent + tag: 'version-6.0.20' + +importerImage: + repository: fireflyiii/data-importer + pullPolicy: IfNotPresent + tag: 'version-1.3.5' + +resources: + limits: + cpu: 4000m + memory: 8Gi + +fireflyConfig: + appUrl: http://localhost:30064 + additionalEnvs: [] + enableImporter: false + additionalImporterEnvs: [] + +fireflyNetwork: + webPort: 30064 + importerPort: 30065 + hostNetwork: false + +fireflyStorage: + uploads: + type: ixVolume + datasetName: uploads + pgData: + type: ixVolume + hostPath: pgData + pgBackup: + type: ixVolume + hostPath: pgBackup + + +notes: + custom: | + {{- if .Values.fireflyConfig.enableImporter }} + ## Data Importer + + You can reach data importer at http://:{{ .Values.fireflyNetwork.importerPort }} + {{- end }} + + ## Database + You can connect to the database using the pgAdmin App from the catalog + +
+ Database Details + + - Database: `firefly` + - Username: `firefly` + - Password: `{{ .Values.fireflyDbPass }}` + - Host: `{{ .Values.fireflyDbHost }}.{{ .Release.Namespace }}.svc.cluster.local` + - Port: `5432` + +
+ {{- $_ := unset .Values "fireflyDbPass" }} + {{- $_ := unset .Values "fireflyDbHost" }}