Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-73548

Kubernetes plugin cannot send requests and limits

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Blocker Blocker
    • kubernetes-plugin
    • None
    • Jenkins version - 2.452.3
      Kubernetes plugin version - 4265.v78b_d4a_1c864a_

      Hello,

      In my cluster, there is a limitation on the requests and limits for the pod. I have to set it to 0 in order for the Kube-API to accept it.

       

      When I specify it in the UI, under Clouds > my-cloud > Pod Templates > my_template > Advanced > Limit CPU and Limit Memory. It gives below error in the controller - 

       

      WARNING o.c.j.p.k.KubernetesLauncher#launch: Error in provisioning; agent=KubernetesSlave name: <SOME_NAME>, template=<TEMPLATE>
      io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: <API_ENDPOINT>. Message: pods "<JENKINS_POD>" is forbidden: failed quota: <QUOTA_NAME>: must specify limits.cpu,limits.memory. Received status: Status(apiVersion=v1, code=403, details=StatusDetails(causes=[], group=null, kind=pods, name=<SOME_NAME>, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=pods "<SOME_NAME>" is forbidden: failed quota: <QUOTA_NAME>: must specify limits.cpu,limits.memory, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Forbidden, status=Failure, additionalProperties={}).

       

      I did try to add the below YAML in override mode but it still does not work -

       

       

      When I call the API directly, using the same YAML, it runs perfectly fine. It is not an authentication error, it looks like the plugin is sending incorrect values for resource limit and request.

       

      If it helps, below is the quota specified on the cluster -

       

       

      Edit: I also tried running it via pipeline in both override() and merge() modes, the issue still remains. Below is my pipeline -

      podTemplate(
        cloud: 'MY_CLOUD',
        namespace: 'oneoffer-k8s-poc',
        name: 'jenkins-agent-pod',
        label: 'jenkins-agent-pod',
        showRawYaml: true,
        yamlMergeStrategy: override(),
        podRetention: always(),
        containers: [
          containerTemplate(name: 'jenkins-agent', image: '<IMAGE_PATH>', ttyEnabled: true, workingDir: '/root', resourceRequestMemory: '0', resourceRequestCpu: '0',  resourceLimitMemory: '0', resourceLimitCpu: '0' )
        ],
        {
          node('jenkins-agent-pod') {
            stage('Build') {
              container('jenkins-agent') {
                echo "Hello from the container"
              }
            }
          }
      })

            Unassigned Unassigned
            foxtrot123 Foxtrot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: