kind: Deployment apiVersion: apps/v1 metadata: name: ankao namespace: default spec: selector: matchLabels: app: ankao replicas: 1 template: metadata: labels: app: ankao spec: imagePullSecrets: - name: aliyun containers: - name: ankao image: registry.cn-qingdao.aliyuncs.com/yuchat/ankao:0.0.9 env: - name: DB_HOST value: pgsql - name: DB_USERNAME value: postgres - name: DB_PASSWORD value: longqi@1314 - name: AI_BASE_URL value: http://new-api - name: AI_API_KEY value: sk-OKBmOpJx855juSOPU14cWG6Iz87tZQuv3Xg9PiaJYXdHoKcN - name: AI_MODEL value: deepseek-v3 ports: - containerPort: 8080 name: tcp-8080 # 存活探针 - 检测容器是否正在运行 # 如果失败,Kubernetes 会重启容器 livenessProbe: httpGet: path: /api/health port: 8080 scheme: HTTP initialDelaySeconds: 30 # 容器启动后等待30秒再开始探测 periodSeconds: 10 # 每10秒探测一次 timeoutSeconds: 5 # 探测超时时间5秒 successThreshold: 1 # 成功1次即认为成功 failureThreshold: 3 # 连续失败3次后重启容器 # 就绪探针 - 检测容器是否准备好接收流量 # 如果失败,会从 Service 负载均衡中移除 readinessProbe: httpGet: path: /api/health port: 8080 scheme: HTTP initialDelaySeconds: 10 # 容器启动后等待10秒再开始探测 periodSeconds: 5 # 每5秒探测一次 timeoutSeconds: 3 # 探测超时时间3秒 successThreshold: 1 # 成功1次即认为就绪 failureThreshold: 3 # 连续失败3次后标记为未就绪 # 启动探针 - 检测容器应用是否已经启动(可选) # 启动探针成功后,存活探针和就绪探针才会接管 startupProbe: httpGet: path: /api/health port: 8080 scheme: HTTP initialDelaySeconds: 0 # 立即开始探测 periodSeconds: 5 # 每5秒探测一次 timeoutSeconds: 3 # 探测超时时间3秒 successThreshold: 1 # 成功1次即认为启动完成 failureThreshold: 12 # 最多失败12次(60秒)才判定启动失败 # 资源限制(建议配置) resources: requests: memory: "256Mi" cpu: "100m" limits: memory: "512Mi" cpu: "500m" volumeMounts: - name: timezone mountPath: /etc/timezone readOnly: true - name: localtime mountPath: /etc/localtime readOnly: true volumes: - name: timezone hostPath: path: /etc/timezone type: File - name: localtime hostPath: path: /etc/localtime type: File restartPolicy: Always --- kind: Service apiVersion: v1 metadata: name: ankao namespace: default spec: selector: app: ankao ports: - name: tcp-80 port: 80 targetPort: 8080 type: LoadBalancer ipFamilyPolicy: PreferDualStack ipFamilies: - IPv4 - IPv6