[英]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.