pod.containers.spec.resources不起作用(限制和请求)Kubernetes

时间:2018-06-20 09:38:41

标签: kubernetes resources kubeadm

我正在尝试在我的Pod的定义中使用资源限制和请求,但这就像调度程序不想应用我的规范一样:

    kind: Pod
    apiVersion: v1
    metadata:
      name: pod-lab5
      namespace: limit-namespace
      labels:
        app: stress
    spec:
      containers:
        - name: resources-limit
          image: dkuffner/docker-stress
          command: ["stress"]
          args: ["--vm", "1", "--vm-bytes", "50M", "--vm-hang", "1"]
          resources:
            requests:
              memory: "60Mi"
              cpu: "70m"
            limits:
              memory: "65Mi"
              cpu: "75m"
            requests:
              ephemeral-storage: "2Gi"
            limits:
              ephemeral-storage: "4Gi"

enter image description here enter image description here 当我使用极限范围时,它采用默认的规格:

apiVersion: v1
kind: LimitRange
metadata:
  name: mylimits
  namespace: limit-namespace
spec:
  limits:
  - max:
      cpu: 100m
      memory: 100Mi
    min:
      cpu: 40m
      memory: 20Mi
    type: Pod
  - default:
      cpu: 80m
      memory: 70Mi
    defaultRequest:
      cpu: 60m
      memory: 50Mi
    max:
      cpu: 100m
      memory: 100Mi
    min:
      cpu: 40m
      memory: 20Mi
    type: Container

enter image description here

enter image description here

有人可以帮助我吗?谢谢:)

1 个答案:

答案 0 :(得分:2)

我认为这只是参数重复的问题。

  resources:
    requests:
      memory: "60Mi"
      cpu: "70m"
    limits:
      memory: "65Mi"
      cpu: "75m"
    requests:
      ephemeral-storage: "2Gi"
    limits:
      ephemeral-storage: "4Gi"

进行如下修改,然后再次测试。

  resources:
    requests:
      memory: "60Mi"
      cpu: "70m"
      ephemeral-storage: "2Gi"
    limits:
      memory: "65Mi"
      cpu: "75m"
      ephemeral-storage: "4Gi"