gpt4 book ai didi

kubernetes pdb 允许中断为 0

转载 作者:行者123 更新时间:2023-12-05 02:41:13 25 4
gpt4 key购买 nike

我正在尝试部署 PodDisruptionBudget对于我的部署,但是当我部署这个例子时

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: example-pdb
spec:
minAvailable: 1
selector:
matchLabels:
app: example-deployment

使用此部署

apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 1
selector:
matchLabels:
app: example-deployment-app
template:
metadata:
labels:
app: example-deployment-app
spec:
...

我收到回复

$ kubectl get pdb
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
example-pdb 1 N/A 0 7s

“允许中断”为 0 是什么意思?

最佳答案

Specifying a PodDisruptionBudget 所述:

A PodDisruptionBudget has three fields:

  • A label selector .spec.selector to specify the set of pods to which it applies. This field is required.

  • .spec.minAvailable which is a description of the number of pods from that set that must still be available after the eviction, even inthe absence of the evicted pod. minAvailable can be either anabsolute number or a percentage.

  • .spec.maxUnavailable (available in Kubernetes 1.7 and higher) which is a description of the number of pods from that set that can beunavailable after the eviction. It can be either an absolute number ora percentage.

在您的情况下,.spec.minAvailable 设置为 1,因此 1 Pod 必须始终可用,即使在中断期间也是如此。

现在查看您的 Deployment 的 .spec.replicas 设置为 1,它与 .spec.minAvailable: 1 的组合意味着有该配置不允许中断。

看看 official example :

Use kubectl to check that your PDB is created.

Assuming you don't actually have pods matching app: zookeeper inyour namespace, then you'll see something like this:

kubectl get poddisruptionbudgets
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
zk-pdb 2 N/A 0 7s

If there are matching pods (say, 3), then you would see something likethis:

kubectl get poddisruptionbudgets
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
zk-pdb 2 N/A 1 7s

The non-zero value for ALLOWED DISRUPTIONS means that the disruptioncontroller has seen the pods, counted the matching pods, and updatedthe status of the PDB.

You can get more information about the status of a PDB with thiscommand:

kubectl get poddisruptionbudgets zk-pdb -o yaml

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
annotations:

creationTimestamp: "2020-03-04T04:22:56Z"
generation: 1
name: zk-pdb

status:
currentHealthy: 3
desiredHealthy: 2
disruptionsAllowed: 1
expectedPods: 3
observedGeneration: 1

您可以看到,如果 .spec.minAvailable 设置为 2 并且有 3 个正在运行的 Pod,那么 disruptionsAllowed 实际上是 1 .您可以检查您的用例。

关于kubernetes pdb 允许中断为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68184909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com