Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.87 KB

configure-pod-disruption-budget.md

File metadata and controls

52 lines (35 loc) · 1.87 KB

Configure PodDisruptionBudget

Before you begin

Write manifest file

Here is an example of PodDisruptionBudget manifest yaml:

apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  name: mercari-echo-jp
  namespace: mercari-echo-jp-prod
spec:
  maxUnavailable: 33%
  selector:
    matchLabels:
      app: mercari-echo-jp

For example, with a maxUnavailable of 33%, evictions are allowed as long as no more than 33% of the desired replicas are unhealthy.

If you follow the resource request/limit guidelines, it is recommended to use a maxUnavailable: 33% PDB.

⚠️ Avoid specifying number of replicas

If you specify number of replicas (e.g. 5) instead of percentage (e.g. 33%), you will get unexpected disruption when the pods auto scales.

For example, instead of using:

spec:
  maxUnavailable: 5   # bad: will cause problems with autoscaling

it is recommended to use a percentage:

spec:
  maxUnavailable: 33%   # good

⚠️ Do not use a non-resolvable combination of replicas and maxUnavailable values

When specifying maxUnavailable, either percentage or replicas, please make sure the deployment subject to the PDB doesn't break the PDB acceptance.

For example, if your Deployment has replicas: 1 and a PDB with maxUnavailable: 20%, the PDB controller will not be able to drain your pods, freezing the draining process, thus affecting the whole cluster drain process. Same for replicas: 2 and maxUnavailable: 66%. To make it resolvable, either change the replicas to 3 or maxUnavailable to 50%. Please *always make sure your PDB maxUnavailable value is resolvable.