Parcourir la source

NAS-123991 / 24.04 / add `n8n` to `community` train (#1520)

* init commit

* add few templates

* add initial implementation

* typo

* add host

* fix lint

* whops

* quote

* fix permisions

* no port

* fix probes

* test user

* readme

* add ui

* typo

* use shortcut for regex

* add redis on metadata

* clean notes

* fixed path

* move down

* fix upgrade json
Stavros Kois il y a 1 an
Parent
commit
1c3f7eaf4a

+ 6 - 0
library/ix-dev/community/n8n/Chart.lock

@@ -0,0 +1,6 @@
+dependencies:
+- name: common
+  repository: file://../../../common
+  version: 1.1.1
+digest: sha256:a7dbe3e4d42dbcd4325776e5e01a1d630c7f185f79e7ebf22b1b9cc80f56eed7
+generated: "2023-09-07T19:31:40.578164035+03:00"

+ 26 - 0
library/ix-dev/community/n8n/Chart.yaml

@@ -0,0 +1,26 @@
+name: n8n
+description: n8n is an extendable workflow automation tool.
+annotations:
+  title: n8n
+type: application
+version: 1.0.0
+apiVersion: v2
+appVersion: 1.6.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://n8n.io/
+icon: https://avatars.githubusercontent.com/u/45487711
+sources:
+  - https://github.com/n8n-io/n8n
+  - https://github.com/truenas/charts/tree/master/community/n8n
+  - https://hub.docker.com/r/n8nio/n8n
+keywords:
+  - workflows
+  - automation

+ 11 - 0
library/ix-dev/community/n8n/README.md

@@ -0,0 +1,11 @@
+# n8n
+
+[n8n](https://n8n.io/) is an extendable workflow automation tool.
+
+> 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.

+ 11 - 0
library/ix-dev/community/n8n/app-readme.md

@@ -0,0 +1,11 @@
+# n8n
+
+[n8n](https://n8n.io/) is an extendable workflow automation tool.
+
+> 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.

BIN
library/ix-dev/community/n8n/charts/common-1.1.1.tgz


+ 13 - 0
library/ix-dev/community/n8n/ci/basic-values.yaml

@@ -0,0 +1,13 @@
+n8nNetwork:
+  webPort: 31000
+
+n8nStorage:
+  data:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/data
+  pgData:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/pgData
+  pgBackup:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/pgBackup

+ 107 - 0
library/ix-dev/community/n8n/ci/https-values.yaml

@@ -0,0 +1,107 @@
+n8nStorage:
+  data:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/data
+  pgData:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/pgData
+  pgBackup:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/pgBackup
+
+n8nConfig:
+  webHost: localhost
+
+n8nRunAs:
+  user: 1001
+  group: 1001
+
+n8nNetwork:
+  webPort: 31000
+  certificateID: 1
+
+ixCertificates:
+  "1":
+    certificate: |
+      -----BEGIN CERTIFICATE-----
+      MIIEdjCCA16gAwIBAgIDYFMYMA0GCSqGSIb3DQEBCwUAMGwxDDAKBgNVBAMMA2Fz
+      ZDELMAkGA1UEBhMCVVMxDTALBgNVBAgMBGFzZGYxCzAJBgNVBAcMAmFmMQ0wCwYD
+      VQQKDARhc2RmMQwwCgYDVQQLDANhc2QxFjAUBgkqhkiG9w0BCQEWB2FAYS5jb20w
+      HhcNMjEwODMwMjMyMzU0WhcNMjMxMjAzMjMyMzU0WjBuMQswCQYDVQQDDAJhZDEL
+      MAkGA1UEBhMCVVMxDTALBgNVBAgMBGFzZGYxDTALBgNVBAcMBGFzZGYxDTALBgNV
+      BAoMBGFkc2YxDTALBgNVBAsMBGFzZGYxFjAUBgkqhkiG9w0BCQEWB2FAYS5jb20w
+      ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7+1xOHRQyOnQTHFcrdasX
+      Zl0gzutVlA890a1wiQpdD5dOtCLo7+eqVYjqVKo9W8RUIArXWmBu/AbkH7oVFWC1
+      P973W1+ArF5sA70f7BZgqRKJTIisuIFIlRETgfnP2pfQmHRZtGaIJRZI4vQCdYgW
+      2g0KOvvNcZJCVq1OrhKiNiY1bWCp66DGg0ic6OEkZFHTm745zUNQaf2dNgsxKU0H
+      PGjVLJI//yrRFAOSBUqgD4c50krnMF7fU/Fqh+UyOu8t6Y/HsySh3urB+Zie331t
+      AzV6QV39KKxRflNx/yuWrtIEslGTm+xHKoCYJEk/nZ3mX8Y5hG6wWAb7A/FuDVg3
+      AgMBAAGjggEdMIIBGTAnBgNVHREEIDAehwTAqAADhwTAqAAFhwTAqAC2hwTAqACB
+      hwTAqACSMB0GA1UdDgQWBBQ4G2ff4tgZl4vmo4xCfqmJhdqShzAMBgNVHRMBAf8E
+      AjAAMIGYBgNVHSMEgZAwgY2AFLlYf9L99nxJDcpCM/LT3V5hQ/a3oXCkbjBsMQww
+      CgYDVQQDDANhc2QxCzAJBgNVBAYTAlVTMQ0wCwYDVQQIDARhc2RmMQswCQYDVQQH
+      DAJhZjENMAsGA1UECgwEYXNkZjEMMAoGA1UECwwDYXNkMRYwFAYJKoZIhvcNAQkB
+      FgdhQGEuY29tggNgUxcwFgYDVR0lAQH/BAwwCgYIKwYBBQUHAwEwDgYDVR0PAQH/
+      BAQDAgWgMA0GCSqGSIb3DQEBCwUAA4IBAQA6FpOInEHB5iVk3FP67GybJ29vHZTD
+      KQHbQgmg8s4L7qIsA1HQ+DMCbdylpA11x+t/eL/n48BvGw2FNXpN6uykhLHJjbKR
+      h8yITa2KeD3LjLYhScwIigXmTVYSP3km6s8jRL6UKT9zttnIHyXVpBDya6Q4WTMx
+      fmfC6O7t1PjQ5ZyVtzizIUP8ah9n4TKdXU4A3QIM6WsJXpHb+vqp1WDWJ7mKFtgj
+      x5TKv3wcPnktx0zMPfLb5BTSE9rc9djcBG0eIAsPT4FgiatCUChe7VhuMnqskxEz
+      MymJLoq8+mzucRwFkOkR2EIt1x+Irl2mJVMeBow63rVZfUQBD8h++LqB
+      -----END CERTIFICATE-----
+      -----BEGIN CERTIFICATE-----
+      MIIEhDCCA2ygAwIBAgIDYFMXMA0GCSqGSIb3DQEBCwUAMGwxDDAKBgNVBAMMA2Fz
+      ZDELMAkGA1UEBhMCVVMxDTALBgNVBAgMBGFzZGYxCzAJBgNVBAcMAmFmMQ0wCwYD
+      VQQKDARhc2RmMQwwCgYDVQQLDANhc2QxFjAUBgkqhkiG9w0BCQEWB2FAYS5jb20w
+      HhcNMjEwODMwMjMyMDQ1WhcNMzEwODI4MjMyMDQ1WjBsMQwwCgYDVQQDDANhc2Qx
+      CzAJBgNVBAYTAlVTMQ0wCwYDVQQIDARhc2RmMQswCQYDVQQHDAJhZjENMAsGA1UE
+      CgwEYXNkZjEMMAoGA1UECwwDYXNkMRYwFAYJKoZIhvcNAQkBFgdhQGEuY29tMIIB
+      IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq//c0hEEr83CS1pMgsHX50jt
+      2MqIbcf63UUNJTiYpUUvUQSFJFc7m/dr+RTZvu97eDCnD5K2qkHHvTPaPZwY+Djf
+      iy7N641Sz6u/y3Yo3xxs1Aermsfedh48vusJpjbkT2XS44VjbkrpKcWDNVpp3Evd
+      M7oJotXeUsZ+imiyVCfr4YhoY5gbGh/r+KN9Wf9YKoUyfLLZGwdZkhtX2zIbidsL
+      Thqi9YTaUHttGinjiBBum234u/CfvKXsfG3yP2gvBGnlvZnM9ktv+lVffYNqlf7H
+      VmB1bKKk84HtzuW5X76SGAgOG8eHX4x5ZLI1WQUuoQOVRl1I0UCjBtbz8XhwvQID
+      AQABo4IBLTCCASkwLQYDVR0RBCYwJIcEwKgABYcEwKgAA4cEwKgAkocEwKgAtYcE
+      wKgAgYcEwKgAtjAdBgNVHQ4EFgQUuVh/0v32fEkNykIz8tPdXmFD9rcwDwYDVR0T
+      AQH/BAUwAwEB/zCBmAYDVR0jBIGQMIGNgBS5WH/S/fZ8SQ3KQjPy091eYUP2t6Fw
+      pG4wbDEMMAoGA1UEAwwDYXNkMQswCQYDVQQGEwJVUzENMAsGA1UECAwEYXNkZjEL
+      MAkGA1UEBwwCYWYxDTALBgNVBAoMBGFzZGYxDDAKBgNVBAsMA2FzZDEWMBQGCSqG
+      SIb3DQEJARYHYUBhLmNvbYIDYFMXMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEF
+      BQcDAjAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAKEocOmVuWlr
+      zegtKYMe8NhHIkFY9oVn5ym6RHNOJpPH4QF8XYC3Z5+iC5yGh4P/jVe/4I4SF6Ql
+      PtofU0jNq5vzapt/y+m008eXqPQFmoUOvu+JavoRVcRx2LIP5AgBA1mF56CSREsX
+      TkuJAA9IUQ8EjnmAoAeKINuPaKxGDuU8BGCMqr/qd564MKNf9XYL+Fb2rlkA0O2d
+      2No34DQLgqSmST/LAvPM7Cbp6knYgnKmGr1nETCXasg1cueHLnWWTvps2HiPp2D/
+      +Fq0uqcZLu4Mdo0CPs4e5sHRyldEnRSKh0DVLprq9zr/GMipmPLJUsT5Jed3sj0w
+      M7Y3vwxshpo=
+      -----END CERTIFICATE-----
+    privatekey: |
+      -----BEGIN PRIVATE KEY-----
+      MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC7+1xOHRQyOnQT
+      HFcrdasXZl0gzutVlA890a1wiQpdD5dOtCLo7+eqVYjqVKo9W8RUIArXWmBu/Abk
+      H7oVFWC1P973W1+ArF5sA70f7BZgqRKJTIisuIFIlRETgfnP2pfQmHRZtGaIJRZI
+      4vQCdYgW2g0KOvvNcZJCVq1OrhKiNiY1bWCp66DGg0ic6OEkZFHTm745zUNQaf2d
+      NgsxKU0HPGjVLJI//yrRFAOSBUqgD4c50krnMF7fU/Fqh+UyOu8t6Y/HsySh3urB
+      +Zie331tAzV6QV39KKxRflNx/yuWrtIEslGTm+xHKoCYJEk/nZ3mX8Y5hG6wWAb7
+      A/FuDVg3AgMBAAECggEAapt30rj9DitGTtxAt13pJMEhyYxvvD3WkvmJwguF/Bbu
+      eW0Ba1c668fMeRCA54FWi1sMqusPS4HUqqUvk+tmyAOsAF4qgD/A4MMSC7uJSVI5
+      N/JWhJWyhCY94/FPakiO1nbPbVw41bcqtzU2qvparpME2CtxSCbDiqm7aaag3Kqe
+      EF0fGSUdZ+TYl9JM05+eIyiX+UY19Fg0OjTHMn8nGpxcNTfDBdQ68TKvdo/dtIKL
+      PLKzJUNNdM8odC4CvQtfGMqaslwZwXkiOl5VJcW21ncj/Y0ngEMKeD/i65ZoqGdR
+      0FKCQYEAGtM2FvJcZQ92Wsw7yj2bK2MSegVUyLK32QKBgQDe8syVCepPzRsfjfxA
+      6TZlWcGuTZLhwIx97Ktw3VcQ1f4rLoEYlv0xC2VWBORpzIsJo4I/OLmgp8a+Ga8z
+      FkVRnq90dV3t4NP9uJlHgcODHnOardC2UUka4olBSCG6zmK4Jxi34lOxhGRkshOo
+      L4IBeOIB5g+ZrEEXkzfYJHESRQKBgQDX2YhFhGIrT8BAnC5BbXbhm8h6Bhjz8DYL
+      d+qhVJjef7L/aJxViU0hX9Ba2O8CLK3FZeREFE3hJPiJ4TZSlN4evxs5p+bbNDcA
+      0mhRI/o3X4ac6IxdRebyYnCOB/Cu94/MzppcZcotlCekKNike7eorCcX4Qavm7Pu
+      MUuQ+ifmSwKBgEnchoqZzlbBzMqXb4rRuIO7SL9GU/MWp3TQg7vQmJerTZlgvsQ2
+      wYsOC3SECmhCq4117iCj2luvOdihCboTFsQDnn0mpQe6BIF6Ns3J38wAuqv0CcFd
+      DKsrge1uyD3rQilgSoAhKzkUc24o0PpXQurZ8YZPgbuXpbj5vPaOnCdBAoGACYc7
+      wb3XS4wos3FxhUfcwJbM4b4VKeeHqzfu7pI6cU/3ydiHVitKcVe2bdw3qMPqI9Wc
+      nvi6e17Tbdq4OCsEJx1OiVwFD9YdO3cOTc6lw/3+hjypvZBRYo+/4jUthbu96E+S
+      dtOzehGZMmDvN0uSzupSi3ZOgkAAUFpyuIKickMCgYAId0PCRjonO2thn/R0rZ7P
+      //L852uyzYhXKw5/fjFGhQ6LbaLgIRFaCZ0L2809u0HFnNvJjHv4AKP6j+vFQYYY
+      qQ+66XnfsA9G/bu4MDS9AX83iahD9IdLXQAy8I19prAbpVumKegPbMnNYNB/TYEc
+      3G15AKCXo7jjOUtHY01DCQ==
+      -----END PRIVATE KEY-----

+ 11 - 0
library/ix-dev/community/n8n/item.yaml

@@ -0,0 +1,11 @@
+icon_url: https://avatars.githubusercontent.com/u/45487711
+categories:
+  - productivity
+screenshots:
+  - https://n8niostorageaccount.blob.core.windows.net/n8nio-strapi-blobs-prod/assets/screen_connect_any_system_v4_584_2672253392.png
+  - https://n8niostorageaccount.blob.core.windows.net/n8nio-strapi-blobs-prod/assets/screen_simple_debugging_v4_584_69c9b38149.png
+  - https://n8niostorageaccount.blob.core.windows.net/n8nio-strapi-blobs-prod/assets/screen_templates_v4_584_8d0d5942ff.png
+  - https://n8niostorageaccount.blob.core.windows.net/n8nio-strapi-blobs-prod/assets/screen_code_ui_v4_584_0971e56ef7.png
+tags:
+  - workflows
+  - automation

+ 18 - 0
library/ix-dev/community/n8n/metadata.yaml

@@ -0,0 +1,18 @@
+runAsContext:
+  - userName: n8n
+    groupName: n8n
+    gid: 568
+    uid: 568
+    description: n8n runs as any non-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: []
+hostMounts: []

+ 281 - 0
library/ix-dev/community/n8n/questions.yaml

@@ -0,0 +1,281 @@
+groups:
+  - name: n8n Configuration
+    description: Configure n8n
+  - name: User and Group Configuration
+    description: Configure User and Group for n8n
+  - name: Network Configuration
+    description: Configure Network for n8n
+  - name: Storage Configuration
+    description: Configure Storage for n8n
+  - name: Resources Configuration
+    description: Configure Resources for n8n
+
+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: n8nConfig
+    label: ""
+    group: n8n Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: webHost
+          label: n8n Host
+          description: |
+            The host address.</br>
+            Examples:</br>
+            n8n.example.com </br>
+            192.168.1.100
+          schema:
+            type: string
+            default: ""
+            required: true
+            $ref:
+              - "definitions/nodeIP"
+        - variable: additionalEnvs
+          label: Additional Environment Variables
+          description: Configure additional environment variables for n8n.
+          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: n8nRunAs
+    label: ""
+    group: User and Group Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: user
+          label: User ID
+          description: The user id that n8n will run as.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+        - variable: group
+          label: Group ID
+          description: The group id that n8n will run as.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+
+  - variable: n8nNetwork
+    label: ""
+    group: Network Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: webPort
+          label: Web Port
+          description: The port for the n8n WebUI.
+          schema:
+            type: int
+            default: 30068
+            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: certificateID
+          label: Certificate
+          description: The certificate to use for n8n
+          schema:
+            type: int
+            "null": true
+            $ref:
+              - "definitions/certificate"
+
+  - variable: n8nStorage
+    label: ""
+    group: Storage Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: data
+          label: n8n Data Storage
+          description: The path to store n8n data.
+          schema:
+            type: dict
+            attrs:
+              - variable: type
+                label: Type
+                description: |
+                  ixVolume: Is dataset created automatically by the system.</br>
+                  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: n8n Postgres Data Storage
+          description: The path to store n8n Postgres Data.
+          schema:
+            type: dict
+            attrs:
+              - variable: type
+                label: Type
+                description: |
+                  ixVolume: Is dataset created automatically by the system.</br>
+                  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: n8n Postgres Backup Storage
+          description: The path to store n8n Postgres Backup.
+          schema:
+            type: dict
+            attrs:
+              - variable: type
+                label: Type
+                description: |
+                  ixVolume: Is dataset created automatically by the system.</br>
+                  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 n8n.
+                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</br>
+                    - Plain Integer - eg. 1</br>
+                    - Float - eg. 0.5</br>
+                    - Milicpu - eg. 500m
+                  default: "4000m"
+                  required: true
+              - variable: memory
+                label: Memory
+                description: Memory limit for n8n.
+                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</br>
+                    - Suffixed with E/P/T/G/M/K - eg. 1G</br>
+                    - Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi</br>
+                    - Plain Integer in bytes - eg. 1024</br>
+                    - Exponent - eg. 134e6
+                  default: "8Gi"
+                  required: true

+ 1 - 0
library/ix-dev/community/n8n/templates/NOTES.txt

@@ -0,0 +1 @@
+{{ include "ix.v1.common.lib.chart.notes" $ }}

+ 86 - 0
library/ix-dev/community/n8n/templates/_configuration.tpl

@@ -0,0 +1,86 @@
+{{- define "n8n.configuration" -}}
+
+  {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
+
+  {{- $dbHost := (printf "%s-postgres" $fullname) -}}
+  {{- $dbUser := "n8n" -}}
+  {{- $dbName := "n8n" -}}
+
+  {{- $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 "n8nDbPass" $dbPass -}}
+  {{- $_ := set .Values "n8nDbHost" $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 -}}
+
+  {{- $encKey := (randAlphaNum 32) -}}
+  {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-n8n-config" $fullname)) -}}
+    {{- $encKey = ((index .data "N8N_ENCRYPTION_KEY") | 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 }}
+
+  n8n-creds:
+    enabled: true
+    data:
+      N8N_ENCRYPTION_KEY: {{ $encKey }}
+      DB_TYPE: postgresdb
+      EXECUTIONS_MODE: queue
+      DB_POSTGRESDB_USER: {{ $dbUser }}
+      DB_POSTGRESDB_PASSWORD: {{ $dbPass }}
+      DB_POSTGRESDB_DATABASE: {{ $dbName }}
+      DB_POSTGRESDB_HOST: {{ $dbHost }}
+      DB_POSTGRESDB_PORT: "5432"
+      QUEUE_BULL_REDIS_USERNAME: default
+      QUEUE_BULL_REDIS_PASSWORD: {{ $redisPass }}
+      QUEUE_BULL_REDIS_DB: "0"
+      QUEUE_BULL_REDIS_HOST: {{ $redisHost }}
+      QUEUE_BULL_REDIS_PORT: "6379"
+
+{{- $prot := "http" -}}
+{{- if .Values.n8nNetwork.certificateID -}}
+  {{- $prot = "https" -}}
+{{- end }}
+configmap:
+  n8n-config:
+    enabled: true
+    data:
+      NODE_ENV: production
+      N8N_PATH: /
+      N8N_PORT: {{ .Values.n8nNetwork.webPort | quote }}
+      N8N_HOST: {{ .Values.n8nConfig.webHost | quote }}
+      GENERIC_TIMEZONE: {{ .Values.TZ }}
+      N8N_PROTOCOL: {{ $prot }}
+      N8N_USER_FOLDER: "/data"
+      {{- if .Values.n8nNetwork.certificateID }}
+      N8N_SSL_KEY: /certs/tls.key
+      N8N_SSL_CERT: /certs/tls.crt
+      {{- end }}
+
+{{- end -}}

+ 61 - 0
library/ix-dev/community/n8n/templates/_n8n.tpl

@@ -0,0 +1,61 @@
+{{- define "n8n.workload" -}}
+workload:
+  n8n:
+    enabled: true
+    primary: true
+    type: Deployment
+    podSpec:
+      hostNetwork: {{ .Values.n8nNetwork.hostNetwork }}
+      containers:
+        n8n:
+          enabled: true
+          primary: true
+          imageSelector: image
+          securityContext:
+            runAsUser: {{ .Values.n8nRunAs.user }}
+            runAsGroup: {{ .Values.n8nRunAs.group }}
+            runAsNonRoot: false
+            readOnlyRootFilesystem: false
+          envFrom:
+            - secretRef:
+                name: n8n-creds
+            - configMapRef:
+                name: n8n-config
+          {{ with .Values.n8nConfig.additionalEnvs }}
+          envList:
+            {{ range $env := . }}
+            - name: {{ $env.name }}
+              value: {{ $env.value }}
+            {{ end }}
+          {{ end }}
+          probes:
+            {{ $prot := "http" }}
+            {{ if .Values.n8nNetwork.certificateID }}
+              {{ $prot = "https" }}
+            {{ end }}
+            liveness:
+              enabled: true
+              type: {{ $prot }}
+              path: /healthz
+              port: {{ .Values.n8nNetwork.webPort }}
+            readiness:
+              enabled: true
+              type: {{ $prot }}
+              path: /healthz
+              port: {{ .Values.n8nNetwork.webPort }}
+            startup:
+              enabled: true
+              type: {{ $prot }}
+              path: /healthz
+              port: {{ .Values.n8nNetwork.webPort }}
+      initContainers:
+      {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
+                                                        "UID" .Values.n8nRunAs.user
+                                                        "GID" .Values.n8nRunAs.group
+                                                        "mode" "check"
+                                                        "type" "init") | nindent 8 }}
+      {{- include "ix.v1.common.app.redisWait" (dict  "name" "02-redis-wait"
+                                                      "secretName" "redis-creds") | nindent 8 }}
+      {{- include "ix.v1.common.app.postgresWait" (dict "name" "03-postgres-wait"
+                                                        "secretName" "postgres-creds") | nindent 8 }}
+{{- end -}}

+ 86 - 0
library/ix-dev/community/n8n/templates/_persistence.tpl

@@ -0,0 +1,86 @@
+{{- define "n8n.persistence" -}}
+persistence:
+  data:
+    enabled: true
+    type: {{ .Values.n8nStorage.data.type }}
+    datasetName: {{ .Values.n8nStorage.data.datasetName | default "" }}
+    hostPath: {{ .Values.n8nStorage.data.hostPath | default "" }}
+    targetSelector:
+      n8n:
+        n8n:
+          mountPath: /data
+        01-permissions:
+          mountPath: /mnt/directories/data
+  tmp:
+    enabled: true
+    type: emptyDir
+    targetSelector:
+      n8n:
+        n8n:
+          mountPath: /tmp
+  {{- range $idx, $storage := .Values.n8nStorage.additionalStorages }}
+  {{ printf "n8n-%v" (int $idx) }}:
+    enabled: true
+    type: {{ $storage.type }}
+    datasetName: {{ $storage.datasetName | default "" }}
+    hostPath: {{ $storage.hostPath | default "" }}
+    targetSelector:
+      n8n:
+        n8n:
+          mountPath: {{ $storage.mountPath }}
+        01-permissions:
+          mountPath: /mnt/directories{{ $storage.mountPath }}
+  {{- end }}
+  # Postgres
+  postgresdata:
+    enabled: true
+    type: {{ .Values.n8nStorage.pgData.type }}
+    datasetName: {{ .Values.n8nStorage.pgData.datasetName | default "" }}
+    hostPath: {{ .Values.n8nStorage.pgData.hostPath | default "" }}
+    targetSelector:
+      # Postgres pod
+      postgres:
+        # Postgres container
+        postgres:
+          mountPath: /var/lib/postgresql/data
+        # Permissions container
+        permissions:
+          mountPath: /mnt/directories/postgres_data
+  # Postgres backup
+  postgresbackup:
+    enabled: true
+    type: {{ .Values.n8nStorage.pgBackup.type }}
+    datasetName: {{ .Values.n8nStorage.pgBackup.datasetName | default "" }}
+    hostPath: {{ .Values.n8nStorage.pgBackup.hostPath | default "" }}
+    targetSelector:
+      # Postgres backup pod
+      postgresbackup:
+        # Postgres backup container
+        postgresbackup:
+          mountPath: /postgres_backup
+        # Permissions container
+        permissions:
+          mountPath: /mnt/directories/postgres_backup
+  {{- if .Values.n8nNetwork.certificateID }}
+  cert:
+    enabled: true
+    type: secret
+    objectName: n8n-cert
+    defaultMode: "0600"
+    items:
+      - key: tls.key
+        path: tls.key
+      - key: tls.crt
+        path: tls.crt
+    targetSelector:
+      n8n:
+        n8n:
+          mountPath: /certs
+          readOnly: true
+
+scaleCertificate:
+  n8n-cert:
+    enabled: true
+    id: {{ .Values.n8nNetwork.certificateID }}
+    {{- end }}
+{{- end -}}

+ 18 - 0
library/ix-dev/community/n8n/templates/_portal.tpl

@@ -0,0 +1,18 @@
+{{- define "n8n.portal" -}}
+  {{- $protocol := "http" -}}
+  {{- if .Values.n8nNetwork.certificateID -}}
+    {{- $protocol = "https" -}}
+  {{- end -}}
+  {{- $host := .Values.n8nConfig.webHost -}}
+  {{- $port := .Values.n8nNetwork.webPort -}}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: portal
+data:
+  port: {{ $port | quote }}
+  path: "/"
+  protocol: {{ $protocol }}
+  host: {{ $host }}
+{{- end -}}

+ 6 - 0
library/ix-dev/community/n8n/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 -}}

+ 6 - 0
library/ix-dev/community/n8n/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 -}}

+ 38 - 0
library/ix-dev/community/n8n/templates/_service.tpl

@@ -0,0 +1,38 @@
+{{- define "n8n.service" -}}
+service:
+  n8n:
+    enabled: true
+    primary: true
+    type: NodePort
+    targetSelector: n8n
+    ports:
+      webui:
+        enabled: true
+        primary: true
+        port: {{ .Values.n8nNetwork.webPort }}
+        nodePort: {{ .Values.n8nNetwork.webPort }}
+        targetSelector: n8n
+  # Redis
+  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 -}}

+ 6 - 0
library/ix-dev/community/n8n/templates/_validation.tpl

@@ -0,0 +1,6 @@
+{{- define "n8n.validation" -}}
+  {{- $host := .Values.n8nConfig.webHost -}}
+  {{- if or (hasPrefix "http://" $host) (hasPrefix "https://" $host) (hasSuffix "/" $host) (contains ":" $host) -}}
+    {{- fail "n8n - Do not start with [http(s)://] or have a trailing slash [/] or have port [:###] in [Web Host] field" -}}
+  {{- end -}}
+{{- end -}}

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

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

+ 1 - 0
library/ix-dev/community/n8n/upgrade_info.json

@@ -0,0 +1 @@
+{"filename": "values.yaml", "keys": ["image"]}

+ 31 - 0
library/ix-dev/community/n8n/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)))

+ 52 - 0
library/ix-dev/community/n8n/values.yaml

@@ -0,0 +1,52 @@
+image:
+  repository: n8nio/n8n
+  pullPolicy: IfNotPresent
+  tag: 1.6.1
+
+resources:
+  limits:
+    cpu: 4000m
+    memory: 8Gi
+
+n8nConfig:
+  webHost: localhost
+  additionalEnvs: []
+
+n8nRunAs:
+  user: 568
+  group: 568
+
+n8nNetwork:
+  webPort: 30068
+  certificateID:
+  hostNetwork: false
+
+n8nStorage:
+  data:
+    type: ixVolume
+    datasetName: data
+  pgData:
+    type: ixVolume
+    hostPath: pgData
+  pgBackup:
+    type: ixVolume
+    hostPath: pgBackup
+  additionalStorages: []
+
+notes:
+  custom: |
+    ## Database
+    You can connect to the database using the pgAdmin App from the catalog
+
+    <details>
+      <summary>Database Details</summary>
+
+      - Database: `n8n`
+      - Username: `n8n`
+      - Password: `{{ .Values.n8nDbPass }}`
+      - Host:     `{{ .Values.n8nDbHost }}.{{ .Release.Namespace }}.svc.cluster.local`
+      - Port:     `5432`
+
+    </details>
+    {{- $_ := unset .Values "n8nDbPass" }}
+    {{- $_ := unset .Values "n8nDbHost" }}