我正在尝试为1.13 EKS群集中的Pod启用自动缩放策略。我一直碰到同样的问题,那就是度量服务器永远不可用。
kubectl get deployment metrics-server -n kube-system
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
metrics-server 1 1 1 0 9s
我已经在自己的计算机上克隆了必要的存储库,然后kubectl apply -f deploy/1.8+
。
我也将这些行添加到了部署中:
args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
command:
- /metrics-server
- --metric-resolution=30s
- --requestheader-allowed-names=aggregator
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
我已经尝试过args,然后分别将命令部分分开,然后一起进行。我也已经从集群中删除了堆(kubectl delete -f this和that)。
谢谢您的帮助
编辑:当我运行kubectl describe deployment metrics-server -n kube-system
时,会看到以下内容:
Name: metrics-server
Namespace: kube-system
CreationTimestamp: Fri, 22 Nov 2019 16:08:14 +0000
Labels: k8s-app=metrics-server
Annotations: deployment.kubernetes.io/revision: 1
kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"k8s-app":"metrics-server"},"name":"metrics-server","na...
Selector: k8s-app=metrics-server
Replicas: 1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: k8s-app=metrics-server
Service Account: metrics-server
Containers:
metrics-server:
Image: k8s.gcr.io/metrics-server-amd64:v0.3.6
Port: <none>
Host Port: <none>
Environment: <none>
Mounts:
/tmp from tmp-dir (rw)
Volumes:
tmp-dir:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
Conditions:
Type Status Reason
---- ------ ------
Available False MinimumReplicasUnavailable
Progressing False ProgressDeadlineExceeded
OldReplicaSets: <none>
NewReplicaSet: metrics-server-6fbb7b8994 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 10m deployment-controller Scaled up replica set metrics-server-6fbb7b8994 to 1
答案 0 :(得分:0)
找出问题所在,如果您遇到的问题与我相同,请执行以下步骤: 与部署中的那些一起部署metrics-server:
- name: metrics-server
image: k8s.gcr.io/metrics-server-amd64:v0.3.6
args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-insecure-tls
应用此hpa
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: cpu-trial
namespace: trial
spec:
scaleTargetRef:
apiVersion: apps/v1beta1
kind: Deployment
name: cpu-trial
minReplicas: 3
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 85
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 85
在部署中应用这些行
image: #{image}
resources:
limits:
cpu: 200m
memory: "65Mi"
requests:
cpu: 100m
memory: "40Mi"
应该的!