gpt4 book ai didi

kubernetes - kubectl 顶级节点显示错误 : metrics not available yet

转载 作者:行者123 更新时间:2023-12-04 01:02:03 24 4
gpt4 key购买 nike

我正在使用 Kubernetes 1.7 并运行 hepaster。当我跑

kubectl top nodes --heapster-namespace=kube-system

它向我展示了
error: metrics not available yet

我也试过这个
kubectl top nodes --heapster-namespace=kube-system --heapster-service=heapster --heapster-scheme=http --heapster-port=12213

在 heapster 运行的地方,它显示以下错误。
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get services http:heapster:12213)

任何解决错误的线索?

最佳答案

这意味着 heapster 没有正确配置。

您需要确保 heapster 在 kube-system 上运行命名空间,并检查 /healthz端点没问题:

$ export HEAPSTER_POD=$(kubectl get po -l k8s-app=heapster -n kube-system -o jsonpath='{.items[*].metadata.name}')
$ export HEAPSTER_SERVICE=$(kubectl get service/heapster --namespace=kube-system -o jsonpath="{.spec.clusterIP}")
$ curl -L "http://${HEAPSTER_SERVICE}/healthz"
ok

然后,您可以检查指标 API 是否可用:
$ curl -L "http://${HEAPSTER_SERVICE}/api/v1/model/metrics/"
[
"cpu/usage_rate",
"memory/usage",
"cpu/request",
"cpu/limit",
"memory/request",
"memory/limit"
]

如果它没有像上面那样返回,请查看容器日志中的错误:
$ kubectl logs -n kube-system ${HEAPSTER_POD} --all-containers
尽管如此,请记住 Heapster 是一个已弃用的项目,在最近的 Kubernetes 版本中运行它时可能会遇到问题。

Heapster Deprecation Timeline :

| Kubernetes Release  | Action              | Policy/Support                                                                   |
|---------------------|---------------------|----------------------------------------------------------------------------------|
| Kubernetes 1.11 | Initial Deprecation | No new features or sinks are added. Bugfixes may be made. |
| Kubernetes 1.12 | Setup Removal | The optional to install Heapster via the Kubernetes setup script is removed. |
| Kubernetes 1.13 | Removal | No new bugfixes will be made. Move to kubernetes-retired organization. |


从 Kubernetes v1.10 开始, kubectl top依赖 指标服务器 默认情况下。

CHANGELOG-1.10.md :

  • Support metrics API in kubectl top commands. (#56206, @brancz)

This PR implements support for the kubectl top commands to use the metrics-server as an aggregated API, instead of requesting the metrics from heapster directly. If the metrics.k8s.io API is not served by the apiserver, then this still falls back to the previous behavior.



最好使用 kubectl版本 v1.10或更高版本,因为它从 metrics-server 获取指标。

但是,请注意 kubectl Version Skew Policy :

kubectl is supported within one minor version (older or newer) of kube-apiserver



检查您的 kube-apiserver选择之前的版本 kubectl版本。

关于kubernetes - kubectl 顶级节点显示错误 : metrics not available yet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50704244/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com