-
-
Save dedene/51ba4c213412d4007b0a79005082f6d3 to your computer and use it in GitHub Desktop.
N8n on Kubernetes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: postgresql | |
stringData: | |
db-user: postgres | |
db-password: postgres | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: app-shared | |
data: | |
db-host: postgresql | |
db-port: "5432" | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: n8n | |
data: | |
basic-auth-active: "true" | |
generic-timezone: Europe/Budapest | |
db-type: postgresdb | |
db-schema: n8n | |
--- | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: n8n | |
stringData: | |
basic-auth-user: admin | |
basic-auth-password: mysupersecretadminpassword | |
encryption-key: fdxMdmtGwFKEg5+/+Rr/SsI40mSox+uX | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: n8n | |
labels: | |
app: n8n | |
spec: | |
type: ClusterIP | |
ports: | |
- port: 80 | |
targetPort: http | |
protocol: TCP | |
name: http | |
selector: | |
app: n8n | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: n8n | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: n8n | |
template: | |
metadata: | |
labels: | |
app: n8n | |
spec: | |
initContainers: | |
# Optional initContainer: wait for the DB and create a namespace for n8n | |
- name: init-database | |
image: governmentpaas/psql:latest | |
imagePullPolicy: IfNotPresent | |
env: | |
- name: DB_USER | |
valueFrom: | |
secretKeyRef: | |
key: db-user | |
name: postgresql | |
- name: PGPASSWORD | |
valueFrom: | |
secretKeyRef: | |
key: db-password | |
name: postgresql | |
- name: DB_HOST | |
valueFrom: | |
configMapKeyRef: | |
key: db-host | |
name: app-shared | |
- name: DB_PORT | |
valueFrom: | |
configMapKeyRef: | |
key: db-port | |
name: app-shared | |
- name: DB_NAME | |
valueFrom: | |
configMapKeyRef: | |
key: name | |
name: app | |
- name: DB_SCHEMA | |
valueFrom: | |
configMapKeyRef: | |
key: db-schema | |
name: n8n | |
command: | |
- sh | |
args: | |
- -c | |
- | | |
CONNECTION=postgresql://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME | |
RETRIES=15 | |
until psql $CONNECTION -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do | |
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..." | |
sleep 5 | |
done | |
# try creating database schema | |
psql $CONNECTION -c "create schema if not exists $DB_SCHEMA" | |
containers: | |
- name: n8n | |
image: n8nio/n8n | |
ports: | |
- name: http | |
containerPort: 5678 | |
protocol: TCP | |
env: | |
- name: N8N_PORT | |
value: "5678" | |
- name: N8N_BASIC_AUTH_ACTIVE | |
valueFrom: | |
configMapKeyRef: | |
key: basic-auth-active | |
name: n8n | |
- name: N8N_BASIC_AUTH_USER | |
valueFrom: | |
secretKeyRef: | |
key: basic-auth-user | |
name: n8n | |
- name: N8N_BASIC_AUTH_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
key: basic-auth-password | |
name: n8n | |
- name: N8N_ENCRYPTION_KEY | |
valueFrom: | |
secretKeyRef: | |
key: encryption-key | |
name: n8n | |
- name: GENERIC_TIMEZONE | |
valueFrom: | |
configMapKeyRef: | |
key: generic-timezone | |
name: n8n | |
- name: DB_TYPE | |
valueFrom: | |
configMapKeyRef: | |
key: db-type | |
name: n8n | |
- name: DB_POSTGRESDB_SCHEMA | |
valueFrom: | |
configMapKeyRef: | |
key: db-schema | |
name: n8n | |
- name: DB_POSTGRESDB_USER | |
valueFrom: | |
secretKeyRef: | |
key: db-user | |
name: postgresql | |
- name: DB_POSTGRESDB_PASSWORD | |
valueFrom: | |
secretKeyRef: | |
key: db-password | |
name: postgresql | |
- name: DB_POSTGRESDB_HOST | |
valueFrom: | |
configMapKeyRef: | |
key: db-host | |
name: app-shared | |
- name: DB_POSTGRESDB_PORT | |
valueFrom: | |
configMapKeyRef: | |
key: db-port | |
name: app-shared | |
- name: DB_POSTGRESDB_DATABASE | |
valueFrom: | |
configMapKeyRef: | |
key: name | |
name: app | |
- name: WEBHOOK_TUNNEL_URL | |
value: http://n8n/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment