This commit is contained in:
@@ -2,17 +2,17 @@ apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: $APP_NAME
|
||||
app: $APP_NAME # 标签 用于选择器
|
||||
version: $APP_TAG
|
||||
name: $APP_NAME
|
||||
namespace: default #一定要写名称空间
|
||||
name: $APP_NAME # Deployment名称
|
||||
namespace: default # 一定要写名称空间
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
replicas: 1 # 副本数 1个 pod
|
||||
revisionHistoryLimit: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: $APP_NAME
|
||||
app: $APP_NAME # 选择器 匹配 pod 标签
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 50%
|
||||
@@ -21,31 +21,62 @@ spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: $APP_NAME
|
||||
app: $APP_NAME # pod 标签
|
||||
version: $APP_TAG
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: dockerhub-id #提前在项目下配置访问阿里云的账号密码
|
||||
- name: dockerhub-id #提前在项目下配置访问私有镜像仓库的账号密码
|
||||
containers:
|
||||
- image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG
|
||||
name: $APP_NAME
|
||||
- name: $APP_NAME # 容器名称
|
||||
image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG # 镜像地址
|
||||
imagePullPolicy: Always
|
||||
# 存活探针配置
|
||||
livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复
|
||||
httpGet:
|
||||
path: /test
|
||||
port: 13145
|
||||
initialDelaySeconds: 10 # 延迟xx秒开始执行
|
||||
periodSeconds: 15 # 每隔15秒执行一次
|
||||
timeoutSeconds: 10 # 10秒未返回结果则超时
|
||||
failureThreshold: 10 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败
|
||||
# successThreshold: 5
|
||||
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
|
||||
- containerPort: 13145 # 应用端口
|
||||
protocol: TCP
|
||||
# 资源限制
|
||||
resources:
|
||||
limits:
|
||||
cpu: 99m
|
||||
memory: 65Mi
|
||||
cpu: 99m # 最多 0.1核 CPU
|
||||
memory: 65Mi # 最多 65m 内存
|
||||
# 环境变量配置
|
||||
env:
|
||||
- name: TZ
|
||||
value: "Asia/Shanghai"
|
||||
|
||||
5
pom.xml
5
pom.xml
@@ -87,6 +87,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<!-- Spring Boot Actuator,提供健康检查端点 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>dailylove</finalName>
|
||||
|
||||
@@ -56,4 +56,25 @@ logging:
|
||||
level:
|
||||
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
||||
|
||||
scanclass: false
|
||||
scanclass: false
|
||||
|
||||
# Actuator 配置
|
||||
management:
|
||||
# 端点配置
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
# 暴露健康端点,生产环境要慎重,别把敏感信息暴露了
|
||||
include: health,info
|
||||
# 健康端点配置
|
||||
endpoint:
|
||||
health:
|
||||
# 显示详细的健康信息,方便调试
|
||||
# 生产环境建议设为 when-authorized,需要认证才能看详情
|
||||
show-details: always
|
||||
# 开启探针支持,这个必须设置
|
||||
probes:
|
||||
enabled: true
|
||||
# 在主端口上也暴露探针路径
|
||||
# 这样 K8s 探针可以直接访问应用端口,不用单独配置 management 端口
|
||||
add-additional-paths: true
|
||||
Reference in New Issue
Block a user