Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Must specify limits.cpu" error during pod deployment even though cpu limit is specified

I am trying to run a test pod with OpenShift CLI:

$oc run nginx --image=nginx --limits=cpu=2,memory=4Gi
deploymentconfig.apps.openshift.io/nginx created

$oc describe deploymentconfig.apps.openshift.io/nginx
Name:       nginx
Namespace:  myproject
Created:    12 seconds ago
Labels:     run=nginx
Annotations:    <none>
Latest Version: 1
Selector:   run=nginx
Replicas:   1
Triggers:   Config
Strategy:   Rolling
Template:
Pod Template:
  Labels:   run=nginx
  Containers:
   nginx:
    Image:  nginx
    Port:   <none>
    Host Port:  <none>
    Limits:
      cpu:      2
      memory:       4Gi
    Environment:    <none>
    Mounts:     <none>
  Volumes:      <none>

Deployment #1 (latest):
    Name:       nginx-1
    Created:    12 seconds ago
    Status:     New
    Replicas:   0 current / 0 desired
    Selector:   deployment=nginx-1,deploymentconfig=nginx,run=nginx
    Labels:     openshift.io/deployment-config.name=nginx,run=nginx
    Pods Status:    0 Running / 0 Waiting / 0 Succeeded / 0 Failed

Events:
  Type      Reason          Age         From                Message
  ----      ------          ----            ----                -------
  Normal    DeploymentCreated   12s         deploymentconfig-controller Created new replication controller "nginx-1" for version 1
  Warning   FailedCreate        1s (x12 over 12s)   deployer-controller     Error creating deployer pod: pods "nginx-1-deploy" is forbidden: failed quota: quota-svc-myproject: must specify limits.cpu,limits.memory

I get "must specify limits.cpu,limits.memory" error, despite both limits being present in the same describe output.

What might be the problem and how do I fix it?

like image 655
Hohol Avatar asked Sep 18 '25 14:09

Hohol


2 Answers

I found a solution!

Part of the error message was "Error creating deployer pod". It means that the problem is not with my pod, but with the deployer pod which performs my pod deployment. It seems the quota in my project affects deployer pods as well. I couldn't find a way to set deployer pod limits with CLI, so I've made a DeploymentConfig.

kind: "DeploymentConfig"
apiVersion: "v1"
metadata:
  name: "test-app"
spec:
  template: 
    metadata:
      labels:
        name: "test-app"
    spec:
      containers:
        - name: "test-app"
          image: "nginxinc/nginx-unprivileged"
          resources:
            limits:
              cpu: "2000m"
              memory: "20Gi"
          ports:
            - containerPort: 8080
              protocol: "TCP"
  replicas: 1 
  selector:
    name: "test-app"
  triggers:
    - type: "ConfigChange" 
    - type: "ImageChange" 
      imageChangeParams:
        automatic: true
        containerNames:
          - "test-app"
        from:
          kind: "ImageStreamTag"
          name: "nginx-unprivileged:latest"
  strategy: 
    type: "Rolling"
    resources:
      limits:
        cpu: "2000m"
        memory: "20Gi"

A you can see, two sets of limitations are specified here: for container and for deployment strategy.

With this configuration it worked fine!

like image 80
Hohol Avatar answered Sep 20 '25 08:09

Hohol


Looks like you have specified resource quota and the values you specified for limits seems to be larger than that. Can you describe the resource quota oc describe quota quota-svc-myproject and adjust your configs accordingly.

A good reference could be https://docs.openshift.com/container-platform/3.11/dev_guide/compute_resources.html

like image 21
slashpai Avatar answered Sep 20 '25 10:09

slashpai