k8snetworkplumbingwg / network-resources-injector

A Kubernetes Dynamic Admission Controller that patches Pods to add additional information.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

resource injector overwrites user specified resource limit/request

zshi-redhat opened this issue · comments

commented

When a pod spec already has resource limit and request configured for cpu or memory, network-resources-injector will overwrites cpu/memory resources in the pod spec and only add device plugin resourceName in pod resource field.

For example, when creating a pod with below spec file using network-resources-injector:

apiVersion: v1
kind: Pod
metadata:
  name: testpod4
  annotations:
    k8s.v1.cni.cncf.io/networks: sriov-net1
spec:
  containers:
  - name: appcntr4
    image: centos/tools 
    imagePullPolicy: IfNotPresent
    command: [ "/bin/bash", "-c", "--" ]
    args: [ "while true; do sleep 300000; done;" ]
    resources:
      requests:
        cpu: 2
        memory: 100Mi
      limits:
        cpu: 2
        memory: 100Mi

The deployed pod spec will be:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    k8s.v1.cni.cncf.io/networks: sriov-net1
    k8s.v1.cni.cncf.io/networks-status: |-
      [{
          "name": "",
          "ips": [
              "10.96.1.139"
          ],
          "default": true,
          "dns": {}
      },{
          "name": "sriov-network",
          "interface": "net1",
          "ips": [
              "10.56.217.63"
          ],
          "mac": "fa:32:38:0e:b5:94",
          "dns": {}
      }]
  creationTimestamp: "2019-06-18T14:10:41Z"
  name: testpod4
  namespace: default
  resourceVersion: "21891"
  selfLink: /api/v1/namespaces/default/pods/testpod4
  uid: daea75c4-91d2-11e9-8c67-3cfdfeb5188c
spec:
  containers:
  - args:
    - while true; do sleep 300000; done;
    command:
    - /bin/bash
    - -c
    - --
    image: centos/tools
    imagePullPolicy: IfNotPresent
    name: appcntr4
    resources:
      limits:
        intel.com/sriov: "1"
      requests:
        intel.com/sriov: "1"

Hey @zshi-redhat I'll look into this

OK, PR submitted, should work as intended now.

commented

Issue solved with above PR, closing...