-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
helm: set GOMEMLIMIT via k8s downward API #27958
Merged
nathanjsweet
merged 1 commit into
cilium:main
from
bimmlerd:pr/bimmlerd/set-go-memlimit
Sep 13, 2023
Merged
helm: set GOMEMLIMIT via k8s downward API #27958
nathanjsweet
merged 1 commit into
cilium:main
from
bimmlerd:pr/bimmlerd/set-go-memlimit
Sep 13, 2023
Conversation
This file contains 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
The rationale for setting GOMEMLIMIT is to give the Go Garbage Collector (GC) more information about the potentially constrained environment it is running in. Without setting GOMEMLIMIT, scenarios can occur where the GC may consider it beneficial to _not_ run, when in fact the pod is about to be OOM-killed. This occurs since the GC doesn't understand container resource limits, and hence may let garbage balloon over the limit, since it continually must make a trade-off between the CPU overhead and the memory usage. GOMEMLIMIT is a soft limit for the Go GC. It instructs the GC that it should try to keep the total memory usage of the Go runtime below said limit. You can learn more about it at https://pkg.go.dev/runtime, or specifically at https://pkg.go.dev/runtime/debug#SetMemoryLimit. The K8s downward API allows setting environment variables based on values of the container specification, such as the memory limit in this case. If the limit isn't set, it will fall back to a sensible value, see https://kubernetes.io/docs/concepts/workloads/pods/downward-api/#fallback-information-for-resource-limits. Signed-off-by: David Bimmler <david.bimmler@isovalent.com>
bimmlerd
added
kind/enhancement
This would improve or streamline existing functionality.
sig/k8s
Impacts the kubernetes API, or kubernetes -> cilium internals translation layers.
release-note/minor
This PR changes functionality that users may find relevant to operating Cilium.
area/helm
Impacts helm charts and user deployment experience
sig/agent
Cilium agent related.
labels
Sep 6, 2023
/test CI triage:
|
gandro
approved these changes
Sep 6, 2023
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.
Looks straight forward enough!
/ci-e2e |
This comment was marked as resolved.
This comment was marked as resolved.
nathanjsweet
approved these changes
Sep 13, 2023
maintainer-s-little-helper
bot
added
the
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
label
Sep 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/helm
Impacts helm charts and user deployment experience
kind/enhancement
This would improve or streamline existing functionality.
kind/performance
There is a performance impact of this.
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
release-note/minor
This PR changes functionality that users may find relevant to operating Cilium.
sig/agent
Cilium agent related.
sig/k8s
Impacts the kubernetes API, or kubernetes -> cilium internals translation layers.
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.
The rationale for setting GOMEMLIMIT is to give the Go Garbage Collector (GC) more information about the potentially constrained environment it is running in. Without setting GOMEMLIMIT, scenarios can occur where the GC may consider it beneficial to not run, when in fact the pod is about to be OOM-killed. This occurs since the GC doesn't understand container resource limits, and hence may let garbage balloon over the limit, since it continually must make a trade-off between the CPU overhead and the memory usage.
GOMEMLIMIT is a soft limit for the Go GC. It instructs the GC that it should try to keep the total memory usage of the Go runtime below said limit. You can learn more about it at https://pkg.go.dev/runtime, or specifically at https://pkg.go.dev/runtime/debug#SetMemoryLimit.
The K8s downward API allows setting environment variables based on values of the container specification, such as the memory limit in this case. If the limit isn't set, it will fall back to a sensible value, see https://kubernetes.io/docs/concepts/workloads/pods/downward-api/#fallback-information-for-resource-limits.