Files
dailyLove/deployment-temp.yml
bamanker 06cfebccab
All checks were successful
Build Push and Deploy Image / build (push) Successful in 22m32s
增加探针配置
2026-01-08 13:59:30 +08:00

102 lines
3.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: $APP_NAME # 标签 用于选择器
version: $APP_TAG
name: $APP_NAME # Deployment名称
namespace: default # 一定要写名称空间
spec:
progressDeadlineSeconds: 600
replicas: 1 # 副本数 1个 pod
revisionHistoryLimit: 2
selector:
matchLabels:
app: $APP_NAME # 选择器 匹配 pod 标签
strategy:
rollingUpdate:
maxSurge: 50%
maxUnavailable: 50%
type: RollingUpdate
template:
metadata:
labels:
app: $APP_NAME # pod 标签
version: $APP_TAG
spec:
imagePullSecrets:
- name: dockerhub-id #提前在项目下配置访问私有镜像仓库的账号密码
containers:
- name: $APP_NAME # 容器名称
image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG # 镜像地址
imagePullPolicy: Always
# 存活探针配置
livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复
httpGet:
path: /actuator/health/liveness # 探针路径
port: 13145 # 探针端口
scheme: HTTP # 协议
initialDelaySeconds: 20 # 容器启动后延迟 xx秒开始检查
periodSeconds: 10 # 每隔 15秒检查一次
timeoutSeconds: 5 # 10秒未返回结果则超时
# successThreshold: 1 # 成功 1 次就认定为健康
failureThreshold: 3 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败,重启容器
#就绪探针配置
readinessProbe:
httpGet:
path: /actuator/health/readiness # 探针路径
port: 13145 # 探针端口
scheme: HTTP # 协议
initialDelaySeconds: 10 # 容器启动后等 30 秒再开始检查
periodSeconds: 5 # 每 5 秒检查一次,比存活探针频繁
timeoutSeconds: 5 # 超时时间 3 秒
# successThreshold: 1 # 成功 1 次就认为就绪
failureThreshold: 2 # 失败 3 次才认为未就绪,会从负载均衡摘掉
# 启动探针配置(可选,启动慢的应用必须配)
# startupProbe:
# httpGet:
# path: /actuator/health/liveness # 用存活探针的路径
# port: 13145
# scheme: HTTP
# initialDelaySeconds: 0 # 立即开始检查
# periodSeconds: 5 # 每 5 秒检查一次
# timeoutSeconds: 3 # 超时时间 3 秒
# successThreshold: 1 # 成功 1 次就认为启动完成
# failureThreshold: 30 # 失败 30 次150 秒)才认为启动失败
# 生命周期钩子,优雅关闭
lifecycle:
preStop:
sleep:
seconds: 10 #容器停止前先等 10 秒,让流量切走
ports:
- containerPort: 13145 # 应用端口
protocol: TCP
# 资源限制
resources:
limits:
cpu: 99m # 最多 0.1核 CPU
memory: 65Mi # 最多 65m 内存
# 环境变量配置
env:
- name: TZ
value: "Asia/Shanghai"
---
apiVersion: v1
kind: Service
metadata:
labels:
app: $APP_NAME
name: $APP_NAME
namespace: default
spec:
type: NodePort
externalTrafficPolicy: Local
ports:
- name: http
protocol: TCP
port: 13145
nodePort: 30045
selector:
app: $APP_NAME