美文网首页
Liveness Readiness

Liveness Readiness

作者: 白敏鸢 | 来源:发表于2018-05-18 15:26 被阅读0次

    首先看看k8s官方的解释

    The kubelet uses liveness probes to know when to restart a Container. For example, liveness probes could catch a deadlock, where an application is running, but unable to make progress. Restarting a Container in such a state can help to make the application more available despite bugs.

    k8s本身有强大的恢复能力,通过控制副本数目,可以控制pod在cluster。
    Liveness :k8s对于服务健康性的检查
    Readiness :k8s对于就绪的检查,ok就加入负载池,等待k8s调度

    以前有k8s这部分的说明,今天记录另外不常用几个参数。

    initialDelaySeconds: Number of seconds after the container has started before liveness or readiness probes are initiated.
    
    periodSeconds: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.
    
    timeoutSeconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1.
    
    successThreshold: Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness. Minimum value is 1.
    
    failureThreshold: When a Pod starts and the probe fails, Kubernetes will try failureThreshold times before giving up. 
    Giving up in case of liveness probe means restarting the Pod. In case of readiness probe the Pod will be marked Unready. Defaults to 3. Minimum value is 1.
    

    successThreshold:k8s认为一个资源正常的探针最少正常检查正常数
    failureThreshold:k8s任务一个 不正常的最少失败的检查数

    httpGet部分制定探针的探测路径

    HTTP probes have additional fields that can be set on httpGet:

    • host: Host name to connect to, defaults to the pod IP. You probably want to set “Host” in httpHeaders instead.
    • scheme: Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.
    • path: Path to access on the HTTP server.
    • httpHeaders: Custom headers to set in the request. HTTP allows repeated headers.
    • port: Name or number of the port to access on the container. Number must be in the range 1 to 65535.

    example

    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
    

    相关文章

      网友评论

          本文标题:Liveness Readiness

          本文链接:https://www.haomeiwen.com/subject/rwpgdftx.html