Penyebaran cluster Kubernetes
enterprise deploy —— auto scale, high available, rolling update
kapan harus K8s
jujur banyak orang tidak butuh Kubernetes. single machine Docker Compose bisa handle traffic cukup banyak. tapi kalau situation kamu begini —— team beberapa orang pakai bareng, butuh auto scale, require zero-downtime update —— K8s bener-bener jawaban.
Artikel ini step by step bawa deploy OpenClaw di K8s, mulai persiapan cluster sampai HPA auto scale, satu demi satu.
lima step selesai K8s deploy
Cluster preparation
pertama setup K8s cluster dulu. bisa pakai cloud vendor managed K8s (Aliyun ACK, Tencent TKE, AWS EKS), juga bisa pakai kubeadm self-build. rekomen minimal 3 node, 1 master + 2 worker.
buat Deployment
tulis satu Deployment YAML, define OpenClaw Pod template, replica count, resource limit. replica count rekomen minimal 2, pastikan satu down yang lain kuat top.
buat Service
Service bertanggung jawab distribute traffic ke tiap Pod. Pakai tipe ClusterIP untuk internal cluster, atau NodePort expose port langsung ke publik.
Config Ingress
Ingress adalah gateway masuk cluster, bertanggung jawab routing domain dan TLS offload. Pasang satu Nginx Ingress Controller, kemudian config aturan Ingress saja.
Enable Docker suite
HPA (Horizontal Pod Autoscaler) otomatis naik turun jumlah Pod berdasarkan penggunaan CPU atau memori. Puncak otomatis scale-up, lembah otomatis scale-down, hemat uang dan tenang.
Konfigurasi Deployment
Ini config file core, define cara OpenClaw dijalanin:
apiVersion: apps/v1
kind: Deployment
metadata:
name: openclaw
namespace: openclaw
labels:
app: openclaw
spec:
replicas: 2
selector:
matchLabels:
app: openclaw
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: openclaw
spec:
containers:
- name: openclaw
image: openclaw/openclaw:latest
ports:
- containerPort: 3000
resources:
requests:
cpu: "500m"
memory: "512Mi"
limits:
cpu: "2000m"
memory: "2Gi"
env:
- name: OPENCLAW_API_KEY
valueFrom:
secretKeyRef:
name: openclaw-secrets
key: api-key
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
volumeMounts:
- name: data
mountPath: /app/data
volumes:
- name: data
persistentVolumeClaim:
claimName: openclaw-data
Konfigurasi Service
apiVersion: v1
Deploy command
YAML tulis selesai, beberapa perintah bisa deploy:
# Buat namespace
Rolling update dan rollback
Pembaruan rolling K8s adalah bawaan, tapi Anda harus tahu cara rollback:
# Perbarui versi citra