kubernetes - k8 pod优先级和测试

标签 kubernetes eks

这些是我的优先类(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/

相关文章:

docker - 使用 Helm 安装时, “poddisruptionbudgets.policy ” zk-pdb“已经存在”是什么意思?

docker - 如何获得Kubernetes yaml中所有图像的解析sha摘要?

azure - 无法使用 Azure Devops 在 Kubernetes 上运行 VSTS 代理

amazon-web-services - eks集群-添加工作程序节点-应用configmap如何使我的节点对k8s集群可见?

kubernetes - kubectl上下文与集群

amazon-web-services - 发生节点故障时Kubernetes Container应用程序进程恢复

nginx - 无法配置Kubernetes Nginx入口基本身份验证

kubernetes - 普罗米修斯+赫普斯特

kubernetes - Kubernetes创建 secret 并在创建 namespace 时更改默认服务帐户

kubernetes - EKS负载平衡器上的SSL(ACM)