pod健康检测 方法:
exec
http
tcpSocket
1) liveness-exec.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: liveness-exec
labels:
app: liveness
spec:
containers:
- name: liveness
image: busybox
args:
- /bin/sh
- -c
- touch /tmp/healthy;sleep 30; rm -rf /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
2)liveness-http.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: liveness-http
labels:
app: liveness
spec:
containers:
- name: liveness
image: cnych/liveness
args:
- /server
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
3)tcpSocket方式检测
---
apiVersion: v1
kind: Pod
metadata:
name: liveness-readiness
labels:
app: liveness-readiness
spec:
containers:
- name: liveness-readiness
image: cnych/liveness
args:
- /server
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
tcpSocket:
port:8080
initialDelaySeconds: 3
perioidSeconds: 3