关于这个主题有很多问题,我尝试了很多东西,但仍然没有用。
我是 Kubernetes 新手。我有一个 Kubernetes 集群,有 2 个节点(1 台 PC,另一台 PC 上的 1 个 VM)、1 个主节点、1 个节点。我启动了一个网站(Docker Image)并且 Pod 在节点(不是主节点)上运行。现在我想自动缩放 Pod,这就是我所做的:
- 设置
--request='cpu=50m'
到吊舱 - 创建 hpa:
kubectl autoscale deployment testwebsite --min=1 --max=4 --cpu-percent=25
- 用过的:
kubectl get hpa -w
现在存在输出显示为当前值的问题。我读了很多我必须将请求分配给 pod,就像我一样。通过以下方式检查:kubectl get pod testwebsite --out=yaml
我还创建了度量服务器版本 1.8+。确保它通过以下方式运行:kubectl get pods --all-namespaces
之后,我尝试调试 HPA 并通过以下方式对其进行了研究:
kubectl describe hpa testwebsite
这向我展示了这一点:
Name: testwebsite
Namespace: default
Labels: <none>
Annotations: <none>
CreationTimestamp: Thu, 04 Apr 2019 14:08:57 +0200
Reference: Deployment/testwebsite
Metrics: ( current / target ) resource cpu on pods (as a percentage of request): <unknown> / 25%
Min replicas: 1
Max replicas: 4
Deployment pods: 1 current / 0 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedComputeMetricsReplicas 7m24s (x12 over 10m) horizontal-pod-autoscaler failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API
Warning FailedGetResourceMetric 5s (x41 over 10m) horizontal-pod-autoscaler unable to get metrics for resource cpu: no metrics returned from resource metrics API
10 多分钟后,它不会显示当前值,即使 CPU 使用率为 50-100%,它也不会按比例放大。
正如我所说,我是 Kubernetes 新手,我真的希望有人能帮助我。
此致,
Nico 又名 Myridor
编辑:在两个节点上使用 Ubuntu 18.04 LTS | Kubernetes 版本:1.14.0