-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add possibility to add resource request/limit to initContainer #121
base: main
Are you sure you want to change the base?
Add possibility to add resource request/limit to initContainer #121
Conversation
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.
Can you also add some tests?
@@ -8,6 +8,7 @@ import ( | |||
"context" | |||
"encoding/json" | |||
"fmt" | |||
"os" | |||
|
|||
"github.com/pkg/errors" |
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.
Missing import for resource.MustParse()
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.
Removed MustParse()
if resources.Requests == nil { | ||
resources.Requests = corev1.ResourceList{} | ||
} | ||
resources.Requests[corev1.ResourceCPU] = resource.MustParse(cpuRequest) |
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.
MustParse
will cause the controller to panic if the env var is misconfigured, we should use the form that returns an error and handle that instead.
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.
I've created a helper function to parse the envvar and handle the exception if it fails. However, I am not sure how we should handle the exception, currently it will just print a warning message, but maybe we would like to not configure the resources if any of the inputs are misconfigured?
This commit enables user to configure resource request and limit for cpu and memory on the "setup-ca-certs" initContainer. By not being able to set resources it blocks creation of the Pod if a namespace has a ResourceQuota in place. Signed-off-by: Mattias Andersson <[email protected]>
08fc149
to
290c27e
Compare
I've added some tests. Let me know if anything is missing |
This commit enables user to configure resource request and limit for cpu and memory on the "setup-ca-certs" initContainer.
By not being able to set resources it blocks creation of the Pod if a namespace has a ResourceQuota in place.