如何在 kubernetes 中使用自动缩放行为?
How to use autoscale behaviour in kubernetes?
我正在阅读following documentation。我想了解如何使用 behavior
One or more scaling policies can be specified in the behavior section
of the spec. When multiple policies are specified the policy which
allows the highest amount of change is the policy which is selected by
default. The following example shows this behavior while scaling down:
behavior:
scaleDown:
policies:
- type: Pods
value: 4
periodSeconds: 60
- type: Percent
value: 10
periodSeconds: 60
When the number of pods is more than 40 the second policy will be used
for scaling down. For instance if there are 80 replicas and the target
has to be scaled down to 10 replicas then during the first step 8
replicas will be reduced. In the next iteration when the number of
replicas is 72, 10% of the pods is 7.2 but the number is rounded up to
8. On each loop of the autoscaler controller the number of pods to be change is re-calculated based on the number of current replicas. When
the number of replicas falls below 40 the first policy(Pods) is
applied and 4 replicas will be reduced at a time. ...
我了解到,当自动缩放器决定缩减时 - 由于规则,它会减少 10% 的副本数量:
- type: Percent
value: 10
periodSeconds: 60
但是我无法理解第一条规则的含义。你能澄清一下吗?
当我们有这样的配置时,怎么可能有 80 个节点?如果每次我们有 > 40 个节点时,kubernetes 开始减少节点数量,怎么可能有 80 个节点
How is it possible to have 80 nodes when we have such config?
示例(在您引用的文档中)表示大约 80 Pods,但这只是一个随机数来说明特定示例。
How is it possible to have 80 nodes if kubernetes starts to to reduce amount of nodes each time when we have > 40 nodes
不是每次都这样。它仅开始减少 Pods 的数量 if/when Autoscaler 决定缩小规模。
I understood that when autoscaler decides to scale down - it reduces amount of replics by 10% portions
文档描述的情况是对的,当时有 80 个 Pods,由于负载不足,现在是 "deflate" 集群以降低 Pods 数量的时候了。
but I can't understand the meaning of the first rule. Could you please clarify ?
让我们再看一遍。
behavior:
scaleDown:
policies:
- type: Pods
value: 4
periodSeconds: 60
- type: Percent
value: 10
periodSeconds: 60
您可以在此处看到两项政策。即 Pods
和 Percent
。当指定多个策略时,允许最大更改量的策略是默认选择的策略。
这就是为什么如果有 80 个 pods 并且系统必须缩小到比方说 10 个,它会检查每个策略可以关闭多少 pods。
Pods
一次只允许关闭 4 pods,而 Percent
80Pods*10Percent=8Pods。 Percent
获胜,8 Pods 关闭,72 Pods 离开,流程再次开始。
这次Percent
允许关机72*0.1=7.2Pods。仍然超过 4。该值向上舍入为 8。这就是为什么 10% 的存活 Pods 再次被关闭。 72-8=64Pods 还剩。
在自动缩放控制器的每个循环中,根据当前副本的数量重新计算要更改的 pods 的数量。
所以进度应该是 80 (-8) --> 72 (-8) --> 64 (-7) --> 57 (-6) --> 51 (-6) -- > 45 (-5) --> 40
当副本数低于 40 时,应用第一个策略 Pods
,一次减少 4 个副本。
还剩 40 pods Pods
和 Percent
即将关闭 4 Pods.
36 Pods 剩余,10% 是 3.6 Pods(四舍五入前),根据第一条规则肯定小于 4 Pods。 Pods
胜,4Pods关机
进度会是 36 (-4) --> 32 (-4) --> 28...等等。
希望对您有所帮助! :)
我正在阅读following documentation。我想了解如何使用 behavior
One or more scaling policies can be specified in the behavior section of the spec. When multiple policies are specified the policy which allows the highest amount of change is the policy which is selected by default. The following example shows this behavior while scaling down:
behavior:
scaleDown:
policies:
- type: Pods
value: 4
periodSeconds: 60
- type: Percent
value: 10
periodSeconds: 60
When the number of pods is more than 40 the second policy will be used for scaling down. For instance if there are 80 replicas and the target has to be scaled down to 10 replicas then during the first step 8 replicas will be reduced. In the next iteration when the number of replicas is 72, 10% of the pods is 7.2 but the number is rounded up to 8. On each loop of the autoscaler controller the number of pods to be change is re-calculated based on the number of current replicas. When the number of replicas falls below 40 the first policy(Pods) is applied and 4 replicas will be reduced at a time. ...
我了解到,当自动缩放器决定缩减时 - 由于规则,它会减少 10% 的副本数量:
- type: Percent
value: 10
periodSeconds: 60
但是我无法理解第一条规则的含义。你能澄清一下吗?
当我们有这样的配置时,怎么可能有 80 个节点?如果每次我们有 > 40 个节点时,kubernetes 开始减少节点数量,怎么可能有 80 个节点
How is it possible to have 80 nodes when we have such config?
示例(在您引用的文档中)表示大约 80 Pods,但这只是一个随机数来说明特定示例。
How is it possible to have 80 nodes if kubernetes starts to to reduce amount of nodes each time when we have > 40 nodes
不是每次都这样。它仅开始减少 Pods 的数量 if/when Autoscaler 决定缩小规模。
I understood that when autoscaler decides to scale down - it reduces amount of replics by 10% portions
文档描述的情况是对的,当时有 80 个 Pods,由于负载不足,现在是 "deflate" 集群以降低 Pods 数量的时候了。
but I can't understand the meaning of the first rule. Could you please clarify ?
让我们再看一遍。
behavior:
scaleDown:
policies:
- type: Pods
value: 4
periodSeconds: 60
- type: Percent
value: 10
periodSeconds: 60
您可以在此处看到两项政策。即 Pods
和 Percent
。当指定多个策略时,允许最大更改量的策略是默认选择的策略。
这就是为什么如果有 80 个 pods 并且系统必须缩小到比方说 10 个,它会检查每个策略可以关闭多少 pods。
Pods
一次只允许关闭 4 pods,而 Percent
80Pods*10Percent=8Pods。 Percent
获胜,8 Pods 关闭,72 Pods 离开,流程再次开始。
这次Percent
允许关机72*0.1=7.2Pods。仍然超过 4。该值向上舍入为 8。这就是为什么 10% 的存活 Pods 再次被关闭。 72-8=64Pods 还剩。
在自动缩放控制器的每个循环中,根据当前副本的数量重新计算要更改的 pods 的数量。
所以进度应该是 80 (-8) --> 72 (-8) --> 64 (-7) --> 57 (-6) --> 51 (-6) -- > 45 (-5) --> 40
当副本数低于 40 时,应用第一个策略 Pods
,一次减少 4 个副本。
还剩 40 pods Pods
和 Percent
即将关闭 4 Pods.
36 Pods 剩余,10% 是 3.6 Pods(四舍五入前),根据第一条规则肯定小于 4 Pods。 Pods
胜,4Pods关机
进度会是 36 (-4) --> 32 (-4) --> 28...等等。
希望对您有所帮助! :)