簡體   English   中英

Minikube 水平 pod 自動縮放錯誤:無法獲取資源 cpu 的指標:未返回指標

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

我在 minikube 上啟用了 heapster

minikube addons start heapster

和自定義指標

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

我的部署看起來像

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:

我的 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

但是我得到的目標未知

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

以及來自 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

確保在 minikube 上啟用了metrics-server插件。

當我啟動 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

啟用指標服務器和 HPA 似乎工作得很好。

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

metrics-server監控需要部署在集群中以通過資源指標 API 提供指標,因為 Horizo​​ntal Pod Autoscaler 使用此 API 來收集指標。

因此,通過以下方式啟用metrics-server插件;

$ minikube addons enable metrics-server

請參閱 - Horizo​​ntal Pod Autoscaler 演練 - 開始之前

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM