Home > Mobile >  How to unset limit of pods to Unlimited in Kubernetes Yaml fle?
How to unset limit of pods to Unlimited in Kubernetes Yaml fle?

Time:09-17

At first, I set limit range for namespace kube-system as below:

apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-limit-range
  namespace: kube-system
spec:
  limits:
  - default:
      cpu: 500m
      memory: 500Mi
    defaultRequest:
      cpu: 100m
      memory: 100Mi
    type: Container

However, later found that there is insufficient CPU and Memory to start up my pod as limits are > 100% from namespace kube-system already.

How can I reset reasonable limits for pods in kube-system. It is better to set their limits to unlimitted but I don't know how to set it.


Supplement information for namespace kube-system:

enter image description here

CodePudding user response:

Not sure if your kube-system namespace has a limit set. You can confirm it checking the namespace itself:

kubectl describe namespace kube-system

If you have a limit range or a resource quota set, it will appear in the description. Something like the following:

Name:         default-cpu-example
Labels:       <none>
Annotations:  <none>
Status:       Active

No resource quota.

Resource Limits
 Type       Resource  Min  Max  Default Request  Default Limit  Max Limit/Request Ratio
 ----       --------  ---  ---  ---------------  -------------  -----------------------
 Container  cpu       -    -    500m             1              -

In this case I have set resource limits for my namespace.

Now I can list all the ResourceQuotas and LimitRanges using:

kubectl get resourcequotas -n kube-system
kubectl get limitranges -n kube-system

If somethings returns, from those you can simply remove it:

kubectl delete resourcequotas NAME_OF_YOUR_RESOURCE_QUOTA -n kube-system
kubectl delete limitranges NAME_OF_YOUR_LIMIT_RANGE -n kube-system

I'm still not sure if that's your true problem, but that answers your question.

You can find more info here:

https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/

  • Related