1、 pod的健康检查有两类探针
- LivenessProbe: 判断容器是否running。 如果不包含LivenessProbe,则认为永远是true
- ReadnessProbe: 判断容器是否ready,如果失败, Endpoint 将删之
2、 LivenessProbe的三种实现方式
- ExecAction: 在容器执行命令,如果返回0,则认为健康
pod-livenessprobe.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-exec
spec:
containers:
- name: liveness
image: gcr.io/google_containers/busybox
args:
- /bin/sh
- -c
- echo ok > /tmp/health; sleep 10; rm -rf /tmp/health; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/health
initialDelaySeconds: 15
timeoutSeconds: 1
apiVersion: v1
kind: Pod
metadata:
name: pod-with-healthcheck
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
livenessProbe:
tcpSocket:
port: 80
initialDelaySeconds: 30
timeoutSeconds: 1
网友评论