You can create a pod with a quality of service (QoS) class of Guaranteed
for high-performance workloads. Configuring a pod with a QoS class of Guaranteed
ensures that the pod has priority access to the specified CPU and memory resources.
To create a pod with a QoS class of Guaranteed
, you must apply the following specifications:
In general, a pod with a QoS class of Guaranteed
will not be evicted from a node. One exception is during resource contention caused by system daemons exceeding reserved resources. In this scenario, the kubelet
might evict pods to preserve node stability, starting with the lowest priority pods.
Procedure
-
Create a namespace for the pod by running the following command:
$ oc create namespace qos-example (1)
1 |
This example uses the qos-example namespace. |
Example output
namespace/qos-example created
-
Create the Pod
resource:
-
Create a YAML file that defines the Pod
resource:
Example qos-example.yaml
file
apiVersion: v1
kind: Pod
metadata:
name: qos-demo
namespace: qos-example
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
containers:
- name: qos-demo-ctr
image: quay.io/openshifttest/hello-openshift:openshift (1)
resources:
limits:
memory: "200Mi" (2)
cpu: "1" (3)
requests:
memory: "200Mi" (4)
cpu: "1" (5)
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
1 |
This example uses a public hello-openshift image. |
2 |
Sets the memory limit to 200 MB. |
3 |
Sets the CPU limit to 1 CPU. |
4 |
Sets the memory request to 200 MB. |
5 |
Sets the CPU request to 1 CPU.
|
If you specify a memory limit for a container, but do not specify a memory request, OKD automatically assigns a memory request that matches the limit. Similarly, if you specify a CPU limit for a container, but do not specify a CPU request, OKD automatically assigns a CPU request that matches the limit.
|
|
-
Create the Pod
resource by running the following command:
$ oc apply -f qos-example.yaml --namespace=qos-example