### Configure Pod Lifecycle Hooks Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/configuration.md Specify lifecycle hooks for the n8n pods, such as postStart or preStop commands. This example shows how to install a package after the container starts. ```yaml main: lifecycle: postStart: exec: command: ["/bin/sh", "-c", "apk add mysql-client"] ``` -------------------------------- ### Install Apache Bench for Load Testing Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/troubleshooting.md Installs the Apache Bench (ab) tool, commonly used for load testing web applications. ```bash apt-get install apache2-utils ``` -------------------------------- ### Configure Database Connection Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/troubleshooting.md Example of configuring the database connection details in the Helm chart's values. Ensure host and port match your database setup. ```yaml main: config: db: postgresdb: host: postgres.default.svc port: 5432 ``` -------------------------------- ### Example Init Container Configuration Source: https://github.com/8gears/n8n-helm-chart/blob/main/README.md An example of how to configure an init container for data directory initialization. Ensure the image repository and tag are correctly set. ```yaml - name: init-data-dir image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" command: [ "/bin/sh", "-c", "mkdir -p /home/node/.n8n/" ] volumeMounts: - name: data mountPath: /home/node/.n8n ``` -------------------------------- ### Configure Lifecycle Hooks Source: https://github.com/8gears/n8n-helm-chart/blob/main/README.md Enables the definition of lifecycle hooks for containers, such as `postStart`, to execute commands after container startup. Useful for installing packages or performing initial setup. ```yaml lifecycle: {} # here's the sample configuration to add mysql-client to the container # lifecycle: # postStart: # exec: # command: ["/bin/sh", "-c", "apk add mysql-client"] ``` -------------------------------- ### Install n8n via OCI Registry Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/chart-reference.md Install the n8n Helm chart directly from an OCI registry. This is the recommended method for pre-built and tested deployments. ```bash helm install my-n8n oci://8gears.container-registry.com/library/n8n \ --version 2.0.1 \ --namespace n8n \ --create-namespace ``` -------------------------------- ### Install Traefik Helm Chart Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/ingress-and-networking.md Installs the Traefik Helm chart to manage ingress traffic. ```bash helm repo add traefik https://traefik.github.io/charts helm install traefik traefik/traefik ``` -------------------------------- ### Install NGINX Ingress Controller Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/ingress-and-networking.md Installs the NGINX Ingress controller using Helm. Required for using NGINX-specific Ingress annotations. ```bash helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm install nginx-ingress ingress-nginx/ingress-nginx ``` -------------------------------- ### Get Helm Installation Notes Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/chart-reference.md Retrieve installation notes for a deployed Helm release. This is useful for post-installation steps or configuration details. ```bash helm get notes my-n8n -n n8n ``` -------------------------------- ### Install n8n Development Deployment Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/deployment-patterns.md Installs the n8n Helm chart with development-specific values. After installation, use kubectl port-forward to access n8n locally. ```bash helm install n8n-dev ./charts/n8n -f values-dev.yaml # Access via NodePort kubectl port-forward service/n8n-dev-n8n 5678:5678 # Then open http://localhost:5678 ``` -------------------------------- ### Example Output for n8n.labels Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/templates-and-helpers.md Illustrates the common labels applied to Kubernetes resources when using the `n8n.labels` helper. ```yaml helm.sh/chart: n8n-2.0.1 app.kubernetes.io/name: n8n app.kubernetes.io/instance: my-n8n app.kubernetes.io/version: "1.122.4" app.kubernetes.io/managed-by: Helm ``` -------------------------------- ### Install n8n from GitHub Repository Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/chart-reference.md Clone the n8n Helm chart repository from GitHub and install it locally. This method allows for direct access to the source code and local modifications. ```bash git clone https://github.com/8gears/n8n-helm-chart cd n8n-helm-chart helm install my-n8n charts/n8n \ --namespace n8n \ --create-namespace ``` -------------------------------- ### Example Output for n8n.selectorLabels Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/templates-and-helpers.md Shows the minimal labels generated by the `n8n.selectorLabels` helper, suitable for Kubernetes pod selectors. ```yaml app.kubernetes.io/name: n8n app.kubernetes.io/instance: my-n8n ``` -------------------------------- ### Install Cert-Manager and Create ClusterIssuer Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/ingress-and-networking.md Installs cert-manager and configures a ClusterIssuer for automatic certificate provisioning. ```bash # Install cert-manager kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.0/cert-manager.yaml # Create cluster issuer kubectl apply -f - < manifests.yaml ``` -------------------------------- ### Install AWS ALB Ingress Controller Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/ingress-and-networking.md Installs the AWS ALB Ingress controller using Helm. Required for using ALB-specific Ingress annotations. ```bash helm repo add eks https://aws.github.io/eks-charts helm install aws-load-balancer-controller eks/aws-load-balancer-controller ``` -------------------------------- ### Install CloudNativePG and Deploy N8n Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/deployment-patterns.md These bash commands install the CloudNativePG operator, wait for it to be ready, create necessary Kubernetes secrets for database credentials and certificates, and finally deploy n8n using Helm with the production values file. ```bash # First ensure CloudNativePG is installed kubectl apply -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.27/releases/cnpg-1.27.1.yaml # Wait for CNPG controller kubectl rollout status deployment -n cnpg-system cnpg-controller-manager # Create database credentials secret kubectl create secret generic postgres-credentials \ --from-literal=password=your-secure-password # Create certificate kubectl create secret generic postgres-ca-cert \ --from-file=ca.crt=/path/to/ca.crt # Deploy n8n helm install n8n ./charts/n8n -f values-prod.yaml ``` -------------------------------- ### Configure Liveness and Readiness Probes Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/troubleshooting.md Example of configuring liveness and readiness probe settings in the Helm chart. Adjust `initialDelaySeconds`, `periodSeconds`, `timeoutSeconds`, and `failureThreshold` as needed. ```yaml main: livenessProbe: httpGet: path: /healthz port: http initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 6 readinessProbe: httpGet: path: /healthz port: http initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 3 ``` -------------------------------- ### Example Small Deployment Configuration Source: https://github.com/8gears/n8n-helm-chart/blob/main/README.md A sample configuration for a small n8n deployment using NodePort for local testing. It includes basic n8n settings, encryption key, and resource limits. ```yaml #small deployment with nodeport for local testing or small deployments main: config: n8n: hide_usage_page: true secret: n8n: encryption_key: "" resources: limits: memory: 2048Mi requests: memory: 512Mi service: type: NodePort port: 5678 ``` -------------------------------- ### Helmfile Configuration for n8n Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/chart-reference.md Example `helmfile.yaml` configuration to manage the n8n Helm chart deployment. This is useful for declarative Helm deployments. ```yaml repos: - name: n8n url: oci://8gears.container-registry.com/library/n8n releases: - name: my-n8n namespace: n8n createNamespace: true chart: n8n/n8n version: 2.0.1 values: - values.yaml ``` -------------------------------- ### Extra Kubernetes Manifests Example Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/configuration.md Deploy additional Kubernetes resources like ConfigMaps. Supports templating for dynamic values. ```yaml extraManifests: - apiVersion: v1 kind: ConfigMap metadata: name: custom-config data: key: value extraTemplateManifests: - | apiVersion: v1 kind: ConfigMap metadata: name: dynamic-config data: image: {{ .Values.image.repository }} ``` -------------------------------- ### Configure Resource Requests Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/troubleshooting.md Example of setting resource requests for CPU and memory in the Helm chart's values. This is a solution for pods failing due to insufficient resources. ```yaml main: resources: requests: cpu: 100m memory: 256Mi ``` -------------------------------- ### DNS Record Setup for LoadBalancer Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/ingress-and-networking.md Configure a CNAME record for ingress hostname when using a LoadBalancer. ```dns n8n.example.com IN CNAME elb-1234567890.us-east-1.elb.amazonaws.com ``` -------------------------------- ### DNS Record Setup for NodePort (Development) Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/ingress-and-networking.md Configure an A record for ingress hostname when using NodePort for development. ```dns n8n.local IN A 192.168.1.100 ``` -------------------------------- ### Initial n8n Database Schema Setup Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/persistence-and-data.md Configuration snippet showing how n8n automatically creates its database schema (tables, indexes, constraints) on the first connection to a PostgreSQL database. ```yaml main: config: db: type: postgresdb postgresdb: host: postgres ``` -------------------------------- ### Database Connection Pooling Configuration Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/scaling-and-architecture.md Example of configuring the database connection pool size for the postgresdb within the main deployment configuration. ```yaml db: postgresdb: pool: size: 20 ``` -------------------------------- ### Automated Cluster Backup using Velero Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/persistence-and-data.md Installs Velero for cluster-wide backups and creates a schedule for daily backups of the default namespace. Requires Velero installation and AWS provider configuration. ```bash # Install Velero velero install --provider aws \ --bucket velero-backups \ --secret-file ./credentials-velero # Create backup schedule velero schedule create n8n-daily \ --schedule="0 2 * * *" \ --include-namespaces default ``` -------------------------------- ### Enable Verbose Output for Helm and Kubectl Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/troubleshooting.md Enables verbose output for Helm installations and kubectl logs to aid in debugging. ```bash helm install my-n8n ./charts/n8n --debug ``` ```bash kubectl logs deployment/my-n8n-n8n -v=4 ``` -------------------------------- ### Local Development Configuration for n8n Helm Chart Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/configuration.md This snippet illustrates a configuration for local development using Kind or K3s. It simplifies the setup by disabling persistence and workers, and hiding the usage page. Note that the encryption key is set to a development value and should be changed for production. ```yaml main: service: type: NodePort persistence: enabled: false config: n8n: hide_usage_page: true secret: n8n: encryption_key: "dev-key-change-in-prod" worker: enabled: false webhook: enabled: false ``` -------------------------------- ### DNS Record Setup for ClusterIP + Ingress Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/ingress-and-networking.md Configure a CNAME record for ingress hostname when using ClusterIP. ```dns n8n.example.com IN CNAME ingress.cluster.example.com ``` -------------------------------- ### Conditional Resource Creation Example Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/templates-and-helpers.md Conditionally create Kubernetes resources like Services based on Helm values. This allows for disabling resources by setting a corresponding 'enabled' flag to false. ```go-template {{- if .Values.main.service.enabled }} apiVersion: v1 kind: Service ... {{- end }} ``` -------------------------------- ### Define Initialization Containers Source: https://github.com/8gears/n8n-helm-chart/blob/main/README.md Specifies initialization containers that run in order before the main application containers. Useful for setup tasks, such as data seeding or dependency checks. ```yaml # List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. # See https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ ``` -------------------------------- ### Helmfile Configuration for n8n Deployment Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/deployment-patterns.md Example Helmfile configuration to manage n8n deployments using GitOps principles. This specifies the chart, version, namespace, and values file for the release. ```yaml releases: - name: my-n8n namespace: workflow chart: oci://8gears.container-registry.com/library/n8n version: 1.0.0 values: - values.yaml ``` -------------------------------- ### Horizontal Scaling Configuration Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/deployment-patterns.md Example YAML snippet to adjust replica counts for main, worker, and webhook deployments to achieve horizontal scaling. ```yaml main: replicaCount: 5 # Increase from 2 worker: replicaCount: 10 # More workers for queue processing concurrency: 10 # Each worker handles 10 jobs webhook: replicaCount: 3 # More webhook handlers ``` -------------------------------- ### Vertical Scaling Configuration Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/deployment-patterns.md Example YAML snippet to increase pod resource requests and limits for vertical scaling of the N8n main deployment. ```yaml main: resources: requests: cpu: 2000m # Increased from 500m memory: 2Gi # Increased from 1Gi limits: cpu: 4000m memory: 4Gi ``` -------------------------------- ### Check Service Endpoints Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/scaling-and-architecture.md Use kubectl to get the endpoints for a service to verify load balancing distribution. ```bash kubectl get endpoints my-n8n-n8n ``` -------------------------------- ### Dynamic Port Mapping Example Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/templates-and-helpers.md Dynamically reference service ports in Ingress backends. This allows for custom service ports defined in values, defaulting to port 80 if not specified. ```go-template backend: service: name: {{ $fullName }} port: number: {{ $.Values.main.service.port | default 80 }} ``` -------------------------------- ### Update Helm Dependencies Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/chart-reference.md Use this command to download the necessary chart dependencies, such as the Valkey Helm chart, before installing or upgrading the n8n chart. ```bash helm dependency update charts/n8n ``` -------------------------------- ### Configure Dynamic Persistent Volume with AWS GP3 Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/persistence-and-data.md Example of configuring a dynamic persistent volume using the AWS `gp3` storage class with a size of 100Gi and `ReadWriteOnce` access mode. ```yaml main: persistence: enabled: true type: dynamic size: 100Gi storageClass: gp3 accessModes: - ReadWriteOnce ``` -------------------------------- ### Configure n8n to Use Spot Instances (AWS Example) Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/scaling-and-architecture.md Assigns n8n main and worker pods to nodes with the 'spot' capacity type using node selectors, typically for cost savings on cloud platforms like AWS via Karpenter. ```yaml main: nodeSelector: karpenter.sh/capacity-type: spot worker: nodeSelector: karpenter.sh/capacity-type: spot ``` -------------------------------- ### Check Probe Status and Details Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/troubleshooting.md Inspect probe details using `kubectl describe pod` and monitor status changes with `kubectl get pods -w`. This is essential for diagnosing 'Pod Running But Not Ready' issues. ```bash kubectl describe pod my-n8n-n8n-xxxxx ``` ```bash kubectl get pods -w ``` ```bash kubectl exec deployment/my-n8n-n8n -- curl -v http://localhost:3100/healthz ``` -------------------------------- ### Auto-Scaling Configuration Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/deployment-patterns.md Example YAML snippet to enable and configure Horizontal Pod Autoscaler for N8n main and worker deployments based on CPU utilization. ```yaml main: autoscaling: enabled: true minReplicas: 2 maxReplicas: 20 targetCPUUtilizationPercentage: 60 worker: autoscaling: enabled: true minReplicas: 2 maxReplicas: 50 targetCPUUtilizationPercentage: 70 ``` -------------------------------- ### Merge Configuration Example Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/templates-and-helpers.md Merge configuration from ConfigMaps and Secrets conditionally. This pattern avoids creating resource references if the corresponding values (main.config or main.secret) are not provided. ```go-template envFrom: {{- if .Values.main.config }} - configMapRef: name: {{ include "n8n.fullname" . }}-app-config {{- end }} {{- if .Values.main.secret }} - secretRef: name: {{ include "n8n.fullname" . }}-app-secret {{- end }} ``` -------------------------------- ### Database Connection Troubleshooting Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/deployment-patterns.md Troubleshoot database connection issues by adding a sidecar container or command to test connectivity before starting the main n8n process. Ensure database host and port are correctly set in environment variables. ```yaml main: extraVolumes: - name: debug emptyDir: {} command: - /bin/sh - -c - | echo "Testing database connection..." nc -zv $DB_POSTGRESDB_HOST $DB_POSTGRESDB_PORT exec node /usr/local/bin/n8n ``` -------------------------------- ### Get PostgreSQL Database Size Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/persistence-and-data.md Use kubectl to run a temporary pod with the postgres image and psql to query the size of the n8n database. ```bash # Size of database kubectl run -it --rm db-check \ --image=postgres:15 \ --restart=Never \ -- psql -h postgres.default.svc -U n8n -d n8n \ -c "SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) FROM pg_database;" ``` -------------------------------- ### Override Container Command Source: https://github.com/8gears/n8n-helm-chart/blob/main/README.md Allows overriding the default command executed by the main container. This can be used to modify startup scripts or install additional software before n8n starts. ```yaml command: [] # sample configuration that overrides starting script and solves above issue (also it runs n8n as root, so be careful): # command: # - tini # - -- # - /bin/sh # - -c # - chmod o+rx /root; chown -R node /root/.n8n || true; chown -R node /root/.n8n; ln -s /root/.n8n /home/node; chown -R node /home/node || true; node /usr/local/bin/n8n ``` -------------------------------- ### Convert YAML to Environment Variables (Non-Secret) Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/templates-and-helpers.md Example input for the `toEnvVars` template when `isSecret` is false, demonstrating conversion of nested YAML to environment variables with string quoting. ```yaml values: db: postgresdb: host: localhost port: 5432 prefix: "" isSecret: false ``` -------------------------------- ### Create PersistentVolumeClaim using kubectl Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/persistence-and-data.md Demonstrates how to create a PersistentVolumeClaim named `my-n8n-storage` with `ReadWriteOnce` access, using the `fast-ssd` storage class and requesting 10Gi of storage. ```bash kubectl apply -f - < turns into ENV: N8N_ENCRYPTION_KEY=my_secret db: type: postgresdb # ==> turns into ENV: DB_TYPE=postgresdb postgresdb: host: 192.168.0.52 # ==> turns into ENV: DB_POSTGRESDB_HOST=192.168.0.52 node: function_allow_builtin: "*" # ==> turns into ENV: NODE_FUNCTION_ALLOW_BUILTIN="*" ``` -------------------------------- ### Migrating n8n Data to New Storage Backend Source: https://github.com/8gears/n8n-helm-chart/blob/main/_autodocs/persistence-and-data.md Steps to migrate n8n data to a new storage backend by creating a new PersistentVolumeClaim, copying data, and updating the Helm release. ```bash # 1. Create new PVC kubectl apply -f - <