[英]Minikube horizontal pod autoscaling error: unable to get metrics for resource cpu: no metrics returned
I'v enabled heapster on minikube我在 minikube 上启用了 heapster
minikube addons start heapster
And custom metrics with和自定义指标
minikube start --extra-config kubelet.EnableCustomMetrics=true
My deployment looks like我的部署看起来像
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:
My hpa looks like我的 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
However I get target unknown但是我得到的目标未知
jonathan@ubuntu ~> kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
kubia Deployment/kubia <unknown> / 1000000% 1 5 1 31m
And the following warnings from the hpa以及来自 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
Ensure the metrics-server
addons is enabled on minikube.确保在 minikube 上启用了
metrics-server
插件。
When I start minikube () I have the following addons enabled by default:当我启动 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
Enable the metrics server and HPAs appear to work great.启用指标服务器和 HPA 似乎工作得很好。
$ minikube addons enable metrics-server
metrics-server was successfully enabled
metrics-server
monitoring needs to be deployed in the cluster to provide metrics via the resource metrics API, as Horizontal Pod Autoscaler uses this API to collect metrics.metrics-server
监控需要部署在集群中以通过资源指标 API 提供指标,因为 Horizontal Pod Autoscaler 使用此 API 来收集指标。
Thus enable metrics-server
addon via;因此,通过以下方式启用
metrics-server
插件;
$ minikube addons enable metrics-server
Refer - Horizontal Pod Autoscaler Walkthrough - Before you begin请参阅 - Horizontal Pod Autoscaler 演练 - 开始之前
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.