就绪探测
readinessProbe-httpget(基于httpGet的就绪探测)
spec:
containers:
- image: test/test
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet: #用的是httpGet的方案
path: /index.html
port: 80
scheme: HTTP
initialDelaySeconds: 5 #容器启动后5秒开始检测
periodSeconds: 5 #重试间隔 每隔5秒检测一次
timeoutSeconds: 4 #超时时间:4秒不给应答就算失败
存活探测
livenessProbe-httpGet方式 (存活探针httpget方式):
spec:
containers:
- image: test/test
imagePullPolicy: IfNotPresent
livenessProbe: #存活探针
httpGet: #用的是httpGet的方案
path: /index.html #检测的容器内网页文件路径
port: 80 #检测的容器内端口
scheme: HTTP #端口别名 写不写无所谓
initialDelaySeconds: 10 #容器启动后10秒开始检测
periodSeconds: 10 #重试间隔 每隔10秒检测一次
timeoutSeconds: 9 #超时时间:9秒不给应答就算失败
livenessProbe-tcp方式(存活探针tcp方式):
spec:
containers:
- image: test/test
imagePullPolicy: IfNotPresent
livenessProbe: #存活探针
tcpSocket: #基于tcpSocket方案检测
port: 80
initialDelaySeconds: 10 #容器启动后10秒开始检测
periodSeconds: 10 #重试间隔 每隔10秒检测一次
timeoutSeconds: 9 #超时时间:9秒不给应答就算失败
livenessProbe-exec (存活探针exec方式):
spec:
containers:
- image: test/test
imagePullPolicy: IfNotPresent
livenessProbe: #存活探针
exec:
command: ["test","-e","/tmp/live"] #判断该文件是否存在,存在为真,不存在返回-1
initialDelaySeconds: 10 #容器启动后10秒开始检测
periodSeconds: 10 #重试间隔 每隔10秒检测一次