簡體   English   中英

Kubernetes HPA 不工作:無法獲取指標

[英]Kubernetes HPA not working: unable to get metrics

我的 pod scaler 部署失敗,一直報 FailedGetResourceMetric 錯誤:

Warning  FailedComputeMetricsReplicas  6s    horizontal-pod-autoscaler  failed to compute desired number of replicas based on listed metrics for Deployment/default/bot-deployment: invalid metrics (1 invalid out of 1), first error is: failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API

正如您在運行以下命令以顯示集群上的 metrics-server 資源時所看到的那樣,我已確保安裝了 metrics-server:

kubectl get deployment metrics-server -n kube-system

它顯示了這一點: metrics-server

我還在 metrics-server 清單文件的args部分設置了--kubelet-insecure-tls--kubelet-preferred-address-types=InternalIP選項。

這是我的部署清單的樣子:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bot-deployment
  labels:
    app: bot
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bot
  template:
    metadata:
      labels:
        app: bot
    spec:
      containers:
      - name: bot-api
        image: gcr.io/<repo>
        ports:
        - containerPort: 5600
        volumeMounts:
        - name: bot-volume
          mountPath: /core
      - name: wallet
        image: gcr.io/<repo>
        ports:
        - containerPort: 5000
        resources:
          requests:
            cpu: 800m
          limits:
            cpu: 1500m
        volumeMounts:
        - name: bot-volume
          mountPath: /wallet_
      volumes:
      - name: bot-volume
        emptyDir: {}

我的 pod 縮放器的規格也如下所示:

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: bot-scaler
spec:
  metrics:
    - resource:
        name: cpu
        target:
          averageUtilization: 85
          type: Utilization
      type: Resource
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: bot-deployment
  minReplicas: 1
  maxReplicas: 10

因此, TARGET選項始終保持為 /80%。 經過反省,HPA 一遍又一遍地提出同樣的抱怨,我已經嘗試了所有選項,我在其他一些問題上看到了這些選項,但它們似乎都不起作用。 我也嘗試過多次卸載並重新安裝metrics-server,但它不起作用。

不過,我注意到的一件事是,在我部署 HPA 清單后,metrics-server 似乎關閉了,並且無法啟動。 當我檢查指標服務器的 state 時, READY選項顯示 0/1,即使它最初是 1/1。 有什么問題?

我很樂意根據需要提供盡可能多的信息。 謝謝!

看起來您的 bot-api 缺少它的資源請求和限制。 你的錢包里有它們。 hpa 使用 pod 中的所有資源來計算利用率

暫無
暫無

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

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