Kubernetes 复制控制器缩放查询

Kubernetes Replication Controller Scaling Query

我想知道 Replication Controller 在缩减请求期间采用什么终止策略。

例如:

Initial replicas = 2

2 Pods are created { Pod-1, Pod-2 }

Scale out to 5

3 more Pods will be created { Pod-1, Pod-2, Pod-3, Pod-4, Pod-5 }

Scale down to 2 again

3 Pods will be deleted, and we are left with only 2 Pods { Pod-x, Pod-y }

现在,复制控制器会根据年龄终止并删除 pods 吗?或者这取决于 Pod 内的容器是否繁忙?还是随机顺序?

我测试了这个场景几次,发现 Pods 是随机终止的。任何人都可以确认吗?有没有办法控制终止顺序?

提前致谢。

A Kubernetes 复制控制器确保指定数量的 pod "replicas" 在任何给定时间是 运行。如果有太多,它会杀死一些。如果太少,它会开始更多。与用户直接创建的情况不同 pods 由 ReplicationController 维护的那些在失败、删除或终止时会自动替换

pods的select离子在缩小过程中被杀死是有逻辑的。

用于select 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

没有可以设置的配置选项来避免特定 pods 被杀死。如果您想详细了解它是如何工作的-请查看源代码,祝您愉快lecture.