kubernetes probe

概述

readinessProbe主要探测服务是否就绪,如果你的应用的readinessProbe运行失败,那么就会从组成service的端点中删除,这样就不会有流量通过Kubernetes服务发现机制来发送给它

livenessProbe探测服务是否可,不可用时重启pod

参数

  • initialDelaySeconds:容器启动后,第一次执行探测需要等待多少秒
  • periodSeconds:执行探测的频率,默认是10秒,最小1秒
  • timeoutSeconds:探测超时时间,告诉Kubernetes应该为健康检查等待多长时间,默认1秒,最小1秒

官方文档: https://kubernetes.io/docs/ta...

支持的类型

http 请求

spec:
  containers:
  - name: liveness
    args:
    - /server
    image: gcr.io/google_containers/liveness
    readinessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
          - name: X-Custom-Header
            value: Awesome
      initialDelaySeconds: 20
      periodSeconds: 10
      timeouteSeconds: 1
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
          - name: X-Custom-Header
            value: Awesome
      initialDelaySeconds: 20
      periodSeconds: 10
      timeouteSeconds: 1

tcp 端口

spec:
  containers:
  - name: goproxy
    image: gcr.io/google_containers/goproxy:0.1
    ports:
    - containerPort: 8080
    readinessProbe:
      tcpSocket:
        port: 8080
      initialDelaySeconds: 20
      periodSeconds: 10
      timeoutSeconds: 1
    livenessProbe:
      tcpSocket:
        port: 8080
      initialDelaySeconds: 20
      periodSeconds: 10
      timeoutSeconds: 1

sh命令或shell脚本

spec:
  containers:
  - name: liveness
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
    image: gcr.io/google_containers/busybox
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值