【发布时间】:2019-03-12 09:21:55
【问题描述】:
我尝试将Horizontal Pod Autosclaer 用于nginx pod。
当我描述我的 hpa 时,我收到了这条消息 horizontal-pod-autoscaler failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server could not find the requested resource
我使用 docker for mac。不知道会不会有影响
我的部署
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-app
spec:
selector:
matchLabels:
run: demo-app
replicas: 1
template:
metadata:
labels:
run: demo-app
spec:
containers:
- name: demo-app
image: my-demo-app:v3
imagePullPolicy: Never
resources:
requests:
cpu: 250m
limits:
cpu: 300m
ports:
- containerPort: 80
我的 HPA
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: demo-app-hpa
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: demo-app
minReplicas: 1
maxReplicas: 3
targetCPUUtilizationPercentage: 3
kubectl get hpa 命令的输出:
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
demo-app-hpa Deployment/demo-app <unknown>/3% 1 3 1 20m
kubectl get --raw /apis/metrics.k8s.io/v1beta1 命令的输出
{"kind":"APIResourceList","apiVersion":"v1","groupVersion":"metrics.k8s.io/v1beta1","resources":[{"name":"nodes","singularName":"","namespaced":false,"kind":"NodeMetrics","verbs":["get","list"]},{"name":"pods","singularName":"","namespaced":true,"kind":"PodMetrics","verbs":["get","list"]}]}
我用this 配置metric-server 但不起作用
Scaling active 设置为 False。我认为这是问题,但我不知道如何改变价值
【问题讨论】:
标签: kubernetes kubectl minikube docker-for-mac