k8s之Probe
概述
readinessProbe主要探测服务是否就绪,如果你的应用的readinessProbe运行失败,那么就会从组成service的端点中删除,这样就不会有流量通过Kubernetes服务发现机制来发送给它
livenessProbe探测服务是否可,不可用时重启pod
参数
- initialDelaySeconds:容器启动后,第一次执行探测需要等待多少秒
- periodSeconds:执行探测的频率,默认是10秒,最小1秒
- timeoutSeconds:探测超时时间,告诉Kubernetes应该为健康检查等待多长时间,默认1秒,最小1秒
官方文档: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/
支持的类型
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
相关推荐
kunyus 2020-10-28
hubanbei00的家园 2020-10-25
btqszl 2020-10-21
shurenyun 2020-08-19
CurrentJ 2020-08-18
朱培知浅ZLH 2020-11-16
cdbdqn00 2020-11-12
达观数据 2020-11-11
JustinChia 2020-11-11
远远的山 2020-11-09
jingtao 2020-11-08
大叔比较胖 2020-10-30
gracecxj 2020-10-30
onepiecedn 2020-10-29
JustHaveTry 2020-10-27
锋锋 2020-10-26
谢恩铭 2020-10-23
kaidiphp 2020-10-13
guchengxinfen 2020-10-12