Kubernetes ( k8s ) gRPC服务 健康检查
Dockerfile
### Install gRPC check
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.1 \
&& wget -O /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 \
&& chmod +x /bin/grpc_health_probe
deployment.yaml
spec:
containers:
- name: xxx
image: xxx
ports:
- containerPort: 8090
name: gRPC
protocol: TCP
# 就绪检查
readinessProbe:
initialDelaySeconds: 30 # 延迟探测时间(秒)【 在k8s第一次探测前等待秒 】
periodSeconds: 2 # 执行探测频率(秒) 【 每隔秒执行一次 】
timeoutSeconds: 1 # 超时时间
successThreshold: 1 # 健康阀值
failureThreshold: 3 # 不健康阀值
exec:
command: ["/bin/grpc_health_probe", "-addr=:8090"] # gRPC检查
# 存活检查
livenessProbe:
initialDelaySeconds: 30 # 延迟探测时间(秒) 【 在k8s第一次探测前等待秒 】
periodSeconds: 10 # 执行探测频率(秒) 【 每隔秒执行一次 】
timeoutSeconds: 1 # 超时时间
successThreshold: 1 # 健康阀值
failureThreshold: 3 # 不健康阀值
exec:
command: ["/bin/grpc_health_probe", "-addr=:8090"] # gRPC检查
检测返回值
$ kubectl -n linuxhub-prd exec -it zeze-linuxhub-fb456bdb5-88mlf sh
# /bin/grpc_health_probe -addr=:8090
status: SERVING
/ # grpc_health_probe-linux-amd64 -addr zeze-linuxhub:8090
status: SERVING
网友评论