Skip to content

Instantly share code, notes, and snippets.

@bacarini
Last active July 5, 2024 03:45
Show Gist options
  • Save bacarini/fa12ed61ca8fadfd7f0121cca3fb5fa1 to your computer and use it in GitHub Desktop.
Save bacarini/fa12ed61ca8fadfd7f0121cca3fb5fa1 to your computer and use it in GitHub Desktop.
N8N - Kubernetes complete configuration
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: n8n-deployment
namespace: standard
labels: &labels
app: n8n
component: deployment
spec:
replicas: 1
selector:
matchLabels: *labels
template:
metadata:
labels: *labels
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "5678"
spec:
containers:
- name: n8n
image: n8nio/n8n
imagePullPolicy: IfNotPresent
ports:
- name: http-metrics
containerPort: 5678
envFrom:
- secretRef:
name: n8n-secrets
livenessProbe:
httpGet:
path: /healthz
port: 5678
readinessProbe:
httpGet:
path: /healthz
port: 5678
resources:
limits:
cpu: "1.0"
memory: "1024Mi"
requests:
cpu: "0.5"
memory: 512Mi
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: n8n-ingress
namespace: standard
labels: &labels
app: n8n
component: ingress
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
tls:
- hosts:
- your.domain.com
secretName: {{ YOUR_SECRET_TLS_CONFIG }}
rules:
- host: your.domain.com
http:
paths:
- path: /
backend:
serviceName: n8n-service
servicePort: 80
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: n8n-secrets
namespace: standard
labels:
app: n8n
component: secrets
stringData:
DB_TYPE: "postgresdb"
DB_POSTGRESDB_USER: "n8n"
DB_POSTGRESDB_DATABASE: "n8n"
DB_POSTGRESDB_PASSWORD: "{{ PASSWORD }}"
DB_POSTGRESDB_HOST: "{{ HOST }}"
DB_POSTGRESDB_PORT: "5432"
# Basic auth credentials
N8N_BASIC_AUTH_ACTIVE: "true"
N8N_BASIC_AUTH_USER: "n8n"
N8N_BASIC_AUTH_PASSWORD: "{{ PASSWORD }}"
N8N_HOST: "your.domain.com"
N8N_ENCRYPTION_KEY: "{{ PASSWORD }}"
GENERIC_TIMEZONE: "Europe/Lisbon"
WEBHOOK_TUNNEL_URL: "https://your.domain.com/"
NODE_ENV: "production"
N8N_METRICS: "true"
# Increase node max memory
NODE_OPTIONS: "--max_old_space_size=1024"
# Set n8n to work as single thread instead of forking to worker threads
EXECUTIONS_PROCESS: "main"
---
apiVersion: v1
kind: Service
metadata:
name: n8n-service
namespace: standard
annotations:
prometheus.io/probe: "true"
prometheus.io/probe-path: "/healthz"
labels:
app: n8n
component: service
spec:
type: ClusterIP
selector:
app: n8n
component: deployment
ports:
- protocol: TCP
name: http
port: 80
targetPort: 5678
---
apiVersion: v1
kind: Service
metadata:
name: n8n-postgres
namespace: standard
labels: &labels
app: n8n
component: database
spec:
ports:
- name: postgres
port: 5432
targetPort: 5432
clusterIP: None
selector:
app: n8n
component: database
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: n8n-postgres
namespace: standard
labels: &labels
app: n8n
component: database
spec:
serviceName: "n8n-postgres"
replicas: 1
selector:
matchLabels: *labels
template:
metadata:
labels: *labels
spec:
containers:
- name: postgresql
image: postgres:10
ports:
- name: postgres
containerPort: 5432
env:
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: POSTGRES_USER
value: n8n
- name: POSTGRES_DB
value: n8n
- name: POSTGRES_PASSWORD
value: {{ PASSWORD }}
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "gp2"
resources:
requests:
storage: 1Gi
@Kokolokoli
Copy link

Kokolokoli commented Nov 16, 2021

Well, I guess it didn't work.
Tried changing the N8N_PATH to subdomain.myhost.com/n8n and it didn't work; now both the subdomain.myhost.com and subdomain.myhost.com/n8n return blank pages...

I also tried N8N_HOST=subdomain.myhost.com/ && N8N_PATH=/n8n, same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment