原创-k8s 存活探针,就绪探针与启动探针

k8s使用存活探针livenessProbe进行pod存活性检测,使用就绪探针确保未就绪的pod不会被加入service的后端。启动探针确保程序启动后才开始剩下俩种探针的探测,启动探针一般用的比较少。

使用示例:

在spec.container下:

---

tcp探测

        livenessProbe:

         failureThreshold: 3 /失败三次算真正失败

         initialDelaySeconds: 30 /第一次探测等待30秒

         periodSeconds: 10 /每次间隔10秒

         successThreshold: 1 /成功一次算真正成功

         tcpSocket:

           port: 10018 /tcp探测10018

         timeoutSeconds: 2 /2秒算超时

---

http探测

    ports:

     - name: internal-port

       containerPort: 8080

       hostPort: 8080

 

    readinessProbe:

     failureThreshold: 5 /失败5次算真正失败

     httpGet:

       path: /health

       port: internal-port   /这里引用上面的ports信息

       scheme: HTTP

     initialDelaySeconds: 3 /第一次检测等待3秒

     periodSeconds: 5 /每次间隔5秒

     successThreshold: 1 /成功一次即成功

     timeoutSeconds: 1 /超时一秒失败一次

 

---

命令探测

livenessProbe:

     exec:

       command:

       - cat

       - /tmp/healthy

     initialDelaySeconds: 5 /第一次检测等待5秒

     periodSeconds: 5 /每5秒检测一次

 

 

 

 ---

参考文档:https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/

posted @ 2021-04-06 13:12  Normanlin  阅读(940)  评论(0编辑  收藏  举报