kubernetes - Kubernetes 复制控制器扩展查询
问题描述
我想知道在缩减请求期间复制控制器采用什么终止策略。
例如:
初始副本 = 2
创建了 2 个 Pod { Pod-1, Pod-2 }
扩展至 5
将再创建 3 个 Pod { Pod-1, Pod-2, Pod-3, Pod-4, Pod-5 }
再次缩小到 2
3 个 Pod 将被删除,我们只剩下 2 个 Pod { Pod-x, Pod-y }
现在,Replication 控制器会根据 Pod 的年龄终止并删除 Pod 吗?还是取决于 Pod 内的容器是否忙?还是随机顺序?
我对这种情况进行了几次测试,发现 Pod 是随机终止的。任何人都可以确认吗?有没有办法控制终止顺序?
提前致谢。
解决方案
Kubernetes复制控制器确保在任何给定时间运行指定数量的 pod“副本” 。如果有太多,它会杀死一些。如果太少,它会开始更多。与用户直接创建的 Pod 不同,由 ReplicationController 维护的 Pod 在失败、删除或终止时会自动替换
在缩减过程中选择要杀死的 pod 是有逻辑的。
开发人员描述了用于选择要杀死的 pod 的工资:
// 1. Unassigned < assigned
// If only one of the pods is unassigned, the unassigned one is smaller
// 2. PodPending < PodUnknown < PodRunning
// 3. Not ready < ready
// 4. Been ready for empty time < less time < more time
// If both pods are ready, the latest ready one is smaller
// 5. Pods with containers with higher restart counts < lower restart counts
// 6. Empty creation time pods < newer pods < older pods
没有可以设置的配置选项来避免特定的 pod 被杀死。如果你想详细了解它是如何工作的——请查看源代码,好好听讲。
推荐阅读
- node.js - 在创建反应应用程序时,进程停止并显示 1 个漏洞(运行 npm 审计)
- ios - macCatalyst 上的通用链接不起作用
- javascript - 从元素列表中获取输入数据
- django - 如何在 django 过滤器中实现 2 个布尔字段条件 OR?
- django - 从 React 前端向 Django 发送 POST 时出错,错误状态 401
- ruby-on-rails - 上传到 ActionText 文本区域的图像未正确链接到 S3
- r - 如何更改 facet_nested 标签之一的位置?
- qt - QML:列不适用于自定义类型
- javascript - 快速切换页面后在 axios 调用中反应 setState
- python - 通过在 Pandas 中创建列按组展平 DataFrame