harden n9n deployment

This commit is contained in:
sirius0xdev 2026-02-09 22:40:48 +00:00
parent 3d82e32e28
commit da52118045
2 changed files with 48 additions and 12 deletions

View file

@ -5,6 +5,7 @@ metadata:
namespace: customer1 namespace: customer1
labels: labels:
app: customer1-n8n app: customer1-n8n
spec: spec:
selector: selector:
matchLabels: matchLabels:
@ -18,28 +19,52 @@ spec:
labels: labels:
app: customer1-n8n app: customer1-n8n
spec: 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: securityContext:
runAsNonroot: True
runAsUser: 1000 runAsUser: 1000
runAsGroup: 1000 runAsGroup: 1000
fsGroup: 1000 fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers: containers:
- name: customer1-n8n - name: customer1-n8n
image: docker.n8n.io/n8nio/n8n:2.1.4 image: docker.n8n.io/n8nio/n8n:2.1.4
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
resources: resources:
requests: requests:
memory: "500Mi" memory: "500Mi"
cpu: "250m" cpu: "250m"
limits: limits:
memory: "1Gi" memory: "1Gi"
cpu: "500" cpu: "500"
livenessProbe:
httpGet:
path: /healthz
port: 3008
initialDelaySeconds: 30
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /healthz
port: 3008
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: True
capabilites:
drop:
- ALL
@ -52,17 +77,26 @@ spec:
ports: ports:
- containerPort: 5678 - containerPort: 5678
name: n8n-port name: n8n-port
volumeMounts: volumeMounts:
- name: n8n-data - name: cache
mountPath: /home/node/.n8n mountPath: /home/node/.cache
- name: tmp
mountPath: /tmp
volumes: volumes:
- name: n8n-data - name: cache
persistentVolumeClaim: emptyDir: {}
claimName: n8n-data
- name: tmp
emptyDir: {}
restartPolicy: Always restartPolicy: Always

View file

@ -1,4 +1,6 @@
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: customer1 name: customer1
labels:
pod-security.kubernetes.io/enforce: restricted