我通过kops
aws
创建一个k8s
集群,节点自动伸缩组配置如下:
metadata:
creationTimestamp: "2017-03-21T03:53:26Z"
name: nodes
spec:
associatePublicIp: true
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2016-10-21
machineType: t2.medium
maxSize: 5
minSize: 2
role: Node
zones:
- us-west-1a
- us-west-1c
aws
控制台显示当前的 ASG,如下所示:
desired:2; min:2; max:5
然后我使用官方文档安装add-ons
--- cluster-autoscaler
,然后我部署一个当前集群无法提供资源的 pod,但cluster-autoscaler
没有将节点添加到集群中,日志如下所示:
admin@ip-10-0-52-252:/var/log$kubectl logs -f cluster-autoscaler-1581749901-fqbzk -n kube-system
I0322 07:08:43.407683 1 event.go:216] Event(api.ObjectReference{Kind:"Pod", Namespace:"default", Name:"new-mq-test-951523717-trd2s", UID:"9437ac54-0ecd-11e7-8779-0257a5d4c012", APIVersion:"v1", ResourceVersion:"189546", FieldPath:""}): type: 'Normal' reason: 'NotTriggerScaleUp' pod didn't trigger scale-up (it wouldn't fit if a new node is added)
I0322 07:08:43.407910 1 event.go:216] Event(api.ObjectReference{Kind:"Pod", Namespace:"default", Name:"new-mq-test-951523717-n986l", UID:"9437a3db-0ecd-11e7-8779-0257a5d4c012", APIVersion:"v1", ResourceVersion:"189543", FieldPath:""}): type: 'Normal' reason: 'NotTriggerScaleUp' pod didn't trigger scale-up (it wouldn't fit if a new node is added)
那么,为什么cluster-autoscaler
不通过添加EC2节点来扩展集群呢? 任何答案都非常感谢
终于找到了答案,我对nodes
asg 的默认kops
配置是 t2.medium
,而我部署的 pod 需要内存5000M
,因为我们都知道t2.medium
内存4GB
不符合要求,所以cluster-autoscaler
无法扩展!
我在尝试在Google Container Engine上使用Kubernetes自动扩展时遇到了类似的问题。当您的集群没有足够的节点来容纳更多的 Kubernetes Pod 时,通常会发生这种情况。
解决方案是在集群(在本例中为 AWS EC2(中启用自动扩展以及 kubernetes 自动扩展。
有关详细信息,请查看以下 Kubernetes 文档,了解如何在 AWS 上自动扩展:链接。