k8s - livenessProbe - tcp存活性检测

yaml文件中定义检测端口为8090,因nginx启动为80端口,所以容器启动5秒后,开始检测,检测发起连接8090端口,1秒后超时检测失败

[root@k8s-master01 k8s-test]# cat livenessProbe-tcp.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: liveness-tcp
  namespace: default
spec:
  containers:
  - name: liveness-tcp-container
    image: kone.com/library/nginx
    imagePullPolicy: IfNotPresent
    livenessProbe:
      initialDelaySeconds: 5
      timeoutSeconds: 1
      tcpSocket:
        port: 8090
      periodSeconds: 3
[root@k8s-master01 k8s-test]# 

查看liveness-tcp容器在不停的重启


[root@k8s-master01 k8s-test]# kubectl get pod -w 
NAME                               READY   STATUS      RESTARTS   AGE
liveness-tcp                       1/1     Running     0          11s
liveness-tcp                       1/1     Running     1          15s
liveness-tcp                       1/1     Running     2          28s

你可能感兴趣的:(k8s - livenessProbe - tcp存活性检测)