![](https://habrastorage.org/webt/b6/z6/p0/b6z6p0ovllx9tbiusy2vwhpgwvs.png)
Protegendo um pod de despejo com orçamentos de interrupção de pod no Kubernetes
(. . — ) Kubernetes-. , pod’ . preStop
pod’ , , pod’ . pod’, pod’, . PodDisruptionBudgets ( PDB), .
PodDisruptionBudgets: pod’
pod (PDB) — , pod’ ( ).
, pod’ , , , , . drain , pod’, .
pod PodDisruptionBudget
, pod’ . , pod (PDB), pod Nginx deployment-, :
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: nginx-pdb
spec:
minAvailable: 1
selector:
matchLabels:
app: nginx
Kubernetes, , 1 pod, app: nginx
. , Kubernetes pod’ drain-, pod’ drain-.
, , . prestop-, readiness probes service . , . , , , , .
, :
![](https://habrastorage.org/webt/h7/ym/76/h7ym76qbiuqx0ynji-0-mlkznku.png)
, . , pod’ :
![](https://habrastorage.org/webt/cn/es/tv/cnestvhneu1edyu1phqnkjamg-c.png)
pod’, drain . , drain , pod’ Nginx. drain ( , ), drain .
, , , drain . , drain , “” ( NoSchedule
), pod’ . .
, , drain “” pod’ :
![](https://habrastorage.org/webt/ye/gt/e1/yegte1mhgszz6ieqtmns9w-dk58.png)
, , drain pod’ . , drain control plane, Pod Disruption Budget (PDB).
, control plane , PDB . , control plane , . , 2 pod’. pod’ 1, PDB . , pod , , , . , , control plane , , pod’ 0, PDB.
, , 1 . drain 1 pod’, drain 2 :
![](https://habrastorage.org/webt/xs/cj/ww/xscjwwuicsdrxx-3kkxbz-rxejo.png)
![](https://habrastorage.org/webt/xm/sz/8i/xmsz8ivb4zzqagudnmtlvwefmuw.png)
pod’ , Deployment
. “” NoSchedule
, scheduler :
![](https://habrastorage.org/webt/nj/a_/sn/nja_snswolramxrn9covllmid0i.png)
, pod , 1 , drain 1 .
drain 2 control plane PDB, . , pod, , , , drain 2 , pod’ (PDB). :
![](https://habrastorage.org/webt/02/k8/hl/02k8hljlnzerknuduyfa2z6p6js.png)
![](https://habrastorage.org/webt/t4/79/5r/t4795rvmfkif6mcicqm4mcnraci.png)
![](https://habrastorage.org/webt/3t/5g/b5/3t5gb58ipxyocoabrp3byp22gew.png)
, pod’ , , pod’ . , - drain , Kubernetes !
, :
- lifecycle , .
- pod’
- pod’ (PDB), , pod’ .
, — !
! . terratest, k8s endpoint. , , 300 . , , .
Kubernetes AWS , Gruntwork.io.
: