readinessProbe & livenessProbe Demo

readinessProbe & livenessProbe 三种检测方式

  • httpGet:发送http请求检查服务是否正常,返回200-399状态码说明容器为健康状态。
  • tcpSocket:执行容器的IP和Port的TCP检查,如果能够建立TCP连接,则容器为健康状态。
  • exec:执行命令来检查服务是否正常,预定的命令执行成功返回值为0说明容器为健康状态。

httpGet demo1

    readinessProbe:
      httpGet:
        path: /test
        port: 8080
      initialDelaySeconds: 30
      timeoutSeconds: 30
    livenessProbe:
      httpGet:
        path: /test
        port: 8080
      initialDelaySeconds: 30
      timeoutSeconds: 30

httpGet demo2

    livenessProbe:
      httpGet:
        path: /test
        port: 8080
        httpHeaders:
        - name: X-Custom-Header
          value: Awesome
      initialDelaySeconds: 5
      periodSeconds: 5

tcpSocket demo

    readinessProbe:
      tcpSocket:
        port: 3306
      initialDelaySeconds: 5
      periodSeconds: 10
    livenessProbe:
      tcpSocket:
        port: 3306
      initialDelaySeconds: 15
      periodSeconds: 20

exec demo

    livenessProbe:
      exec:
        command:
        - cat
        - /app/test-healthy
      initialDelaySeconds: 10
      periodSeconds: 10
    readinessProbe:
      exec:
        command:
        - cat
        - /app/test-healthy
      initialDelaySeconds: 10
      periodSeconds: 10

相关属性

  • initialDelaySeconds:Pod启动后延迟多少秒才进行检查
  • periodSeconds:检查的间隔时间,默认为10秒
  • timeoutSeconds:探测的超时时间,默认为1秒
  • successThreshold:探测失败后认为成功的最小连接成功次数,默认为1,在Liveness探针中必须为1,最小值为1。
  • failureThreshold:探测失败的重试次数,重试一定次数后将认为失败,在readiness探针中,Pod会被标记为未就绪,默认为3,最小值为1。
本作品采用《CC 协议》,转载必须注明作者和本文链接
:kissing_closed_eyes: 我爱小砚 乀(ˉεˉ乀)
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!