试图将自动标号部署到我的集群,但目标显示“未知”,我尝试了不同的度量服务器,但没有效果。我跟踪了this githhub issue,甚至认为我使用的是Kubeadm,而不是minikube,这并没有改变问题。
我也followed this Stack post也没有成功。
我正在运行Ubuntu20.0.4LTS。
使用kubernetes版本1.23.5,用于kubeadm、kubcectl等
按照另一个堆栈帖子的建议,我通过curl获取了最新版本。
curl -L https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
我将该文件编辑如下:
spec:
containers:
- args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubectl-insecure-tls
- --kubelet-preferred-address-types=InternalIP
- --kubelet-use-node-status-port
- --metric-resolution=15s
image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
imagePullPolicy: IfNotPresent然后我运行kubectl应用-f components.yaml
仍未起作用:
$ kubectl获得hpa名称参考目标MINPODS MAXPODS副本年龄teastore-webui-hpa部署/teastore-webui /50% 1 20 1 20h
另一项建议是具体宣布限制。
$ kubectl autoscale deployment teastore-webui --max=20 --cpu-percent=50 --min=1
horizontalpodautoscaler.autoscaling/teastore-webui autoscaled
group8@group8:~/Downloads/TeaStore-master/examples/kubernetes$ kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
teastore-webui Deployment/teastore-webui <unknown>/50% 1 20 0 4s
teastore-webui-hpa Deployment/teastore-webui <unknown>/50% 1 20 1 20h这也不起作用。
下面是我正在尝试自动调整的部署和服务配置的一个实例。
spec:
containers:
- name: teastore-webui
image: descartesresearch/teastore-webui
ports:
- containerPort: 8080
env:
- name: HOST_NAME
value: "teastore-webui"
- name: REGISTRY_HOST
value: "teastore-registry"
resources:
requests:
cpu: "250m"
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: teastore-webui-hpa
labels:
app: teastore
spec:
maxReplicas: 20
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: teastore-webui
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
---
apiVersion: v1
kind: Service
metadata:
name: teastore-webui
labels:
app: teastore
run: teastore-webui
spec:
type: NodePort
ports:
- port: 8080
nodePort: 30080
protocol: TCP
selector:
run: teastore-webui根据其他建议,我将资源具体声明为cpu,利用率为50%,CPU请求设置为250毫秒。
$kubectl describe hpa
Warning: autoscaling/v2beta2 HorizontalPodAutoscaler is deprecated in v1.23+, unavailable in v1.26+; use autoscaling/v2 HorizontalPodAutoscaler
Name: teastore-webui
Namespace: default
Labels: <none>
Annotations: <none>
CreationTimestamp: Sat, 02 Apr 2022 16:07:25 -0400
Reference: Deployment/teastore-webui
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): <unknown> / 50%
Min replicas: 1
Max replicas: 20
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: failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server is currently unable to handle the request (get pods.metrics.k8s.io)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedComputeMetricsReplicas 29m (x12 over 32m) horizontal-pod-autoscaler invalid metrics (1 invalid out of 1), first error is: failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server is currently unable to handle the request (get pods.metrics.k8s.io)
Warning FailedGetResourceMetric 2m12s (x121 over 32m) 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 is currently unable to handle the request (get pods.metrics.k8s.io)发布于 2022-04-03 14:28:51
此yaml第6行的语法错误。它需要的是- --kubelet-insecure-tls而不是- --kubectl-insecure-tls
spec:
containers:
- args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubectl-insecure-tls
- --kubelet-preferred-address-types=InternalIP
- --kubelet-use-node-status-port
- --metric-resolution=15s
image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1
imagePullPolicy: IfNotPresent检查日志文件时注意到
kubectl logs -f metric-server -n kube-system谢谢大卫·梅泽的评论。
https://stackoverflow.com/questions/71721065
复制相似问题