-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically set or not set resource quota through the cluster #59
Conversation
The requests/limits options were introduced by @arothste-blk in #38 |
I don’t think the CPU limit is necessary. The actual amount of CPU used is very small and it should be compatible with most environments. Most operating systems, especially older operating systems, have cgoup values of 1 instead of 2. |
My clusters require requests and limits for both CPU and memory on every pod whether I like it or not. That was why I added them. Feel free to adjust them as u see fit. Perhaps u can add a mechanism for removing/adding them as required by users so that I can continue to use them and those who don’t won’t.
Drew
…________________________________
From: pycgo ***@***.***>
Sent: Monday, January 8, 2024 5:12:38 AM
To: kvaps/kubectl-node-shell ***@***.***>
Cc: Rothstein, Drew ***@***.***>; Mention ***@***.***>
Subject: Re: [kvaps/kubectl-node-shell] delele cpu limit fix timeout (PR #59)
External Email: Use caution with links and attachments
I don’t think the CPU limit is necessary. The actual amount of CPU used is very small and it should be compatible with most environments. Most operating systems, especially older operating systems, have cgoup values of 1 instead of 2.
If you do not modify this tool, upgrading the system where k8s is located will be a big job.
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https://github.com/kvaps/kubectl-node-shell/pull/59*issuecomment-1880709308__;Iw!!KSjYCgUGsB4!ZtLxiwiNbF534S8wKGUIpuN9w6XbTHDEronuUYrk220KNLItw4kPT2KONt5B9uW8zrGu-lKU9F-ZLLZEGGGVSYx2OA$>, or unsubscribe<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AMWEUSSSQKHWLAH6MP5LNQTYNPBBNAVCNFSM6AAAAABBODA7FWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQG4YDSMZQHA__;!!KSjYCgUGsB4!ZtLxiwiNbF534S8wKGUIpuN9w6XbTHDEronuUYrk220KNLItw4kPT2KONt5B9uW8zrGu-lKU9F-ZLLZEGGGSTSctbA$>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
This message may contain information that is confidential or privileged. If you are not the intended recipient, please advise the sender immediately and delete this message. See http://www.blackrock.com/corporate/compliance/email-disclaimers for further information. Please refer to http://www.blackrock.com/corporate/compliance/privacy-policy for more information about BlackRock’s Privacy Policy.
For a list of BlackRock's office addresses worldwide, see http://www.blackrock.com/corporate/about-us/contacts-locations.
© 2024 BlackRock, Inc. All rights reserved.
|
@arothste-blk is there any way to implement any sort of auto-detection for resources requirements? if kubectl run --image test test --dry-run 2>&1 | grep -q 'resources.requests: Required value' then
container_cpu="100m"
container_memory="256Mi"
fi in your cluster please |
in k8s create this yaml to test it
[root@master ~]# kubectl run --image test test --dry-run
W0110 10:21:43.697889 104817 helpers.go:692] --dry-run is deprecated and can be replaced with --dry-run=client.
pod/test created (dry run)
[root@master ~]# echo $?
0
[root@master ~]# kubectl run --image test test
Error from server (Forbidden): pods "test" is forbidden: failed quota: mem-cpu-example: must specify limits.cpu for: test; limits.memory for: test; requests.cpu for: test; requests.memory for: test
[root@master ~]# echo $?
1
[root@master ~]# |
we can use this to test and It won't really be created, but it can be verified kubectl run test --image test --dry-run=server [root@master ~]# kubectl run test --image test --dry-run=server
Error from server (Forbidden): pods "test" is forbidden: failed quota: mem-cpu-example: must specify limits.cpu for: test; limits.memory for: test; requests.cpu for: test; requests.memory for: test @arothste-blk can you test this in your cluster? |
I think the best option is to: test if resource specification is required
I could implement this by myself, but I have no free time right now. Sorry. If you want this asap, feel free to add this check into your PR :) |
@kvaps I've changed it, take a look. thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job, please apply review suggestions and here we go
kubectl-node_shell
Outdated
@@ -140,6 +140,20 @@ else | |||
fi | |||
fi | |||
|
|||
# test if resource specification is required | |||
set +e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set +e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if do not set this,when grep nothting ,the shell will exit ,can you test it in no limit cluster ?
I can not find other way to fix it.
kubectl-node_shell
Outdated
resources_json='"resources": {}' | ||
|
||
fi | ||
set -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set -e |
Co-authored-by: Andrei Kvapil <[email protected]>
@kvaps I fix it ,and test ok,take a look again.thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I forgot we use set -e
(I confused it with set -x
)
But as I can see, you already found elegant solution!
LGTM
"limits": { "cpu": "'${container_cpu}'", "memory": "'${container_memory}'" }, | ||
"requests": { "cpu": "'${container_cpu}'", "memory": "'${container_memory}'" } | ||
}' | ||
$kubectl run test --image test --dry-run=server 2>&1 | grep 'failed quota' --quiet || resources_json='"resources": {}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very tricky, bravo👏
CRI-O 1.28 no longer supports CGOUP1 for CPU allocation when use centos7, In order to be compatible, we should remove the CPU restrictions in the script.
#53