gpt4 book ai didi

Kubernetes AutoScaler未缩放,HPA显示目标<未知>

转载 作者:行者123 更新时间:2023-12-04 20:29:37 24 4
gpt4 key购买 nike

我对kubernetes很陌生,而对于docker来说就不那么多了。

我一直在研究示例,但是我对自动缩放器(似乎无法缩放)感到困惑。

我在这里通过示例https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#step-one-run--expose-php-apache-server

您会在底部找到构建
kubectl create -f https://k8s.io/docs/tasks/run-application/hpa-php-apache.yaml
看起来像这样

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 50
kubectl get hba显示
NAME         REFERENCE               TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
php-apache Deployment/php-apache <unknown>/50% 1 10 0 7s
<unknown>部分中的线索。

然后 kubectl describe hba显示
Name:                                                  php-apache
Namespace: default
Labels: <none>
Annotations: <none>
CreationTimestamp: Sat, 14 Apr 2018 23:05:05 +0100
Reference: Deployment/php-apache
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): <unknown> / 50%
Min replicas: 1
Max replicas: 10
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale False FailedGetScale the HPA controller was unable to get the target's current scale: deployments/scale.extensions "php-apache" not found
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedGetScale 12s (x14 over 6m) horizontal-pod-autoscaler deployments/scale.extensions "php-apache" not found

所以然后我用...手动添加它
kubectl run php-apache --image=k8s.gcr.io/hpa-example --requests=cpu=200m --expose --port=80
然后,如果我再次运行 kubectl describe hpa,我会收到此错误。
Name:                                                  php-apache
Namespace: default
Labels: <none>
Annotations: <none>
CreationTimestamp: Sat, 14 Apr 2018 23:05:05 +0100
Reference: Deployment/php-apache
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): <unknown> / 50%
Min replicas: 1
Max replicas: 10
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: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedGetScale 1m (x21 over 11m) horizontal-pod-autoscaler deployments/scale.extensions "php-apache" not found
Warning FailedGetResourceMetric 8s (x2 over 38s) horizontal-pod-autoscaler unable to get metrics for resource cpu: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)
Warning FailedComputeMetricsReplicas 8s (x2 over 38s) horizontal-pod-autoscaler failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from API: the server could not find the requested resource (get pods.metrics.k8s.io)

最佳答案

由于在kubernetes的更高版本(v 1.13)中不推荐使用Heapster,因此您也可以使用metrics-server公开指标,请检查以下答案以逐步设置HPA:

How to Enable KubeAPI server for HPA Autoscaling Metrics

关于Kubernetes AutoScaler未缩放,HPA显示目标<未知>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49836681/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com