容器外的Kubernetes健康检查

时间:2018-11-30 11:50:05

标签: kubernetes kubernetes-health-check

我可以从包装箱中进行生命力或准备状态的健康检查吗?我的意思是,在无法访问应用程序的情况下,可以停止到Pod的流量并重新启动容器。

1 个答案:

答案 0 :(得分:1)

“ Http请求活动性”探针和“ TCP活动性”探针可用于查看您是否可以从外部访问在容器内部运行的应用程序:

pods/probe/http-liveness.yaml

apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-http
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/liveness
    args:
    - /server
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
        - name: X-Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3

请参见this piece of documentation on configuring probes。可以回答您的问题吗?