一、探针(容器在启动后中间做的事)给自己的
livenessProbe
命令模式探针
如果起不来,docker可以起来,k8s不行,可能是探针时间问题,还有可能是电脑配置
-
-
kind: Pod
metadata:
labels:
name: centos
spec:
containers:- name: centos
image: centos:7
command:- tail
- -f
- /dev/null
livenessProbe: #探针,健康检查
exec: #类型
command: #命令- cat
- /root/anaconda-ks.cfg
initialDelaySeconds: 5 #健康检查,在容器启动5s后开始执行
periodSeconds: 5 #每5s执行一次
重启,k8s就是删除重建
-
-
httpget方式探针
[root@kub-k8s-master prome]# vim liveness-httpget.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: default
spec:
containers:
- name: nginx
image: nginx:1.16.1
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
livenessProbe: #探针,健康检查
httpGet:
port: http
path: /index.html
initialDelaySeconds: 1