我已经配置了一个Kubernetes集群,其中的metrics-server(作为聚合的apiserver)取代了heapster。 kubectl top可以正常工作,metrics.k8s.io / v1beta1 api组中的原始端点也可以正常工作。但是,HPA没有。控制器经理日志显示以下错误(没有其他错误):
E1008 10:45:18.462447 1 horizontal.go:188] failed to compute desired number of replicas based on listed metrics for Deployment/kube-system/nginx: failed to get cpu utilization: missing request for cpu on container nginx in pod kube-system/nginx-64f497f8fd-7kr96
I1008 10:45:18.462511 1 event.go:221] Event(v1.ObjectReference{Kind:"HorizontalPodAutoscaler", Namespace:"kube-system", Name:"nginx", UID:"387f256e-cade-11e8-9cfa-525400c042d5", APIVersion:"autoscaling/v2beta1", ResourceVersion:"3367", FieldPath:""}): type: 'Warning' reason: 'FailedGetResourceMetric' missing request for cpu on container nginx in pod kube-system/nginx-64f497f8fd-7kr96
I1008 10:45:18.462529 1 event.go:221] Event(v1.ObjectReference{Kind:"HorizontalPodAutoscaler", Namespace:"kube-system", Name:"nginx", UID:"387f256e-cade-11e8-9cfa-525400c042d5", APIVersion:"autoscaling/v2beta1", ResourceVersion:"3367", FieldPath:""}): type: 'Warning' reason: 'FailedComputeMetricsReplicas' failed to get cpu utilization: missing request for cpu on container nginx in pod kube-system/nginx-64f497f8fd-7kr96
metrics-server规范:
spec:
containers:
- args:
- --kubelet-preferred-address-types=InternalIP
image: k8s.gcr.io/metrics-server-amd64:v0.3.1
imagePullPolicy: Always
name: metrics-server
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /tmp
name: tmp-dir
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: metrics-server
serviceAccountName: metrics-server
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: tmp-dir
controller-manager与运行
--horizontal-pod-autoscaler-use-rest-clients="true"
k8s版本1.11.3
有什么想法吗?
答案 0 :(得分:1)
原来这是我的愚蠢(与metrics-server无关)。
我正在对Pod容器没有任何CPU请求设置的部署进行测试。
答案 1 :(得分:0)
我将在此处编写不方便注释的注释。
检查您proxy-client-cert-file
和proxy-client-key
,向他打开此命令,然后检查主题CN:
$ openssl x509 -noout -text -in /etc/kubernetes/ssl/front-proxy-client.pem
Certificate:
Data:
Version: hidden
Serial Number: hidden (hidden)
Signature Algorithm: hidden
Issuer: CN=front-proxy-ca
Validity
Not Before: hidden
Not After : hidden
Subject: CN=front-proxy-client
在我的情况下,主题CN = front-proxy-client
,此CN我添加到kube-apiserver中:
--requestheader-allowed-names=front-proxy-client