|
| 1 | +--- |
| 2 | +title: Pod Quality of Service Classes |
| 3 | +content_type: concept |
| 4 | +weight: 30 |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- overview --> |
| 8 | + |
| 9 | +This page introduces _Quality of Service (QoS) classes_ in Kubernetes, and explains |
| 10 | +how Kubernetes assigns a QoS class to each Pods as a consequence of the resource |
| 11 | +constraints that you specify for the containers in that Pod. Kubernetes relies on this |
| 12 | +classification to make decisions about which Pods to evict when there are not enough |
| 13 | +available resources on a Node. |
| 14 | + |
| 15 | +<!-- body --> |
| 16 | + |
| 17 | +## Quality of Service classes |
| 18 | + |
| 19 | +Kubernetes classifies the Pods that you run and allocates each Pod into a specific |
| 20 | +_quality of service (QoS) class_. Kubernetes uses that classification to influence how different |
| 21 | +pods are handled. Kubernetes does this classification based on the |
| 22 | +[resource requests](/docs/concepts/configuration/manage-resources-containers/) |
| 23 | +of the {{< glossary_tooltip text="Containers" term_id="container" >}} in that Pod, along with |
| 24 | +how those requests relate to resource limits. |
| 25 | +This is known as {{< glossary_tooltip text="Quality of Service" term_id="qos-class" >}} |
| 26 | +(QoS) class. Kubernetes assigns every Pod a QoS class based on the resource requests |
| 27 | +and limits of its component Containers. QoS classes are used by Kubernetes to decide |
| 28 | +which Pods to evict from a Node experiencing |
| 29 | +[Node Pressure](/docs/concepts/scheduling-eviction/node-pressure-eviction/). The possible |
| 30 | +QoS classes are `Guaranteed`, `Burstable`, and `BestEffort`. When a Node runs out of resources, |
| 31 | +Kubernetes will first evict `BestEffort` Pods running on that Node, followed by `Burstable` and |
| 32 | +finally `Guaranteed` Pods. When this eviction is due to resource pressure, only Pods exceeding |
| 33 | +resource requests are candidates for eviction. |
| 34 | + |
| 35 | +### Guaranteed |
| 36 | + |
| 37 | +Pods that are `Guaranteed` have the strictest resource limits and are least likely |
| 38 | +to face eviction. They are guaranteed not to be killed until they exceed their limits |
| 39 | +or there are no lower-priority Pods that can be preempted from the Node. They may |
| 40 | +not acquire resources beyond their specified limits. These Pods can also make |
| 41 | +use of exclusive CPUs using the |
| 42 | +[`static`](/docs/tasks/administer-cluster/cpu-management-policies/#static-policy) CPU management policy. |
| 43 | + |
| 44 | +#### Criteria |
| 45 | + |
| 46 | +For a Pod to be given a QoS class of `Guaranteed`: |
| 47 | + |
| 48 | +* Every Container in the Pod must have a memory limit and a memory request. |
| 49 | +* For every Container in the Pod, the memory limit must equal the memory request. |
| 50 | +* Every Container in the Pod must have a CPU limit and a CPU request. |
| 51 | +* For every Container in the Pod, the CPU limit must equal the CPU request. |
| 52 | + |
| 53 | +### Burstable |
| 54 | + |
| 55 | +Pods that are `Burstable` have some lower-bound resource guarantees based on the request, but |
| 56 | +do not require a specific limit. If a limit is not specified, it defaults to a |
| 57 | +limit equivalent to the capacity of the Node, which allows the Pods to flexibly increase |
| 58 | +their resources if resources are available. In the event of Pod eviction due to Node |
| 59 | +resource pressure, these Pods are evicted only after all `BestEffort` Pods are evicted. |
| 60 | +Because a `Burstable` Pod can include a Container that has no resource limits or requests, a Pod |
| 61 | +that is `Burstable` can try to use any amount of node resources. |
| 62 | + |
| 63 | +#### Criteria |
| 64 | + |
| 65 | +A Pod is given a QoS class of `Burstable` if: |
| 66 | + |
| 67 | +* The Pod does not meet the criteria for QoS class `Guaranteed`. |
| 68 | +* At least one Container in the Pod has a memory or CPU request or limit. |
| 69 | + |
| 70 | +### BestEffort |
| 71 | + |
| 72 | +Pods in the `BestEffort` QoS class can use node resources that aren't specifically assigned |
| 73 | +to Pods in other QoS classes. For example, if you have a node with 16 CPU cores available to the |
| 74 | +kubelet, and you assign assign 4 CPU cores to a `Guaranteed` Pod, then a Pod in the `BestEffort` |
| 75 | +QoS class can try to use any amount of the remaining 12 CPU cores. |
| 76 | + |
| 77 | +The kubelet prefers to evict `BestEffort` Pods if the node comes under resource pressure. |
| 78 | + |
| 79 | +#### Criteria |
| 80 | + |
| 81 | +A Pod has a QoS class of `BestEffort` if it doesn't meet the criteria for either `Guaranteed` |
| 82 | +or `Burstable`. In other words, a Pod is `BestEffort` only if none of the Containers in the Pod have a |
| 83 | +memory limit or a memory request, and none of the Containers in the Pod have a |
| 84 | +CPU limit or a CPU request. |
| 85 | +Containers in a Pod can request other resources (not CPU or memory) and still be classified as |
| 86 | +`BestEffort`. |
| 87 | + |
| 88 | +## Some behavior is independent of QoS class {#class-independent-behavior} |
| 89 | + |
| 90 | +Certain behavior is independent of the QoS class assigned by Kubernetes. For example: |
| 91 | + |
| 92 | +* Any Container exceeding a resource limit will be killed and restarted by the kubelet without |
| 93 | + affecting other Containers in that Pod. |
| 94 | + |
| 95 | +* If a Container exceeds its resource request and the node it runs on faces |
| 96 | + resource pressure, the Pod it is in becomes a candidate for [eviction](/docs/concepts/scheduling-eviction/node-pressure-eviction/). |
| 97 | + If this occurs, all Containers in the Pod will be terminated. Kubernetes may create a |
| 98 | + replacement Pod, usually on a different node. |
| 99 | + |
| 100 | +* The resource request of a Pod is equal to the sum of the resource requests of |
| 101 | + its component Containers, and the resource limit of a Pod is equal to the sum of |
| 102 | + the resource limits of its component Containers. |
| 103 | + |
| 104 | +* The kube-scheduler does not consider QoS class when selecting which Pods to |
| 105 | + [preempt](/docs/concepts/scheduling-eviction/pod-priority-preemption/#preemption). |
| 106 | + Preemption can occur when a cluster does not have enough resources to run all the Pods |
| 107 | + you defined. |
| 108 | + |
| 109 | +## {{% heading "whatsnext" %}} |
| 110 | + |
| 111 | +* Learn about [resource management for Pods and Containers](/docs/concepts/configuration/manage-resources-containers/). |
| 112 | +* Learn about [Node-pressure eviction](/docs/concepts/scheduling-eviction/node-pressure-eviction/). |
| 113 | +* Learn about [Pod priority and preemption](/docs/concepts/scheduling-eviction/pod-priority-preemption/). |
| 114 | +* Learn about [Pod disruptions](/docs/concepts/workload/pods/disruptions/). |
| 115 | +* Learn how to [assign memory resources to containers and pods](/docs/tasks/configure-pod-container/assign-memory-resource/). |
| 116 | +* Learn how to [assign CPU resources to containers and pods](/docs/tasks/configure-pod-container/assign-cpu-resource/). |
| 117 | +* Learn how to [configure Quality of Service for Pods](/docs/tasks/configure-pod-container/quality-service-pod/). |
0 commit comments