GKE 集群未缩小规模

2023-12-23

我在 Google Kubernetes 集群上启用了自动缩放,并且我可以看到其中一个 Pod 的使用率要低得多

我总共有 6 个节点,我预计至少有这个节点被终止。我经历了以下事情:https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-types-of-pods-can-prevent-ca-from-removing-a-node https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-types-of-pods-can-prevent-ca-from-removing-a-node

我已将此注释添加到我的所有 pod 中

cluster-autoscaler.kubernetes.io/safe-to-evict: true

但是,集群自动缩放程序可以正确扩展,但不会像我预期的那样缩小。

我有以下日志

$ kubectl  logs kube-dns-autoscaler-76fcd5f658-mf85c -n kube-system

autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:90: Failed to list *v1.Node: Get https://10.55.240.1:443/api/v1/nodes?resourceVersion=0: dial tcp 10.55.240.1:443: getsockopt: connection refused
E0628 20:34:36.187949       1 reflector.go:190] github.com/kubernetes-incubator/cluster-proportional-autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:90: Failed to list *v1.Node: Get https://10.55.240.1:443/api/v1/nodes?resourceVersion=0: dial tcp 10.55.240.1:443: getsockopt: connection refused
E0628 20:34:47.191061       1 reflector.go:190] github.com/kubernetes-incubator/cluster-proportional-autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:90: Failed to list *v1.Node: Get https://10.55.240.1:443/api/v1/nodes?resourceVersion=0: net/http: TLS handshake timeout
I0628 20:35:10.248636       1 autoscaler_server.go:133] ConfigMap not found: Get https://10.55.240.1:443/api/v1/namespaces/kube-system/configmaps/kube-dns-autoscaler: net/http: TLS handshake timeout, will create one with default params
E0628 20:35:17.356197       1 autoscaler_server.go:95] Error syncing configMap with apiserver: configmaps "kube-dns-autoscaler" already exists
E0628 20:35:18.191979       1 reflector.go:190] github.com/kubernetes-incubator/cluster-proportional-autoscaler/pkg/autoscaler/k8sclient/k8sclient.go:90: Failed to list *v1.Node: Get https://10.55.240.1:443/api/v1/nodes?resourceVersion=0: dial tcp 10.55.240.1:443: i/o timeout

我不确定以上是否是相关日志,调试此问题的正确方法是什么?

我的 Pod 有本地存储。我一直在尝试使用来调试这个问题

kubectl drain  gke-mynode-d57ded4e-k8tt

error: DaemonSet-managed pods (use --ignore-daemonsets to ignore): fluentd-gcp-v3.1.1-qzdzs, prometheus-to-sd-snqtn; pods with local storage (use --delete-local-data to override): mydocs-585879b4d5-g9flr, istio-ingressgateway-9b889644-v8bgq, mydocs-585879b4d5-7lmzk

我认为忽略是安全的daemonsets因为 CA 应该可以驱逐它,但是我不确定如何让 CA 理解 mydocs 可以被驱逐并在添加注释后移动到另一个节点

EDIT

The min and the max nodes have been set correctly as seen on the GCP console enter image description here


The kubectl logs命令适用于 DNS 自动缩放程序,而不是集群自动缩放程序。它将为您提供有关集群中 kube-dns 副本数量的信息,而不是节点数量或扩展决策的信息。

来自集群自动缩放器常见问题解答 https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-types-of-pods-can-prevent-ca-from-removing-a-node(并考虑到您在问题中所写的内容):

Kube 系统 pod:

  • 默认情况下不在节点上运行
  • 具有本地存储的 Pod

另外,限制性Pod Disruption Budgets。但是,由于问题中没有说明,我假设您没有设置任何内容。

尽管您有带有本地存储的 Pod,但您添加了注释以使它们可以安全地逐出,这样系统 Pod 默认情况下不会在节点中运行。

由于 GKE 中的系统 Pod 带有注释协调循环 https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/addon-manager,您不能向它们添加此指令,这可能会阻止它们被驱逐。

在这种情况下,您可以考虑使用Pod Disruption Budget配置为允许自动缩放程序驱逐它们 https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-can-i-scale-my-cluster-to-just-1-node.

This Pod Disruption Budget https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-to-set-pdbs-to-enable-ca-to-move-kube-system-pods可以包含默认情况下不在节点中运行的 DNS 和日志记录 Pod。

不幸的是,GKE 是一个托管选项,因此自动缩放器常见问题解答中没有太多可应用的内容。不过,如果你想更进一步,你不妨考虑一下Pod 装箱策略 https://en.wikipedia.org/wiki/Bin_packing_problem using 亲和力与反亲和力 https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity, 污染和容忍 https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ and 要求和限制 https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-resource-requests-and-limits正确安装它们,尽可能使缩小尺寸变得更容易。

最后,在 GKE 上您可以使用cluster-autoscaler-status配置映射表 https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-can-i-check-what-is-going-on-in-ca-检查自动缩放器正在做出哪些决定。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GKE 集群未缩小规模 的相关文章

随机推荐