---
title: Configure Quality of Service for Pods
content_type: task
weight: 30
---
# Konfigurasi Quality of Service untuk Pod
<!-- overview -->
Halaman ini menunjukkan bagaimana mengkonfigurasi Pods agar ditempatkan pada kelas Quality of Service (QoS) khusus.
. Kubernetes menggunakan kelas QoS untuk membuat keputusan tentang
menjadwalkan dan mengeluarkan Pod.
This page shows how to configure Pods so that they will be assigned particular Quality of Service (QoS) classes. Kubernetes uses QoS classes to make decisions about scheduling and evicting Pods.
## {{% heading "prerequisites" %}}
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
<!-- steps -->
## QoS classes
Saat Kubernetes membuat Pod, ia menetapkan salah satu kelas QoS berikut ke Pod:
* Guaranteed
* Burstable
* BestEffort
## Create a namespace
Buat namespace sehingga *resource* yang Anda buat dalam latihan ini
diisolasi dari cluster Anda yang lain. (translate sendiri).
```shell
kubectl create namespace qos-example
```
## Create a Pod that gets assigned a QoS class of Guaranteed
Agar Pod memiliki Kelas QoS Guaranteed:
* Setiap Container, termasuk init containers, dalam Pod harus memiliki memory limit dan memory request, dan keduanya harus sama.
* Setiap Container, termasuk init containers, dalam Pod harus memiliki sebuah CPU limit dan sebuah CPU request, dan keduanya harus sama.
// in the Pod must have a memory limit and a memory request, and they must be the same.
// * Every Container, including init containers, in the Pod must have a CPU limit and a CPU request, and they must be the same.
Berikut adalah file konfigurasi untuk Pod yang memiliki satu Container. Container tersebut memiliki sebuah memory limit dan memory request, keduanya memiliki kapasitas 200MiB.
Container tersebut memiliki sebuah CPU limit dan sebuah CPU request, keduanya memiliki kapasitas 700milliCPU:
//Here is the configuration file for a Pod that has one Container. The Container has a memory limit and a
memory request, both equal to 200 MiB. The Container has a CPU limit and a CPU request, both equal to 700 milliCPU:
{{< codenew file="pods/qos/qos-pod.yaml" >}}
Membuat Pod:
Create the Pod
```shell
kubectl apply -f https://k8s.io/examples/pods/qos/qos-pod.yaml --namespace=qos-example
```
Melihat informasi detail mengenai Pod:
//View detailed information about the Pod
```shell
kubectl get pod qos-demo --namespace=qos-example --output=yaml
```
Hasil menampilkan bahwa Kubernetes memberikan kelas QoS Guaranteed pada Pod. Hasil juga mengesahkan bahwa Pod Container memiliki memory request yang cocok dengan memory limitnya, dan CPU request yang cocok dengan CPU limitnya.
The output shows that Kubernetes gave the Pod a QoS class of Guaranteed. The output also
verifies that the Pod Container has a memory request that matches its memory limit, and it has
a CPU request that matches its CPU limit.
```yaml
spec:
containers:
...
resources:
limits:
cpu: 700m
memory: 200Mi
requests:
cpu: 700m
memory: 200Mi
...
status:
qosClass: Guaranteed
```
{{< note >}}
Jika sebuah Container menentukan sendiri memory limitnya, namun tidak menentukan memory request, Kubernetes secara otomatis akan menetapkan memory request yang cocok dengan memory limitnya. Sama halnya jika sebuah Container menentukan sendiri CPU limitnya, namun tidak menetapkan CPU request, Kubernetes secara otomatis akan menetapkan CPU request yang cocok dengan limitnya.
If a Container specifies its own memory limit, but does not specify a memory request, Kubernetes
automatically assigns a memory request that matches the limit. Similarly, if a Container specifies its own
CPU limit, but does not specify a CPU request, Kubernetes automatically assigns a CPU request that matches
the limit.
{{< /note >}}
Menghapus Pod anda:
```shell
kubectl delete pod qos-demo --namespace=qos-example
```
## Create a Pod that gets assigned a QoS class of Burstable
Pod akan mendapatkan kelas QoS Burstable apabila:
//A Pod is given a QoS class of Burstable if:
* Pod tidak memenuhi kriteria untuk kelas QoS Guaranteed.
* Minimal satu kontainer dalam Pod memiliki sebuah memory atau CPU request.
//* The Pod does not meet the criteria for QoS class Guaranteed.
//* At least one Container in the Pod has a memory or CPU request.
Berikut adalah file konfigurasi untuk Pod yang memiliki satu Container. Container yang dimaksud memiliki
memory limit sebesar 200MiB
dan memory request sebesar 100MiB
//Here is the configuration file for a Pod that has one Container. The Container has a memory limit of 200 MiB
and a memory request of 100 MiB.
{{< codenew file="pods/qos/qos-pod-2.yaml" >}}
Membuat Pod:
```shell
kubectl apply -f https://k8s.io/examples/pods/qos/qos-pod-2.yaml --namespace=qos-example
```
Melihat informasi detail mengenai Pod
//View detailed information about the Pod:
```shell
kubectl get pod qos-demo-2 --namespace=qos-example --output=yaml
```
Hasil menampilkan bahwa Kubernetes memberikan kelas QoS Burstable pada Pod.
//The output shows that Kubernetes gave the Pod a QoS class of Burstable.
```yaml
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: qos-demo-2-ctr
resources:
limits:
memory: 200Mi
requests:
memory: 100Mi
...
status:
qosClass: Burstable
```
Menghapus Pod anda:
// Delete your Pod:
```shell
kubectl delete pod qos-demo-2 --namespace=qos-example
```
## Create a Pod that gets assigned a QoS class of BestEffort
Agar Pod mendapatkan kelas QoS BestEffort, Container-Container dalam pod tidak boleh sama sekali memiliki memory atau CPU limit atau request.
//For a Pod to be given a QoS class of BestEffort, the Containers in the Pod must not
have any memory or CPU limits or requests.
Berikut adalah file konfigurasi untuk Pod yang memiliki satu Container. Container yang dimaksud tidak memiliki memory atau CPU limit atau request.
//Here is the configuration file for a Pod that has one Container. The Container has no memory or CPU
limits or requests:
{{< codenew file="pods/qos/qos-pod-3.yaml" >}}
Membuat Pod:
```shell
kubectl apply -f https://k8s.io/examples/pods/qos/qos-pod-3.yaml --namespace=qos-example
```
Melihat informasi detail mengenai Pod
//View detailed information about the Pod:
```shell
kubectl get pod qos-demo-3 --namespace=qos-example --output=yaml
```
Hasil menampilkan bahwa Kubernetes memberikan kelas QoS BestEffort pada Pod.
//The output shows that Kubernetes gave the Pod a QoS class of BestEffort.
```yaml
spec:
containers:
...
resources: {}
...
status:
qosClass: BestEffort
```
Menghapus Pod
//Delete your Pod:
```shell
kubectl delete pod qos-demo-3 --namespace=qos-example
```
## Create a Pod that has two Containers
Berikut adalah konfigurasi file untuk Pod yang memiliki dua Container. Satu Container menentukan memory request sebesar 200MiB. Container yang lain tidak menentukan request atau limit sama sekali
//Here is the configuration file for a Pod that has two Containers. One container specifies a memory
request of 200 MiB. The other Container does not specify any requests or limits.
{{< codenew file="pods/qos/qos-pod-4.yaml" >}}
Perhatikan bahwa Pod ini memenuhi kriteria untuk kelas QoS Burstable. Maksudnya, Container tersebut tidak memenuhi kriteria untuk kelas QoS Guaranteed, dan satu dari Container-Containernya memiliki memory request.
//Notice that this Pod meets the criteria for QoS class Burstable. That is, it does not meet the
criteria for QoS class Guaranteed, and one of its Containers has a memory request.
Membuat Pod:
```shell
kubectl apply -f https://k8s.io/examples/pods/qos/qos-pod-4.yaml --namespace=qos-example
```
Melihat informasi detail mengenai Pod
//View detailed information about the Pod:
```shell
kubectl get pod qos-demo-4 --namespace=qos-example --output=yaml
```
Hasil menampilkan bahwa Kubernetes memberikan kelas QoS Burstaable pada Pod.
//The output shows that Kubernetes gave the Pod a QoS class of Burstable:
```yaml
spec:
containers:
...
name: qos-demo-4-ctr-1
resources:
requests:
memory: 200Mi
...
name: qos-demo-4-ctr-2
resources: {}
...
status:
qosClass: Burstable
```
Menghapus Pod anda:
//Delete your Pod:
```shell
kubectl delete pod qos-demo-4 --namespace=qos-example
```
## Clean up
Menghapus *namespace
//Delete your namespace:
```shell
kubectl delete namespace qos-example
```
## {{% heading "whatsnext" %}}
### For app developers
* [Assign Memory Resources to Containers and Pods](/docs/tasks/configure-pod-container/assign-memory-resource/)
* [Assign CPU Resources to Containers and Pods](/docs/tasks/configure-pod-container/assign-cpu-resource/)
### For cluster administrators
* [Configure Default Memory Requests and Limits for a Namespace](/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/)
* [Configure Default CPU Requests and Limits for a Namespace](/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)
* [Configure Minimum and Maximum Memory Constraints for a Namespace](/docs/tasks/administer-cluster/manage-resources/memory-constraint-namespace/)
* [Configure Minimum and Maximum CPU Constraints for a Namespace](/docs/tasks/administer-cluster/manage-resources/cpu-constraint-namespace/)
* [Configure Memory and CPU Quotas for a Namespace](/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/)
* [Configure a Pod Quota for a Namespace](/docs/tasks/administer-cluster/manage-resources/quota-pod-namespace/)
* [Configure Quotas for API Objects](/docs/tasks/administer-cluster/quota-api-object/)
* [Control Topology Management policies on a node](/docs/tasks/administer-cluster/topology-manager/)