概述
这份文档记录了在新加坡华为云节点上,基于 K3s 部署 OpenClaw 的完整配置与实操过程。
基础设施概况
- 节点 ID:
vip-proxy-1-1c44-13dd
- 容器引擎: K3s (v1.34.3+k3s1)
- 宿主机路径:
/root/.openclaw-k8s (持久化存储)
部署架构
采用 Deployment + Service 模式,副本数严格限制为 1,以保证机器人会话的一致性。
核心配置文件 (openclaw-deploy.yaml)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
apiVersion: apps/v1
kind: Deployment
metadata:
name: openclaw
labels:
app: openclaw
spec:
replicas: 1
strategy:
type: Recreate # 确保旧 Pod 彻底停止后再拉起新 Pod
selector:
matchLabels:
app: openclaw
template:
metadata:
labels:
app: openclaw
spec:
containers:
- name: openclaw
image: ghcr.io/openclaw/openclaw:latest
imagePullPolicy: Always
command:
- sleep
- inf
ports:
- containerPort: 18789 # Gateway 端口
env:
- name: OPENCLAW_GATEWAY_TOKEN
value: "change-me-later" # 建议更新为复杂密码
volumeMounts:
- name: data
mountPath: /root/.openclaw
volumes:
- name: data
hostPath:
path: /root/.openclaw-k8s # 宿主机持久化路径
type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
name: openclaw-service
spec:
selector:
app: openclaw
ports:
- protocol: TCP
port: 18789
targetPort: 18789
nodePort: 32226 # 对外暴露的访问端口
type: NodePort
|
配置
使用 ghcr.io/openclaw/openclaw:latest 镜像部署的 Deployment,其中 Pod 以 sleep inf 启动,用户需要登录到容器中执行 openclaw onboard 命令进行配置即可。