Some checks failed
Build and Deploy Backend / build-and-deploy (push) Failing after 4m28s
## 变更内容
### k8s/ingress.yaml
- 新增 /xiaozhi/v1/ 路径规则,将 WebSocket 流量路由到 hw-ws-svc:8888
- Traefik 最长前缀优先,/xiaozhi/v1/ 不影响 / 下的 Django 路由
### hw_service_go/k8s/service.yaml
- Service 类型由 LoadBalancer 改为 ClusterIP
- 移除阿里云 SLB 注解(通过 Traefik Ingress 统一暴露,不再需要独立公网 IP)
### hw_service_go/k8s/deployment.yaml
- 镜像地址改为 ${CI_REGISTRY_IMAGE}/hw-ws-service:latest 占位符
- CI/CD 部署时统一通过 sed 替换为华为云 SWR 实际地址
### hw_service_go/internal/server/server.go
- 新增 GET /xiaozhi/v1/healthz 接口,返回 {"status":"ok","active_connections":N}
- 用于部署后验证服务存活及当前连接数
### .gitea/workflows/deploy.yaml
- 新增 Build and Push HW WebSocket Service 步骤,构建并推送 hw_service_go 镜像
- 部署步骤新增 kubectl apply hw_service_go/k8s/deployment.yaml 和 service.yaml
- 新增 kubectl rollout restart deployment/hw-ws-service
### run.sh
- 本地同时启动 Django + hw_service_go 的开发脚本
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
83 lines
2.3 KiB
YAML
83 lines
2.3 KiB
YAML
apiVersion: apps/v1
|
||
kind: Deployment
|
||
metadata:
|
||
name: hw-ws-service
|
||
labels:
|
||
app: hw-ws-service
|
||
spec:
|
||
replicas: 2
|
||
selector:
|
||
matchLabels:
|
||
app: hw-ws-service
|
||
# WebSocket 连接有状态,滚动更新时使用 Recreate 或 RollingUpdate + 优雅关闭
|
||
strategy:
|
||
type: RollingUpdate
|
||
rollingUpdate:
|
||
maxUnavailable: 0 # 始终保持至少 2 个 Pod 可用
|
||
maxSurge: 1
|
||
template:
|
||
metadata:
|
||
labels:
|
||
app: hw-ws-service
|
||
spec:
|
||
# 优雅关闭总时限:90s(服务内部等待 80s,留 10s 缓冲)
|
||
terminationGracePeriodSeconds: 90
|
||
|
||
containers:
|
||
- name: hw-ws-service
|
||
image: ${CI_REGISTRY_IMAGE}/hw-ws-service:latest
|
||
imagePullPolicy: Always
|
||
ports:
|
||
- name: ws
|
||
containerPort: 8888
|
||
protocol: TCP
|
||
|
||
env:
|
||
- name: HW_WS_HOST
|
||
value: "0.0.0.0"
|
||
- name: HW_WS_PORT
|
||
value: "8888"
|
||
- name: HW_RTC_BACKEND_URL
|
||
# 集群内部直接访问 rtc-backend Service,不走公网
|
||
value: "http://rtc-backend-svc:8000"
|
||
|
||
lifecycle:
|
||
preStop:
|
||
exec:
|
||
# 等待 5s 让 LB/Ingress 将流量从本 Pod 摘除,再开始关闭
|
||
command: ["/bin/sh", "-c", "sleep 5"]
|
||
|
||
# 就绪探针:TCP 握手成功才接流量
|
||
readinessProbe:
|
||
tcpSocket:
|
||
port: 8888
|
||
initialDelaySeconds: 3
|
||
periodSeconds: 5
|
||
failureThreshold: 3
|
||
|
||
# 存活探针:连续失败 3 次才重启(避免短暂抖动误杀)
|
||
livenessProbe:
|
||
tcpSocket:
|
||
port: 8888
|
||
initialDelaySeconds: 10
|
||
periodSeconds: 15
|
||
failureThreshold: 3
|
||
|
||
# 资源限制(根据实际负载调整)
|
||
resources:
|
||
requests:
|
||
cpu: "100m"
|
||
memory: "128Mi"
|
||
limits:
|
||
cpu: "500m"
|
||
memory: "512Mi"
|
||
|
||
# 优先调度到不同节点,避免单点故障
|
||
topologySpreadConstraints:
|
||
- maxSkew: 1
|
||
topologyKey: kubernetes.io/hostname
|
||
whenUnsatisfiable: DoNotSchedule
|
||
labelSelector:
|
||
matchLabels:
|
||
app: hw-ws-service
|