简体   繁体   English

Minikube 水平 pod 自动缩放错误:无法获取资源 cpu 的指标:未返回指标

[英]Minikube horizontal pod autoscaling error: unable to get metrics for resource cpu: no metrics returned

I'v enabled heapster on minikube我在 minikube 上启用了 heapster

minikube addons start heapster

And custom metrics with和自定义指标

minikube start --extra-config kubelet.EnableCustomMetrics=true

My deployment looks like我的部署看起来像

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kubia
spec:
  replicas: 1
  template:
    metadata:
      name: kubia
      labels:
        app: kubia
      annotations:
        pod.beta.kubernetes.io/init-containers: '[
            {
                "name": "setup",
                "image": "busybox",
                "imagePullPolicy": "IfNotPresent",
                "command": ["sh", "-c", "echo \"{\\\"endpoint\\\": \\\"http://$POD_IP:8080/metrics\\\"}\" > /etc/custom-metrics/definition.json"],
                "env": [{
                  "name": "POD_IP",
                  "valueFrom": {
                    "fieldRef": {
                      "apiVersion": "v1",
                      "fieldPath": "status.podIP"
                    }
                  }
                }],
                "volumeMounts": [
                    {
                        "name": "config",
                        "mountPath": "/etc/custom-metrics"
                    }
                ]
            }
        ]'
    spec:
      containers:
      - image: luksa/kubia:qps
        name: nodejs
        ports:
          - containerPort: 8080
        volumeMounts:
        - name: config
          mountPath: /etc/custom-metrics
        resources:
          requests:
            cpu: 100m
      volumes:
      - name: config
        emptyDir:

My hpa looks like我的 hpa 看起来像

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: kubia
  annotations:
    alpha/target.custom-metrics.podautoscaler.kubernetes.io: '{"items":[{"name":"qps", "value": "20"}]}'
spec:
  maxReplicas: 5
  minReplicas: 1
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: kubia
  targetCPUUtilizationPercentage: 1000000

However I get target unknown但是我得到的目标未知

jonathan@ubuntu ~> kubectl get hpa
NAME      REFERENCE          TARGETS                MINPODS   MAXPODS   REPLICAS   AGE
kubia     Deployment/kubia   <unknown> / 1000000%   1         5         1          31m

And the following warnings from the hpa以及来自 hpa 的以下警告

  Warning  FailedGetResourceMetric       27m (x12 over 33m)  horizontal-pod-autoscaler  unable to get metrics for resource cpu: no metrics returned from heapster
  Warning  FailedComputeMetricsReplicas  27m (x12 over 33m)  horizontal-pod-autoscaler  failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from heapster

Ensure the metrics-server addons is enabled on minikube.确保在 minikube 上启用了metrics-server插件。

When I start minikube () I have the following addons enabled by default:当我启动 minikube () 时,我默认启用了以下插件:

$ minikube addons list
- addon-manager: enabled
- coredns: disabled
- dashboard: enabled
- default-storageclass: enabled
- efk: disabled
- freshpod: disabled
- heapster: enabled
- ingress: disabled
- kube-dns: enabled
- metrics-server: disabled
- registry: disabled
- registry-creds: disabled
- storage-provisioner: enabled

Enable the metrics server and HPAs appear to work great.启用指标服务器和 HPA 似乎工作得很好。

$ minikube addons enable metrics-server
metrics-server was successfully enabled

metrics-server monitoring needs to be deployed in the cluster to provide metrics via the resource metrics API, as Horizontal Pod Autoscaler uses this API to collect metrics. metrics-server监控需要部署在集群中以通过资源指标 API 提供指标,因为 Horizo​​ntal Pod Autoscaler 使用此 API 来收集指标。

Thus enable metrics-server addon via;因此,通过以下方式启用metrics-server插件;

$ minikube addons enable metrics-server

Refer - Horizontal Pod Autoscaler Walkthrough - Before you begin请参阅 - Horizo​​ntal Pod Autoscaler 演练 - 开始之前

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 水平 pod 自动缩放不起作用:`无法获取资源 cpu 的指标:没有从 heapster 返回指标` - Horizontal pod autoscaling not working: `unable to get metrics for resource cpu: no metrics returned from heapster` 没有自定义指标的水平 pod 自动缩放 - Horizontal pod Autoscaling without custom metrics 如何在外部指标上实现 Horizontal Pod Autoscaling? - How to implment Horizontal Pod Autoscaling on external metrics? Kubernetes HPA -- 无法获取资源内存指标:没有从资源指标 API 返回指标 - Kubernetes HPA -- Unable to get metrics for resource memory: no metrics returned from resource metrics API 基于 Kubernetes 指标的 Google Cloud GKE 水平 pod 自动缩放 - Google cloud GKE horizontal pod autoscaling based on Kubernetes metrics 如何在 Kubernetes Horizontal Pod Autoscaling 中排除某些容器的指标 - How to exclude some containers' metrics in Kubernetes Horizontal Pod Autoscaling 无法获取Pod指标-Kubernetes - Unable to get pod metrics -Kubernetes 水平 Pod 自动缩放无法读取指标 - Horizontal Pod Autoscale unable to read metrics 可以从指标服务器获取哪些指标以进行水平Pod自动缩放 - What metrics can be fetched from metrics-server for Horizontal Pod Autoscaling 对于“超过 63 个字符”的指标,通过 custom-metrics-stackdriver-adapter 进行水平 Pod 自动缩放失败 - Horizontal Pod Autoscaling via custom-metrics-stackdriver-adapter fails for metrics "more than 63 characters"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM