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:
Create pod:
View detailed information about the Pod:
Check the output:
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。
Last updated
Was this helpful?