You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes HPA显示<unknown>问题求助:前端服务无法获取有效指标值

Fixing HPA Showing <unknown> When Metrics Server Isn't Ready

Let’s break down what’s going on here and fix your HPA issue step by step:

The core problem is clear: your Metrics Server deployment isn’t ready (shows 0/1 in your kubectl get deployment output). HPA depends entirely on Metrics Server to pull CPU/memory usage data from pods—if Metrics Server can’t run properly, HPA has no metrics to display, hence the <unknown> value.

Here’s how to resolve this:

1. Diagnose Why Metrics Server Is Failing

First, check the logs of the Metrics Server pod to uncover the root cause:

kubectl logs deployment/metrics-server -n kube-system

Common issues here include:

  • Certificate validation errors (most local/private clusters use self-signed certificates for kubelet)
  • Network connectivity problems with the Kubernetes API Server
  • Missing required startup flags for Metrics Server

2. Fix the Metrics Server Deployment

The most frequent fix for a stuck Metrics Server is adding a flag to skip kubelet certificate verification (safe for non-production environments; adjust certificate settings properly for production):

  1. Edit the Metrics Server deployment:
    kubectl edit deployment metrics-server -n kube-system
    
  2. Find the args section under the metrics-server container, and add the --kubelet-insecure-tls flag:
    args:
      - --cert-dir=/tmp
      - --secure-port=4443
      - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
      - --kubelet-use-node-status-port
      - --kubelet-insecure-tls  # Add this line
    
  3. Save and exit the editor—Kubernetes will automatically restart the Metrics Server pod.

3. Verify Metrics Server Is Working

Wait 30 seconds, then check if the deployment is ready:

kubectl get deployment metrics-server -n kube-system

Once it shows 1/1 Ready, confirm it can fetch metrics:

# Check node-level metrics
kubectl top nodes
# Check metrics for your udagram-frontend pods
kubectl top pods

If these commands return valid CPU/memory values, Metrics Server is functioning correctly.

4. Recheck Your HPA Status

Give HPA a minute to pull the new metrics, then run:

kubectl describe hpa udagram-frontend

You should now see actual CPU usage percentages instead of <unknown>.

A quick note: Your udagram-frontend deployment is correctly configured with resources.requests.cpu—this is a required setting for HPA to calculate usage percentages, so you don’t need to adjust anything there.

内容的提问来源于stack exchange,提问作者Oussama Bouchikhi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 17:17:45