gpt4 book ai didi

kubernetes - Minikube 水平 Pod 自动缩放错误 : unable to get metrics for resource cpu: no metrics returned

转载 作者:行者123 更新时间:2023-12-03 19:36:49 25 4
gpt4 key购买 nike

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

最佳答案

确保 metrics-server在 minikube 上启用了插件。

当我启动 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

关于kubernetes - Minikube 水平 Pod 自动缩放错误 : unable to get metrics for resource cpu: no metrics returned,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48325627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com