3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

n8nを簡単にKubernetes上にデプロイして使う方法

Posted at

オープンソースのワークフローツールn8nをKubernetesで使った時のメモです。
https://n8n.io

デフォルトでは作成したデータが保存されないため、PVを用意する必要があります。
また認証を有効にしています。
N8N_BASIC_AUTH_USER N8N_BASIC_AUTH_PASSWORD を設定してください。

http://ノードのIPアドレス:32567 でアクセスができるようになります。

PVなしのパターン

n8n.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: n8n

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: n8n-deployment
  namespace: n8n
spec:
  replicas: 1
  selector:
    matchLabels:
      app: n8n
  template:
    metadata:
      labels:
        app: n8n
    spec:
      containers:
      - name: n8n
        image: n8nio/n8n
        ports:
        - containerPort: 5678
        env:
        - name: N8N_BASIC_AUTH_ACTIVE
          value: "true"
        - name: N8N_BASIC_AUTH_USER
          value: "n8n"
        - name: N8N_BASIC_AUTH_PASSWORD
          value: "n8n"
        - name: GENERIC_TIMEZONE
          value: "Asia/Tokyo"

---
apiVersion: v1
kind: Service
metadata:
  name: n8n-deployment
  namespace: n8n
spec:
  type: NodePort
  selector:
    app: n8n
  ports:
  - protocol: TCP
    port: 5678
    nodePort: 32567
kubectl apply -f n8n.yaml

PVありのパターン

n8n-with-pv.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: n8n

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: n8n-pvc
  namespace: n8n
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 2Gi

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: n8n-deployment
  namespace: n8n
spec:
  replicas: 1
  selector:
    matchLabels:
      app: n8n
  template:
    metadata:
      labels:
        app: n8n
    spec:
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: n8n-pvc
      containers:
      - name: n8n
        image: n8nio/n8n
        ports:
        - containerPort: 5678
        env:
        - name: N8N_BASIC_AUTH_ACTIVE
          value: "true"
        - name: N8N_BASIC_AUTH_USER
          value: "n8n"
        - name: N8N_BASIC_AUTH_PASSWORD
          value: "n8n"
        - name: GENERIC_TIMEZONE
          value: "Asia/Tokyo"
        volumeMounts:
        - name: data
          mountPath: /root/

---
apiVersion: v1
kind: Service
metadata:
  name: n8n-deployment
  namespace: n8n
spec:
  type: NodePort
  selector:
    app: n8n
  ports:
  - protocol: TCP
    port: 5678
    nodePort: 32567
kubectl apply -f n8n-with-pv.yaml
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?