Docker Kubernetes(Mac)-自动缩放器无法找到指标 [英] Docker Kubernetes (Mac) - Autoscaler unable to find metrics
问题描述
我已经在Mac上通过Docker安装了Kubernetes的本地实例.
I have installed a local instance of Kubernetes via Docker on my Mac.
按照演练进行激活在部署上自动缩放我遇到了一个问题.自动缩放器无法读取指标.
Following the walkthrough on how to activate autoscaling on a deployment I have experienced an issue. The autoscaler can't read the metrics.
当我运行kubectl describe hpa
时,当前的CPU使用率以未知/50%的形式返回并显示警告:
When I am running kubectl describe hpa
the current cpu usage comes back as unknown / 50% with the warnings:
警告失败GetResourceMetric: horizontal-pod-autoscaler无法获取资源cpu的指标: 无法从API获取指标:服务器找不到 请求的资源(获取pods.metrics.k8s.io)
Warning FailedGetResourceMetric: horizontal-pod-autoscaler unable to get metrics for resource cpu: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)
警告失败的计算指标重复 horizontal-pod-autoscaler无法获得cpu利用率:无法 获取资源cpu的指标:无法从API获取指标: 服务器找不到请求的资源(获取pods.metrics.k8s.io)
Warning FailedComputeMetricsReplicas horizontal-pod-autoscaler failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)
我已经通过git clone https://github.com/kubernetes-incubator/metrics-server.git
安装了指标服务器,并通过kubectl create -f deploy/1.8+
I have installed the metrics-server via git clone https://github.com/kubernetes-incubator/metrics-server.git
and installed it with kubectl create -f deploy/1.8+
推荐答案
我终于使它工作了. 这是我为使事情正常运行所采取的全部步骤:
I finally got it working.. Here are the full steps I took to get things working:
-
Kubernetes在Docker中运行
Have Kubernetes running within Docker
使用kubectl delete -n kube-system deployments.apps metrics-server
使用git clone https://github.com/kubernetes-incubator/metrics-server.git
编辑文件 deploy/1.8 +/metrics-server-deployment.yaml ,通过添加不存在的 command 部分来覆盖默认命令前.新部分将指示metrics-server允许进行不安全的通信会话(不要验证所涉及的证书).仅对Docker执行此操作,而不对metrics-server的生产部署执行此操作:
Edit the file deploy/1.8+/metrics-server-deployment.yaml to override the default command by adding a command section that didn't exist before. The new section will instruct metrics-server to allow for an insecure communications session (don't verify the certs involved). Do this only for Docker, and not for production deployments of metrics-server:
containers:
- name: metrics-server
image: k8s.gcr.io/metrics-server-amd64:v0.3.1
command:
- /metrics-server
- --kubelet-insecure-tls
使用kubectl create -f deploy/1.8+
将metrics-server添加到您的Kubernetes实例(如果.yaml出现错误,请改写为:kubectl apply -f deploy/1.8+
)
Add metrics-server to your Kubernetes instance with kubectl create -f deploy/1.8+
(if errors with the .yaml, write this instead: kubectl apply -f deploy/1.8+
)
这篇关于Docker Kubernetes(Mac)-自动缩放器无法找到指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!