部署HPA(Horizo ntal Pod Autoscaler)的自定义指标(http请求)?

问题描述 投票:0回答:1

我正在使用基于http请求的HPA算法部署我的应用程序。我跟着这个link。在“基于自定义指标的Auto Scaling”部分中。我用他们的应用程序成功构建了但是当我使用我的应用程序部署时,我收到错误:

$ kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/http_requests" | jq .
Error from server (NotFound): the server could not find the metric http_requests for pods

在这部分中,他们说“podinfo app公开了一个名为http_requests_total的自定义指标”。那么,我的应用程序如何公开这样的自定义指标呢?非常感谢!

kubernetes prometheus
1个回答
0
投票

您可以找到有关此部署here的更多信息。 另一个如何为自定义指标构建应用程序的示例,您可以找到herehere。 在这两种情况下都使用“Golang Client API

在您的教程的示例中,端口9898上有工作应用程序 tcp 0 0 ::: 9898 ::: * LISTEN 1 / podinfo

如果您不确定您的应用程序是否正常运行,请验证:

    kubectl get deploy,pods
    -- verify if your new deployment is working properly 
    kubectl describe <your pod>
    -- in case of any issues with your application:
    kubectl logs <your pod>
    -- if the port and an endpoint are the same as in the example
    curl <your pod ip (endpoint)>:9898/metrics 
       you should notice http_requests_total metrics: htp_requests_total{status="200"} 1926 
    -- for generall issues
    kubectl get events

请与您的调查结果和结果分享。

© www.soinside.com 2019 - 2024. All rights reserved.