【问题标题】:Kubernetes livenessProbe http result?Kubernetes livenessProbe http 结果?
【发布时间】:2017-11-06 03:13:15
【问题描述】:

我们有一个 HTTP livenessProbe 设置,如果服务不健康,它会返回 500,并打印出问题所在。
有没有办法查看livenessProbe返回的输出?

我可以在应用程序中记录它,但也许可以从 Kubernetes 中查看?

目前,我看到的唯一一件事是pod describe

Killing container with id docker://12568746c312e6646fd6ecdb2123db448be0bc6808629b1a63ced8b7298be444:pod "test-3893895584-7f4cr_test(524091bd-49d8-11e7-bd00-42010a840224)" container "test" is unhealthy, it will be killed and re-created.

在 GKE 上运行

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    很遗憾,似乎没有办法访问失败的 HTTP 探测的 HTTP 响应正文。

    为了证实这个怀疑,让我们看一下在 Kubelet 守护进程中运行的 HTTP Prober's source code

    func DoHTTPProbe(url *url.URL, headers http.Header, client HTTPGetInterface) (probe.Result, string, error) {
        // ...
        body := string(b)
        if res.StatusCode >= http.StatusOK && res.StatusCode < http.StatusBadRequest {
            glog.V(4).Infof("Probe succeeded for %s, Response: %v", url.String(), *res)
            return probe.Success, body, nil
        }
        glog.V(4).Infof("Probe failed for %s with request headers %v, response body: %v", url.String(), headers, body)
        return probe.Failure, fmt.Sprintf("HTTP probe failed with statuscode: %d", res.StatusCode), nil
    }
    

    如您所见,Kubelet 守护程序会将失败探测的 HTTP 响应正文记录在其自己的日志中,但即使如此,也只有在详细程度设置为 4 或更高的情况下。除了将响应记录在自己的日志中之外,它不会从 DoHTTPProbe 方法传回,也不会被 Kubelet 进一步处理。

    正如您自己已经指出的那样,我认为您最安全的选择是从应用程序本身记录您需要的数据。

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-21
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      • 2020-10-12
      相关资源
      最近更新 更多