k8s之存活探针与就绪探针文件模板

就绪探测

readinessProbe-httpget(基于httpGet的就绪探测)

spec:
  containers:
    - image: test/test
      imagePullPolicy: IfNotPresent
      readinessProbe:
        httpGet:                   #用的是httpGet的方案
          path: /index.html
          port: 80
          scheme: HTTP
        initialDelaySeconds: 5     #容器启动后5秒开始检测
        periodSeconds: 5           #重试间隔 每隔5秒检测一次
        timeoutSeconds: 4          #超时时间:4秒不给应答就算失败

存活探测

livenessProbe-httpGet方式 (存活探针httpget方式):

spec:
  containers:
    - image: test/test
      imagePullPolicy: IfNotPresent
      livenessProbe:            #存活探针
        httpGet:                 #用的是httpGet的方案
          path: /index.html      #检测的容器内网页文件路径
          port: 80               #检测的容器内端口
          scheme: HTTP           #端口别名  写不写无所谓
        initialDelaySeconds: 10  #容器启动后10秒开始检测
        periodSeconds: 10         #重试间隔 每隔10秒检测一次
        timeoutSeconds: 9       #超时时间:9秒不给应答就算失败

livenessProbe-tcp方式(存活探针tcp方式):

 spec:
  containers:
    - image: test/test
      imagePullPolicy: IfNotPresent
      livenessProbe:            #存活探针
        tcpSocket:               #基于tcpSocket方案检测
          port: 80
        initialDelaySeconds: 10  #容器启动后10秒开始检测
        periodSeconds: 10         #重试间隔 每隔10秒检测一次
        timeoutSeconds: 9       #超时时间:9秒不给应答就算失败

livenessProbe-exec (存活探针exec方式):

spec:
  containers:
    - image: test/test
      imagePullPolicy: IfNotPresent
      livenessProbe:            #存活探针
        exec:
          command: ["test","-e","/tmp/live"]   #判断该文件是否存在,存在为真,不存在返回-1
        initialDelaySeconds: 10  #容器启动后10秒开始检测
        periodSeconds: 10         #重试间隔 每隔10秒检测一次

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个真正的幔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值