# docs/05-08-openclaw-k3s-实验部署.md — 实验用;替换镜像与域名 apiVersion: v1 # Namespace 使用的核心 API 版本 kind: Namespace # 资源类型:命名空间 metadata: # Namespace 元信息 name: openclaw # 命名空间名称 --- apiVersion: apps/v1 # Deployment 使用的 API 版本 kind: Deployment # 工作负载:Deployment metadata: # Deployment 元信息 name: openclaw-gateway # Deployment 名称 namespace: openclaw # 所在命名空间 spec: # Deployment 规格 replicas: 1 # 副本数 selector: # 选择器 matchLabels: # 标签匹配 app: openclaw-gateway # 匹配标签 app=openclaw-gateway template: # Pod 模板 metadata: # Pod 元信息 labels: # Pod 标签 app: openclaw-gateway # 与 selector 匹配 spec: # Pod 规格 containers: # 容器列表 - name: openclaw-gateway # 容器名 image: registry.local/openclaw:local # 容器镜像(按环境替换) imagePullPolicy: IfNotPresent # 拉取策略:本地有镜像则不重复拉取 env: # 环境变量 - name: OPENCLAW_GATEWAY_MODE # 运行模式变量名 value: "local" # 运行模式值 ports: # 容器端口 - containerPort: 18789 # 网关监听端口 volumeMounts: # 卷挂载 - name: config # 配置卷 mountPath: /home/node/.openclaw # 配置目录挂载点 - name: workspace # 工作目录卷 mountPath: /home/node/.openclaw/workspace # 工作目录挂载点 volumes: # 卷定义 - name: config # 配置卷名 emptyDir: {} # 临时卷(Pod 生命周期内) - name: workspace # 工作目录卷名 emptyDir: {} # 临时卷(Pod 生命周期内) --- apiVersion: v1 # Service 使用的核心 API 版本 kind: Service # Service 资源 metadata: # Service 元信息 name: openclaw-gateway # Service 名称 namespace: openclaw # 命名空间 spec: # Service 规格 selector: # 后端 Pod 选择器 app: openclaw-gateway # 选择 app=openclaw-gateway 的 Pod ports: # 端口映射列表 - port: 18789 # Service 暴露端口 targetPort: 18789 # 转发到容器端口 protocol: TCP # 协议 name: http # 端口名 --- apiVersion: networking.k8s.io/v1 # Ingress API 版本 kind: Ingress # 入口路由资源 metadata: # Ingress 元信息 name: openclaw-gateway # Ingress 名称 namespace: openclaw # 命名空间 annotations: # 控制器注解 traefik.ingress.kubernetes.io/router.entrypoints: web # 使用 Traefik web(HTTP) 入口 spec: # Ingress 规则 rules: # 规则列表 - host: openclaw-k3s.example.com # 访问域名(按环境修改) http: # HTTP 规则 paths: # 路径列表 - path: / # 根路径 pathType: Prefix # 前缀匹配 backend: # 后端目标 service: # 后端 Service name: openclaw-gateway # Service 名称 port: # Service 端口 number: 18789 # 端口号