apiVersion: v1
kind: Pod
metadata:
  name: n8n
  labels:
    app: n8n
spec:
  restartPolicy: Always
  containers:
  - name: n8n
    image: docker.io/n8nio/n8n:latest
    ports:
    - hostPort: 5678
      containerPort: 5678
    env:
    - name: DB_TYPE
      value: postgresdb
    - name: DB_POSTGRESDB_HOST
      value: 127.0.0.1
    - name: DB_POSTGRESDB_PORT
      value: '5432'
    - name: DB_POSTGRESDB_DATABASE
      value: n8n
    - name: DB_POSTGRESDB_USER
      value: n8n
    - name: DB_POSTGRESDB_PASSWORD
      value: KK0yQtPwAL7yGlB0fxt4Zg
    - name: N8N_HOST
      value: localhost
    - name: N8N_PORT
      value: '5678'
    - name: N8N_PROTOCOL
      value: http
    - name: WEBHOOK_URL
      value: http://localhost:5678/
    - name: GENERIC_TIMEZONE
      value: Europe/Vienna
    volumeMounts:
    - name: vol-0
      mountPath: /home/node/.n8n
    securityContext:
      runAsUser: 1000
      runAsGroup: 1000
  - name: postgres
    image: docker.io/postgres:16
    ports:
    - hostPort: 5432
      containerPort: 5432
    env:
    - name: POSTGRES_USER
      value: n8n
    - name: POSTGRES_PASSWORD
      value: KK0yQtPwAL7yGlB0fxt4Zg
    - name: POSTGRES_DB
      value: n8n
    volumeMounts:
    - name: vol-1
      mountPath: /var/lib/postgresql/data
  volumes:
  - name: vol-0
    hostPath:
      path: ~/n8n/data
      type: DirectoryOrCreate
  - name: vol-1
    hostPath:
      path: ~/n8n/db
      type: DirectoryOrCreate
