@@ -14,21 +14,18 @@ that your application experiences, allowing for higher availability
14
14
while permitting the cluster administrator to manage the clusters
15
15
nodes.
16
16
17
-
18
-
19
17
## {{% heading "prerequisites" %}}
20
18
21
19
{{< version-check >}}
22
20
23
- * You are the owner of an application running on a Kubernetes cluster that requires
21
+ - You are the owner of an application running on a Kubernetes cluster that requires
24
22
high availability.
25
- * You should know how to deploy [ Replicated Stateless Applications] ( /docs/tasks/run-application/run-stateless-application-deployment/ )
23
+ - You should know how to deploy [ Replicated Stateless Applications] ( /docs/tasks/run-application/run-stateless-application-deployment/ )
26
24
and/or [ Replicated Stateful Applications] ( /docs/tasks/run-application/run-replicated-stateful-application/ ) .
27
- * You should have read about [ Pod Disruptions] ( /docs/concepts/workloads/pods/disruptions/ ) .
28
- * You should confirm with your cluster owner or service provider that they respect
25
+ - You should have read about [ Pod Disruptions] ( /docs/concepts/workloads/pods/disruptions/ ) .
26
+ - You should confirm with your cluster owner or service provider that they respect
29
27
Pod Disruption Budgets.
30
28
31
-
32
29
<!-- steps -->
33
30
34
31
## Protecting an Application with a PodDisruptionBudget
38
35
1 . Create a PDB definition as a YAML file.
39
36
1 . Create the PDB object from the YAML file.
40
37
41
-
42
-
43
38
<!-- discussion -->
44
39
45
40
## Identify an Application to Protect
@@ -61,29 +56,28 @@ You can also use PDBs with pods which are not controlled by one of the above
61
56
controllers, or arbitrary groups of pods, but there are some restrictions,
62
57
described in [ Arbitrary Controllers and Selectors] ( #arbitrary-controllers-and-selectors ) .
63
58
64
-
65
59
## Think about how your application reacts to disruptions
66
60
67
61
Decide how many instances can be down at the same time for a short period
68
62
due to a voluntary disruption.
69
63
70
64
- Stateless frontends:
71
- - Concern: don't reduce serving capacity by more than 10%.
65
+ - Concern: don't reduce serving capacity by more than 10%.
72
66
- Solution: use PDB with minAvailable 90% for example.
73
67
- Single-instance Stateful Application:
74
68
- Concern: do not terminate this application without talking to me.
75
69
- Possible Solution 1: Do not use a PDB and tolerate occasional downtime.
76
- - Possible Solution 2: Set PDB with maxUnavailable=0. Have an understanding
70
+ - Possible Solution 2: Set PDB with maxUnavailable=0. Have an understanding
77
71
(outside of Kubernetes) that the cluster operator needs to consult you before
78
- termination. When the cluster operator contacts you, prepare for downtime,
79
- and then delete the PDB to indicate readiness for disruption. Recreate afterwards.
72
+ termination. When the cluster operator contacts you, prepare for downtime,
73
+ and then delete the PDB to indicate readiness for disruption. Recreate afterwards.
80
74
- Multiple-instance Stateful application such as Consul, ZooKeeper, or etcd:
81
75
- Concern: Do not reduce number of instances below quorum, otherwise writes fail.
82
76
- Possible Solution 1: set maxUnavailable to 1 (works with varying scale of application).
83
- - Possible Solution 2: set minAvailable to quorum-size (e.g. 3 when scale is 5). (Allows more disruptions at once).
77
+ - Possible Solution 2: set minAvailable to quorum-size (e.g. 3 when scale is 5). (Allows more disruptions at once).
84
78
- Restartable Batch Job:
85
79
- Concern: Job needs to complete in case of voluntary disruption.
86
- - Possible solution: Do not create a PDB. The Job controller will create a replacement pod.
80
+ - Possible solution: Do not create a PDB. The Job controller will create a replacement pod.
87
81
88
82
### Rounding logic when specifying percentages
89
83
@@ -103,25 +97,25 @@ that controls this behavior.
103
97
104
98
## Specifying a PodDisruptionBudget
105
99
106
- A ` PodDisruptionBudget ` has three fields:
100
+ A ` PodDisruptionBudget ` has three fields:
107
101
108
- * A label selector ` .spec.selector ` to specify the set of
109
- pods to which it applies. This field is required.
110
- * ` .spec.minAvailable ` which is a description of the number of pods from that
111
- set that must still be available after the eviction, even in the absence
112
- of the evicted pod. ` minAvailable ` can be either an absolute number or a percentage.
113
- * ` .spec.maxUnavailable ` (available in Kubernetes 1.7 and higher) which is a description
114
- of the number of pods from that set that can be unavailable after the eviction.
115
- It can be either an absolute number or a percentage.
102
+ - A label selector ` .spec.selector ` to specify the set of
103
+ pods to which it applies. This field is required.
104
+ - ` .spec.minAvailable ` which is a description of the number of pods from that
105
+ set that must still be available after the eviction, even in the absence
106
+ of the evicted pod. ` minAvailable ` can be either an absolute number or a percentage.
107
+ - ` .spec.maxUnavailable ` (available in Kubernetes 1.7 and higher) which is a description
108
+ of the number of pods from that set that can be unavailable after the eviction.
109
+ It can be either an absolute number or a percentage.
116
110
117
111
{{< note >}}
118
112
The behavior for an empty selector differs between the policy/v1beta1 and policy/v1 APIs for
119
113
PodDisruptionBudgets. For policy/v1beta1 an empty selector matches zero pods, while
120
114
for policy/v1 an empty selector matches every pod in the namespace.
121
115
{{< /note >}}
122
116
123
- You can specify only one of ` maxUnavailable ` and ` minAvailable ` in a single ` PodDisruptionBudget ` .
124
- ` maxUnavailable ` can only be used to control the eviction of pods
117
+ You can specify only one of ` maxUnavailable ` and ` minAvailable ` in a single ` PodDisruptionBudget ` .
118
+ ` maxUnavailable ` can only be used to control the eviction of pods
125
119
that have an associated controller managing them. In the examples below, "desired replicas"
126
120
is the ` scale ` of the controller managing the pods being selected by the
127
121
` PodDisruptionBudget ` .
@@ -130,20 +124,20 @@ Example 1: With a `minAvailable` of 5, evictions are allowed as long as they lea
130
124
5 or more [ healthy] ( #healthiness-of-a-pod ) pods among those selected by the PodDisruptionBudget's ` selector ` .
131
125
132
126
Example 2: With a ` minAvailable ` of 30%, evictions are allowed as long as at least 30%
133
- of the number of desired replicas are healthy.
127
+ of the number of desired replicas are healthy.
134
128
135
129
Example 3: With a ` maxUnavailable ` of 5, evictions are allowed as long as there are at most 5
136
130
unhealthy replicas among the total number of desired replicas.
137
131
138
- Example 4: With a ` maxUnavailable ` of 30%, evictions are allowed as long as no more than 30%
132
+ Example 4: With a ` maxUnavailable ` of 30%, evictions are allowed as long as no more than 30%
139
133
of the desired replicas are unhealthy.
140
134
141
135
In typical usage, a single budget would be used for a collection of pods managed by
142
- a controller—for example, the pods in a single ReplicaSet or StatefulSet.
136
+ a controller—for example, the pods in a single ReplicaSet or StatefulSet.
143
137
144
138
{{< note >}}
145
139
A disruption budget does not truly guarantee that the specified
146
- number/percentage of pods will always be up. For example, a node that hosts a
140
+ number/percentage of pods will always be up. For example, a node that hosts a
147
141
pod from the collection may fail when the collection is at the minimum size
148
142
specified in the budget, thus bringing the number of available pods from the
149
143
collection below the specified size. The budget can only protect against
@@ -156,7 +150,7 @@ object such as ReplicaSet, then you cannot successfully drain a Node running one
156
150
If you try to drain a Node where an unevictable Pod is running, the drain never completes. This is permitted as per the
157
151
semantics of ` PodDisruptionBudget ` .
158
152
159
- You can find examples of pod disruption budgets defined below. They match pods with the label
153
+ You can find examples of pod disruption budgets defined below. They match pods with the label
160
154
` app: zookeeper ` .
161
155
162
156
Example PDB Using minAvailable:
@@ -246,8 +240,8 @@ on the [API server](/docs/reference/command-line-tools-reference/kube-apiserver/
246
240
247
241
PodDisruptionBudget guarding an application ensures that `.status.currentHealthy` number of pods
248
242
does not fall below the number specified in `.status.desiredHealthy` by disallowing eviction of healthy pods.
249
- By using `.spec.unhealthyPodEvictionPolicy`, you can also define the criteria when unhealthy pods
250
- should be considered for eviction. The default behavior when no policy is specified corresponds
243
+ By using `.spec.unhealthyPodEvictionPolicy`, you can also define the criteria when unhealthy pods
244
+ should be considered for eviction. The default behavior when no policy is specified corresponds
251
245
to the `IfHealthyBudget` policy.
252
246
253
247
Policies :
@@ -287,6 +281,6 @@ You can use a PDB with pods controlled by another type of controller, by an
287
281
- only an integer value can be used with `.spec.minAvailable`, not a percentage.
288
282
289
283
You can use a selector which selects a subset or superset of the pods belonging to a built-in
290
- controller. The eviction API will disallow eviction of any pod covered by multiple PDBs,
291
- so most users will want to avoid overlapping selectors. One reasonable use of overlapping
284
+ controller. The eviction API will disallow eviction of any pod covered by multiple PDBs,
285
+ so most users will want to avoid overlapping selectors. One reasonable use of overlapping
292
286
PDBs is when pods are being transitioned from one PDB to another.
0 commit comments