k8s学习过程中需要注意的地方

1、健康检查

livenessProbe(存活探针):捕获当前应用程序运行状态,如崩溃,会重启。
readinessProbe(可读性探针):确定容器是否已经就绪可以接收流量
三种检查方式:exec、httpGet、tcpSocket

* exec: 执行一段命令

* http: 检测某个http请求

* tcpSocket: 使用此配置,kubelet将尝试在指定端口上打开容器的套接字。如果可以建立连接,容器被认为是健康的,如果不能就认为是失败的。实际上就是检查端口

示例:

---
    livenessProbe:
      exec:
        command:
          - cat
          - /tmp/healthy
      initialDelaySeconds: 5 #表示在第1次执行探针的时候要等待5秒
      periodSeconds: 5 #每隔5秒执行livenessProbe
---
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 5
    readinessProbe:
      tcpSocket:
        port: 8080
      initialDelaySeconds: 3
      periodSeconds: 3

猜你喜欢

转载自www.cnblogs.com/cpw6/p/12581817.html