Setup gatewayapi, ssl certs managed by gcloud, n8n. Terraform is also set up

This commit is contained in:
sirius0xdev 2026-01-03 03:47:18 +00:00
commit 824bd2d112
21 changed files with 449 additions and 60 deletions

View file

@ -0,0 +1,18 @@
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: external-http-gateway
namespace: n8n
spec:
gatewayClassName: gke-l7-global-external-managed # Use gke-l7-global-external-http for external, or gke-l7-rilb for internal
listeners:
- name: https
protocol: HTTPS
port: 443
tls:
mode: Terminate
options:
networking.gke.io/pre-shared-certs: n8n-sirius-sec-com
allowedRoutes:
namespaces:
from: All

View file

@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: n8n-config
namespace: n8n
data:
N8N_PORT: "5678"
WEBHOOK_URL: "n8n.sirius-sec.com"
N8N_LISTEN_ADDRESS: "0.0.0.0"
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: "true"
N8N_SECURE_COOKIE: "true"
N8N_METRICS: "true"
QUEUE_HEALTH_CHECK_ACTIVE: "true"
DB_TYPE: "postgresdb"
DB_POSTGRESDB_HOST: "35.188.139.22"
DB_POSTGRESDB_PORT: "5432"
DB_POSTGRESDB_DATABASE: "n8ndb"
DB_POSTGRESDB_USER: "sirius"

View file

@ -0,0 +1,68 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: n8n
namespace: n8n
labels:
app: n8n
spec:
selector:
matchLabels:
app: n8n
replicas: 1
strategy:
rollingUpdate:
type: RollingUpdate
template:
metadata:
labels:
app: n8n
spec:
# initContainers:
# Init containers are exactly like regular containers, except:
# - Init containers always run to completion.
# - Each init container must complete successfully before the next one starts.
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
containers:
- name: n8n
image: docker.n8n.io/n8nio/n8n:2.1.4
imagePullPolicy: IfNotPresent
resources:
requests:
memory: "500Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500"
securityContext:
allowPrivilegeEscalation: false
envFrom:
- configMapRef:
name: n8n-config
- secretRef:
name: n8n-secret
ports:
- containerPort: 5678
name: n8n-port
volumeMounts:
- name: n8n-data
mountPath: /home/node/.n8n
volumes:
- name: n8n-data
persistentVolumeClaim:
claimName: n8n-data
restartPolicy: Always

View file

@ -0,0 +1,16 @@
apiVersion: networking.gke.io/v1
kind: HealthCheckPolicy
metadata:
name: n8n-healthcheck
namespace: n8n
spec:
default:
config:
type: HTTP
httpHealthCheck:
port: 5678 # The port n8n is listening on
requestPath: /healthz # Ensure this returns a 200 OK
targetRef:
group: ""
kind: Service
name: n8n-service # Must match your n8n Service name

View file

@ -0,0 +1,15 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: n8n-route
namespace: n8n
spec:
parentRefs:
- name: external-http-gateway
hostnames:
- "n8n.sirius-sec.com"
rules:
- backendRefs:
- name: n8n-service # The name of your Kubernetes Service
port: 80

View file

@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta
kind: Kustomization
namespace: n8n
resources:
- namespace.yaml
- deployment.yaml
- configmap.yaml
- service.yaml
- storage.yaml

View file

@ -0,0 +1,8 @@
apiVersion: v1
data:
DB_POSTGRESDB_PASSWORD: RzIzPWFRKjhpcnRmKnhLTA==
kind: Secret
metadata:
creationTimestamp: null
name: n8n-secret
namespace: n8n

View file

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: n8n

View file

@ -0,0 +1,9 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-n8n
spec:
instances: 1
storage:
size: 1G

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: n8n-service
namespace: n8n
annotations:
cloud.google.com: '{"ingress": true}'
spec:
selector:
app: n8n
ports:
- port: 80
targetPort: 5678
name: http

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: n8n-data
namespace: n8n
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi