老男孩教育linux81期-15k金牌企业级班级
如下配置文件,使用 exec 的方式使用 cat /tmp/healthy
检查容器的存活性。
apiVersion: v1kind: Podmetadata:
name: exec-healthyspec:
containers:
- name: nginx image: 172.16.156.128:5000/nginx:1.13
ports:
- containerPort: 80
args: # 执行命令,先创建文件,隔 30s 后删除文件。
- /bin/bash - -c - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 60 livenessProbe:
exec:
command:
- cat - /tmp/healthy initialDelaySeconds: 5 # 健康检查的初始间隔
periodSeconds: 5 # 每 5s 检查一次