【发布时间】:2018-06-27 18:45:06
【问题描述】:
我在 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
【问题讨论】:
-
您是否尝试过在资源上添加
limit而不仅仅是请求?不是 100% 确定,但 HPA 可能需要它才能工作 -
我读到另一个问题不是,但让我试试吧
-
你试过了吗?
-
您可以查看this workaround,这可能会帮助您解决问题。你能检查一下并告诉我们吗?
-
@whites11 我做了,几分钟后统计数据显示出来
标签: kubernetes horizontal-scaling google-kubernetes-engine