kubelet健康检查的3种方式

发布时间 2023-07-16 10:50:58作者: 王景迁

httpGet

发送一个 HTTP 请求,当返回码介于 200~400 之间时,检查成功。

livenessProbe:
  httpGet:
    path: /index.html
    port: 80
    httpHeaders:
    - name: X-Custom-Header
      value: Awesome
  initialDelaySeconds: 5
  periodSeconds: 5

exec

在容器中执行指定的命令进行检查,当命令执行成功(返回码为 0),检查成功。

livenessProbe:
  exec:
    command:
    - cat
    - /tmp/healthy
  initialDelaySeconds: 5
  periodSeconds: 5

tcpSocket

对于容器中的指定 TCP 端口进行检查,当 TCP 连接顺利,检查成功。

livenessProbe:
  tcpSocket:
    port: 8080
  initialDelaySeconds: 15
  periodSeconds: 20