DevOps
  • DevOps
  • Docker
    • Overview
  • Vagrant
    • Overview
    • Installation
    • Basic Commands
    • Vagrantfile
      • Example
    • Deploying Multiple Machine
    • Distribution
    • Reference
  • Running SQL Server on Windows Docker
    • Introduction
      • Windows Container & Hyper-V Container
    • System Requirements and Prerequisites
    • Version Compatibility
    • Enable Hyper-V & Containers and Install Docker on Window Servers
    • Using Docker to Run MSSQL Image
    • Install SSMS for remoting MSSQL Server Image
    • Using Docker-Compose to Build Up a MSSQL Image
    • Increase the default Windows container's storage
    • Reference
    • Appendix
  • Kubernetes
    • Install Kubernetes with kubeasz
    • Use Hyper-V Manager to create VM for K8S
      • Specification of the VM
      • Use Hyper-V Manager to turn on a VM for K8S
    • Installation
      • Install VirtualBox and its extension on Ubuntu
      • Install kubectl
      • Install minikube
    • Getting Started
      • Running Kubernetes Locally via Minikube
    • Assign Memory Resources to Containers and Pods
    • Assign CPU Resources to Containers and Pods
    • Quality of Services (QoS)
    • Volume for Storage
      • Configure a Pod to Use a Volume for Storage
      • *Configure a Pod to Use a PersistentVolume for Storage
    • In a nutshell...
    • Reference
  • Ansible
    • What is Ansible?
    • Set Up OS Environments for Ansible
    • Install Ansible
    • Structure for ansible
      • Inventory
      • Playbook
      • Modules
      • Variables
      • Conditions
    • Security - Ansible Fault
    • 實際操作測試1 - 使用ssh
    • 實際操作測試2 - Docker容器部署
    • Appendix
    • Reference
  • Azure
    • Overview
    • Terms
    • Getting Started
    • Azure DevOps Services
    • Reference
Powered by GitBook
On this page
  • QoS Classes
  • Guaranteed
  • Burstable
  • BestEffort
  • Practice
  • QoS優先級
  • QoS pods被kill掉場景與順序
  • 使用建議

Was this helpful?

  1. Kubernetes

Quality of Services (QoS)

QoS Classes

When Kubernetes creates a Pod it assigns one of these QoS classes to the Pod:

  • Guaranteed

  • Burstable

  • BestEffort

Guaranteed

Pod中所有容器都必須統一設置limits,並且設置參數都一致,如果有一個容器要設置requests,那麽所有容器都要設置,並設置參數同limits一致,那麽這個pod的QoS就是Guaranteed級別。 註:如果一個容器只指明limit而未設定request,則request的值等於limit值。

For a Pod to be given a QoS class of Guaranteed:

  • Every Container in the Pod must have a memory limit and a memory request, and they must be the same.

  • Every Container in the Pod must have a CPU limit and a CPU request, and they must be the same.

Burstable

pod中只要有一個容器的requests和limits的設置不相同,該pod的QoS即為Burstable。

A Pod is given a QoS class of Burstable if:

  • The Pod does not meet the criteria for QoS class Guaranteed.

  • At least one Container in the Pod has a memory or CPU request.

BestEffort

如果對於全部的resources來說requests與limits均未設置,該pod的QoS即為Best-Effort。

Practice

We use these 3 yaml files to produce 3 types of the QoS:

# Guraranteed
apiVersion: v1
kind: Pod
metadata:
  name: syrus-qos-demo
  namespace: syrusk8s
spec:
  containers:
  - name: qos-demo-ctr
    image: nginx
    resources:
      limits:
        memory: "200Mi"
        cpu: "700m"
      requests:
        memory: "200Mi"
        cpu: "700m"
# Burstable
apiVersion: v1
kind: Pod
metadata:
  name: syrus-qos-demo-2
  namespace: syrusk8s
spec:
  containers:
  - name: qos-demo-ctr-2
    image: nginx
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"
# BestEffort
apiVersion: v1
kind: Pod
metadata:
  name: syrus-qos-demo-3
  namespace: syrusk8s
spec:
  containers:
  - name: qos-demo-ctr-3
    image: nginx

Create pod:

kubectl apply -f qos.yaml --namespace=syrusk8s

View detailed information about the Pod:

kubectl get pod syrus-qos-demo --namespace=syrusk8s --output=yaml

Check the output:

spec:
  containers:
    ...
    name: qos-demo-ctr
    resources:
      requests:
        memory: 200Mi
    ...
  qosClass: Guaranteed/Burstable/BestEffort (depends on what yaml you used)

QoS優先級

3種QoS優先級從有低到高(從左向右): Best-Effort pods -> Burstable pods -> Guaranteed pods

kill order: BestEffort-> Burstable -> Guaranteed

QoS pods被kill掉場景與順序

Best-Effort 類型的pods:系統用完了全部內存時,該類型pods會最先被kill掉。

Burstable類型pods:系統用完了全部內存,且沒有Best-Effort container可以被kill時,該類型pods會被kill掉。

Guaranteed pods:系統用完了全部內存、且沒有Burstable與Best-Effort container可以被kill,該類型的pods會被kill掉。 註:如果pod進程因使用超過預先設定的limites而非Node資源緊張情況,系統傾向於在其原所在的機器上重啟該container或本機或其他重新創建一個pod。

使用建議

如果資源充足,可將QoS pods類型均設置為Guaranteed。用計算資源換業務性能和穩定性,減少排查問題時間和成本。 如果想更好的提高資源利用率,業務服務可以設置為Guaranteed,而其他服務根據重要程度可分別設置為Burstable或Best-Effort,例如filebeat。

PreviousAssign CPU Resources to Containers and PodsNextVolume for Storage

Last updated 6 years ago

Was this helpful?