Add possibility to add resource request/limit to initContainer - #121
Open
moandersson wants to merge 1 commit into
Open
Add possibility to add resource request/limit to initContainer#121moandersson wants to merge 1 commit into
moandersson wants to merge 1 commit into
Conversation
chenbh
suggested changes
Jan 9, 2025
chenbh
left a comment
Contributor
There was a problem hiding this comment.
Can you also add some tests?
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/pkg/errors" |
Contributor
There was a problem hiding this comment.
Missing import for resource.MustParse()
| if resources.Requests == nil { | ||
| resources.Requests = corev1.ResourceList{} | ||
| } | ||
| resources.Requests[corev1.ResourceCPU] = resource.MustParse(cpuRequest) |
Contributor
There was a problem hiding this comment.
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.
Author
There was a problem hiding this comment.
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 <mattis@mattis.nu>
moandersson
force-pushed
the
feature/add_resource_to_initcontainer
branch
from
January 30, 2025 23:16
08fc149 to
290c27e
Compare
Author
I've added some tests. Let me know if anything is missing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.