如何将我的部署配置为对sprint引导执行器端点进行健康检查?我使用的是在端口9000上运行的spring 2。(PS:前港测试工程)
这是一个错误:
Readiness probe failed: Get http://10.48.0.116:9000/actuator/health: dial tcp 10.48.0.116:9000: connect: connection refused这就是我的部署yml:
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: my-api
namespace: vidolin
labels:
stack: api
app: my-api
spec:
replicas: 1
selector:
matchLabels:
stack: api
app: my-api
template:
metadata:
labels:
stack: api
app: my-api
spec:
imagePullSecrets:
- name: itdevregistry
containers:
- name: primary
image: vidolinregistry.azurecr.io/my/api
ports:
- containerPort: 9000
envFrom:
- configMapRef:
name: my-api-config
readinessProbe:
httpGet:
path: /actuator/health
port: 9000
initialDelaySeconds: 10
timeoutSeconds: 2
periodSeconds: 3
failureThreshold: 1
livenessProbe:
httpGet:
path: /actuator/health
port: 9000
initialDelaySeconds: 20
timeoutSeconds: 2
periodSeconds: 8
failureThreshold: 1发布于 2019-12-24 23:58:48
虽然我的答复有点晚了。但我认为我的实现将帮助人们在未来实现kubernetes准备/活动探测spring引导应用程序。
我的码头形象描述
所以我不能使用kubernetes的httpGet选项,因为它只使用http协议.
这就是为什么我创建一个小的shell脚本“Check-if-Health.sh”作为docker映像的一部分,以了解状态。
check-if-healthy.sh
===================
curl -k https://localhost:8888/actuator/health | grep '"status":"UP"' > /dev/null && exit 0 || exit 1请注意,您需要将此脚本添加到docker映像中,以便它在运行的容器中可用,并可由kubernetes访问,因为kubernetes将像这样激发"docker /bin/ash“
COPY docker/check-if-healthy.sh /home/config-server/check-if-healthy.sh然后使用kubernetes就绪探测的"exec“选项来像这样调用脚本。
readinessProbe:
exec:
command:
- /bin/ash
- /home/config-server/check-if-healthy.sh
initialDelaySeconds: 5
timeoutSeconds: 1
failureThreshold: 50
livenessProbe:
exec:
command:
- /bin/ash
- /home/config-server/check-if-healthy.sh
initialDelaySeconds: 5
timeoutSeconds: 1
failureThreshold: 50https://stackoverflow.com/questions/57320733
复制相似问题