gpt4 book ai didi

docker - kubectl 顶级节点 `error: metrics not available yet` 。不推荐使用指标服务器作为 Heapster

转载 作者:行者123 更新时间:2023-12-04 15:17:29 26 4
gpt4 key购买 nike

Kubernetes 无法找到 metric-server api。我在 Mac 上使用 Kubernetes 和 Docker。我试图从以下示例中进行 HPA [ https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/] .但是,当我执行命令时 kubectl get hpa ,我的目标仍然未知。然后我试了一下,kubectl describe hpa .这给了我如下错误:

  Name:                                                  php-apache
Namespace: default
Labels: <none>
Annotations: <none>
CreationTimestamp: Sun, 07 Oct 2018 12:36:31 -0700
Reference: Deployment/php-apache
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): <unknown> / 5%
Min replicas: 1
Max replicas: 10
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedComputeMetricsReplicas 1h (x34 over 5h) horizontal-pod-autoscaler failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API
Warning FailedGetResourceMetric 1m (x42 over 5h) horizontal-pod-autoscaler unable to get metrics for resource cpu: no metrics returned from resource metrics API

我正在使用 [ https://github.com/kubernetes-incubator/metrics-server]正如 Kubernetes 文档中所建议的那样。我也尝试过使用 Minikube 做同样的事情。但这也不起作用。

运行 kubectl get --raw /apis/metrics.k8s.io/v1beta1/nodes输出:
{
"kind": "NodeMetricsList",
"apiVersion": "metrics.k8s.io/v1beta1",
"metadata": {
"selfLink": "/apis/metrics.k8s.io/v1beta1/nodes"
},
"items": []
}

最佳答案

解决方案(如果使用 Minikube):

将 Kubernetes 的上下文更改为 Minikube。

在 minikube 中启用 metrics-server 和 Disabled heapster。
minikube addons disable heapsterminikube addons enable metrics-server
使用以下步骤在集群中部署 metrics-server:
git clone https://github.com/kubernetes-incubator/metrics-server.gitcd metrics-serverkubectl create -f deploy/1.7/ (如果 Kubernetes 1.7 版)


kubectl create -f deploy/1.8+/ (如果 Kubernetes 版本 1.8+)

开始 minikube dashboadminikube service [your service] .

试试 kubectl top node .

我发现这个 ( https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/ ) 资源很有帮助。

关于docker - kubectl 顶级节点 `error: metrics not available yet` 。不推荐使用指标服务器作为 Heapster,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52694238/

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