deployment.yaml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: <service_name><service_version>
  5. namespace: default
  6. spec:
  7. strategy:
  8. type: RollingUpdate
  9. rollingUpdate:
  10. maxSurge: 1 # 每次只新增 1 个 Pod(逐步替换)
  11. maxUnavailable: 0 # 确保任何时刻所有 Pod 都可用
  12. minReadySeconds: 60 # 新 Pod Ready 后至少保持 60 秒才认为更新完成
  13. selector:
  14. matchLabels:
  15. app: <service_name><service_version>
  16. template:
  17. metadata:
  18. labels:
  19. app: <service_name><service_version>
  20. annotations:
  21. commit-sha: "<COMMIT_SHA>"
  22. spec:
  23. terminationGracePeriodSeconds: 120 # 默认30秒,延长至60秒或其他值
  24. imagePullSecrets:
  25. - name: <imagePullSecret>
  26. containers:
  27. - name: <service_name>
  28. image: <docker_image>
  29. command: ["java"]
  30. args: <java_args>
  31. readinessProbe:
  32. httpGet:
  33. path: <service_health>
  34. port: 80
  35. initialDelaySeconds: 15
  36. periodSeconds: 30
  37. failureThreshold: 3
  38. ports:
  39. - name: http
  40. containerPort: 80
  41. envFrom:
  42. - configMapRef:
  43. name: <configmap_env_name>
  44. volumeMounts:
  45. - name: config-volume
  46. mountPath: /app/configs
  47. volumes:
  48. - name: config-volume
  49. configMap:
  50. name: <configmap_conf_name>