deployment.yaml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. # release: <release>
  17. template:
  18. metadata:
  19. labels:
  20. app: <service_name><service_version>
  21. # release: <release>
  22. annotations:
  23. commit-sha: "<COMMIT_SHA>"
  24. spec:
  25. imagePullSecrets:
  26. - name: <imagePullSecret>
  27. containers:
  28. - name: <service_name>
  29. image: <docker_image>
  30. command: ["java"]
  31. args: <java_args>
  32. readinessProbe:
  33. httpGet:
  34. path: <service_health>
  35. port: 80
  36. initialDelaySeconds: 30
  37. periodSeconds: 30
  38. failureThreshold: 3
  39. ports:
  40. - name: http
  41. containerPort: 80
  42. envFrom:
  43. - configMapRef:
  44. name: <configmap_env_name>