-
Notifications
You must be signed in to change notification settings - Fork 38.9k
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
Allow setting an environment variable to some fraction or multiple of a resource field #91514
Comments
/sig apps |
/remove-sig apps |
/sig api-machinery |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/reopen |
@JohnRusk: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@dobesv I think there's an even stronger reason to support this change, now that GOMEMLIMIT is common (i.e. lots of Go Apps are now built on GO 1.19 or later). I left a comment here https://kubernetes.slack.com/archives/C0EG7JC6T/p1682654871448859 about it. Mods: For more info on GOMEMLIMIT and why this change is needed, see the end of this page: https://billglover.me/2022/09/14/use-the-kubernetes-downwards-api-to-set-gomemlimit/ |
/remove-sig api-machinery |
Hi SIG Apps. Lavalamp pointed out a good point, which is that changing the sematics of an existing field may be undesirable, e.g. may make version rollbacks promblematic. Any thoughts on whether this should be solved by adding a new field, maybe |
/reopen |
@dobesv: Reopened this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@k8s-triage-robot: Closing this issue, marking it as "Not Planned". In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/reopen |
@sylr: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Exactly this. We need to be able to do something like this: - name: GOMEMLIMIT
valueFrom:
resourceFieldRef:
resource: limits.memory
divisor: "1100m" |
/reopen How about using CEL to perform the transformation? Or a limited subset of CEL. |
@sftim: Reopened this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/remove-sig apps |
I see most of the conversation here has been about memory, but I would like to ask that all resource fields be available for this kind of tweaking (in case y'all were not already thinking that.) For example, CPU throttling issues with languages that don't really see the container's cpu limit and/or just behave poorly when the limits are set. Being able to set Another use case I can see (although I don't think people should write cloud-native code this way) is apps that log to multiple files inside the container's emphemeral storage; being able to set app log rotation parameters based on available disk without an entrypoint script or external templating logic would probably be greatly appreciated by people working with code that does that. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
If this helps anyone: this is what I did in Helm to work-around the missing native functionality in Kubernetes and use 90% of the memory limit configured in
|
I second the call for generalization of this feature. Isn't there enough templating (gotemplate FTW?) capability that could be leveraged to allow for templating some env variables? This would also align nicely with Helm and what people do about resources there. |
What would you like to be added:
It would be nice to pass a process a number that is a bit lower than the container memory limit so that its garbage collection or memory management can use that limit.
For example:
GOMEMLIMIT
or settingNODEMEMLIMIT
NODE_OPTS=--max-old-space-size=$(NODEMEMLIMIT)
would be useful.JAVA_MEM_LIMIT
and passing-Xmx$(JAVA_MEM_LIMIT)M
Currently you can use
envFrom.resourceFieldRef
to "copy" a resource request or limit to an environment variable, but you can only multiply the value by some power of 1000 or 1024 by specifyingdivisor
.Why is this needed:
This would make it possible to pass a memory limit into a process inside the container that is based on the container resource request or limit but less.
For example, when specifying node's
--max-old-space-size
or Java's-Xmx
parameter, setting it equal to the memory limit of the container will be a problem, because the process actually uses more memory than what you provided as a parameter.Potential Solutions
divisor
like1.5Mi
then it would result in a number of megabytes equal to roughly 2 thirds of the available memory, leaving some extra for the other heaps.scale
ormultiplier
toenfFrom.resourceFieldRef
which is multiplied by the input value to get the env var value$(SOME_VAR)
in the command line, additionally support something like$(SOME_VAR - 100)
--max-old-space-size={{ value * 800 }}M
Workarounds
bash -c 'NODE_OPTIONS=---max-old-space-size=$(($MEMORY_LIMIT-500)) ...
or create your own entrypoint wrapper (maybe a shell script) that calculates the env vars before running the actual commandThe text was updated successfully, but these errors were encountered: