Pod之Qos
Qos全称Quoality of service ,中文名称为服务质量。在kubernetes中每个pod都有一个qos标记,通过这个标记来对pod进行服务质量管理。对于pod来说qos服务质量体现在两个指标上cpu和memory。当服务器资源紧张时kubernetes通过不同pod的不同qos标记来采取不同的策略
三种策略
- Guaranteed
对于kubernetes来说这个策略是最高级别的当出现集群内部资源紧张时优先供给有这个qos的pod,对应pod来说想要有这个qos要保证内存.cpu请求或限制相等
- Burstable
对于kubernetes来说这个是此等级别低于Guarnteed,当集群内资源紧张且内部pod的qos没有burstable时,保证其存活(只给其最小资源)。对于pod来说想要有这个qos要保证其容器至少要有一个资源限制同时要有最大和最小,资源限制不能一致
- BestEffort
对于kubernetes来说这个是最低级别的qos,当集群资源紧张时第一个先杀掉这个pod
怎么写?
同一使用nginx:latest镜像
Guaranteed
apiVersion: v1
kind: Pod
metadata:
name: nginx1
spec:
containers:
- name: nginx
image: nginx:latest
resources:
limits:
memory: 1024Mi
cpu: 500m
requests:
memory: 1024Mi
cpu: 500m
检测
[root@k8s-master-node1 ~]# kubectl describe pod nginx1 | grep QoS
QoS Class: Guaranteed
Burstable
apiVersion: v1
kind: Pod
metadata:
name: nginx2
spec:
containers:
- name: nginx
image: nginx:latest
resources:
limits:
memory: 1024Mi
requests:
memory: 512Mi
检测
[root@k8s-master-node1 ~]# kubectl describe pod nginx2 | grep QoS
QoS Class: Burstable
BestEffort
apiVersion: v1
kind: Pod
metadata:
name: nginx3
spec:
containers:
- name: nginx
image: nginx:latest
检测
[root@k8s-master-node1 ~]# kubectl describe pod nginx3 | grep QoS
QoS Class: BestEffort

浙公网安备 33010602011771号