这些是我的优先类(class)
NAME VALUE GLOBAL-DEFAULT AGE
k8-monitoring 1000000 false 4d7h
k8-system 500000 false 4d7h
k8-user 1000 false 4d7h
我正在尝试对命名空间pod配额的限制内的优先级进行测试,如果方法正确,是否可以确认我。如果没有,请指导我。apiVersion: v1
kind: Namespace
metadata:
name: priority-test
---
apiVersion: v1
kind: ResourceQuota
metadata:
name: priority-pod-quota
namespace: priority-test
spec:
hard:
pods: "5"
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: user-priority
namespace: priority-test
labels:
tier: x3
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: x3
template:
metadata:
labels:
tier: x3
spec:
priorityClassName: k8-user
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: system-priority
namespace: priority-test
labels:
tier: x2
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: x2
template:
metadata:
labels:
tier: x2
spec:
priorityClassName: k8-system
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: monitoring-priority
namespace: priority-test
labels:
tier: x1
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: x1
template:
metadata:
labels:
tier: x1
spec:
priorityClassName: monitoring-priority
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
我正在EKS v.1.15中运行此测试,但没有获得按设计说明的优先级。告诉我是否需要另一只眼睛看不应该看到这个,应该运行高优先级
NAME DESIRED CURRENT READY AGE
monitoring-priority 3 0 0 17m
system-priority 3 2 2 17m
user-priority 3 3 3 17m
我还阅读了Dawid Kruk K8s pod priority & outOfPods提供的出色解决方案
最佳答案
您已将5个 pods 的ResourceQuota
定义为hard
要求。此ResourceQuota
应用于所有Pod的命名空间级别,无论其优先级级别如何。这就是为什么您在current
中看到3个Pod作为user-priority
和在current
中看到2个Pod在system-priority
中的原因。由于ResourceQuota
中定义的5个 pods 的限制,其余的 pods 无法运行。如果检查kubectl get events
,应该会看到与资源配额有关的403 FORBIDDEN
错误。ResourceQuota
是一个准入 Controller ,当达到配额时(现在正在发生这种情况),它不会让pod完全进入调度队列。因此,您需要增加ResourceQuota配额才能进行Pod优先级和抢占的测试。
测试Pod优先级和抢占的正确方法是部署足够的Pod,以达到节点的资源容量,并验证是否将低优先级Pod赶出了调度高优先级Pod。
关于kubernetes - k8 pod优先级和测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63460576/