Hi all,
I’m a kubernetes newbie. So, say, we have a cluster created already with several namespaces and resources such as CPU and Memory assigned, thus,
we have something like “mycluster”, “myNameSpace1”, “myNameSpace2” etc.
“myNameSpace1” has 2 CPU limit and 300 MiB Memory limit.
Now, I need to double the CPU limit and Memory limit for “myNameSpace1”,
probably we can edit the yaml file and then use { kubectl apply -f myYaml.yml } to make it happen. But, if we can do something like { kubectl increase -n myNameSpace1 CPU-limit=4 Memory-limit=600MiB } how more convenient it would be ! Doable?
Thanks.
You might not be able to do that directly, however there is easier way to do it without yaml file.
You could use kubectl edit command to do that.
# current quota set on mynamespace1
$ kubectl describe quota --namespace=mynamespace1
Name: myquota
Namespace: mynamespace1
Resource Used Hard
limits.cpu 0 2
limits.memory 0 2Gi
requests.cpu 0 1
requests.memory 0 1Gi
$
# command to edit/increase the quota, just save the changes and exit
$ kubectl edit quota myquota -n mynamespace1
apiVersion: v1
kind: ResourceQuota
metadata:
creationTimestamp: “2021-06-12T23:43:31Z”
name: myquota
namespace: mynamespace1
resourceVersion: “668617”
uid: 9a2ad119-ea47-48bc-96a7-6960485da47e
spec:
hard:
limits.cpu: “3”
limits.memory: 3Gi
requests.cpu: “1”
requests.memory: 1Gi
status:
hard:
limits.cpu: "3"
limits.memory: 3Gi
requests.cpu: “1”
requests.memory: 1Gi
used:
limits.cpu: “0”
limits.memory: “0”
requests.cpu: “0”
requests.memory: “0”
resourcequota/myquota edited
$
# confirm quota increased
$ kubectl describe quota --namespace=mynamespace1
Name: myquota
Namespace: mynamespace1
Resource Used Hard
limits.cpu 0 3
limits.memory 0 3Gi
requests.cpu 0 1
requests.memory 0 1Gi
$
1 Like
Beautiful. Thank you very much.