k8s中设置弹性副本缩容的策略

k8s中设置了弹性副本,达到缩容的条件后,删除副本时,是根据副本创建的时间倒序删除,还是随机删除啊,有什么机制吗

阅读 1.7k
1 个回答

Controller 中有相关的机制,源代码请查阅: https://github.com/kubernetes/kubernetes/blob/c9c6901303cd83fc0941c2c9964771404bf9cf9f/pkg/controller/controller_utils.go#L731

这里复述一下源代码中描述的优先删除哪些pod:

  1. Unassigned < assigned
  2. PodPending < PodUnknown < PodRunning
  3. Not ready < ready
  4. Been ready for empty time < less time < more time
  5. Pods with containers with higher restart counts < lower restart counts
  6. Empty creation time pods < newer pods < older pods

简而言之,未分配、未运行的优先删除,运行时间短、重启次数多的优先删除。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进