Docker Kubernetes (Mac) - Autoscaler 无法找到指标 [英] Docker Kubernetes (Mac) - Autoscaler unable to find metrics

查看:35
本文介绍了Docker Kubernetes (Mac) - Autoscaler 无法找到指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的 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 使用率返回为 unknown/50% 并带有警告:

When I am running kubectl describe hpa the current cpu usage comes back as unknown / 50% with the warnings:

警告失败GetResourceMetric:水平 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)

警告失败ComputeMetricsReplicas水平 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 安装了 metrics-server 并使用 kubectl create -f deploy/安装了它1.8+

I have installed the metrics-server via git clone https://github.com/kubernetes-incubator/metrics-server.gitand 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:

  1. 在 Docker 中运行 Kubernetes

  1. 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 执行此操作,不适用于指标服务器的生产部署:

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+)

    删除自动缩放程序并将其重新添加到您的部署中.它现在应该显示当前的 CPU 使用情况.

    Remove and add the autoscaler to your deployment again. It should now show the current cpu usage.

    编辑 2020 年 7 月:

    上述大部分步骤都适用,除了 metrics-server 已经改变并且文件不再存在.

    Most of the above steps hold true except the metrics-server has changed and that file does not exist anymore.

    repo 现在建议这样安装:

    The repo now recommends installing it like this:

    apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml
    

    所以我们现在可以下载这个文件了,

    So we can now download this file,

    curl -L https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml --output components.yaml
    

    args (L88) 下添加 --kubelet-insecure-tlsmetrics-server 部署并运行

    add --kubelet-insecure-tls under args (L88) to the metrics-server deployment and run

    kubectl apply -f components.yaml
    

    这篇关于Docker Kubernetes (Mac) - Autoscaler 无法找到指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆