feat(argo-cd): support tpl in env var values#3842
Conversation
ab89b38 to
6944ca4
Compare
|
Why you don't use resource field refs? server:
env:
- name: GOMEMLIMIT
valueFrom:
resourceFieldRef:
resource: limits.memory
divisor: "1"In my opinion this would be the exact use case for this: $ kubectl explain pod.spec.containers.env.valueFrom.resourceFieldRef
KIND: Pod
VERSION: v1
FIELD: resourceFieldRef <ResourceFieldSelector>
DESCRIPTION:
Selects a resource of the container: only resources limits and requests
(limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu,
requests.memory and requests.ephemeral-storage) are currently supported.
ResourceFieldSelector represents container resources (cpu, memory) and their
output format
FIELDS:
containerName <string>
Container name: required for volumes, optional for env vars
divisor <Quantity>
Specifies the output format of the exposed resources, defaults to "1"
resource <string> -required-
Required: resource to select |
|
Thanks for the suggestion — I looked into The goal of setting So That leaves either hardcoding (drift-prone but explicit) or an entrypoint script that reads the cgroup limit and computes 90% — which is exactly the kind of thing chart-level templating with |
mkilchhofer
left a comment
There was a problem hiding this comment.
@DrFaust92 Perfect answer, thanks for these details! I now also found this issue over there:
Looks like you already made the right proposal for what is possible today.
Signed-off-by: Ilia <ilia.lazebnik@placer.ai>
77338c6 to
64199d1
Compare
|
Hi @mkilchhofer — just rebased onto current Would you be willing to merge this when you have a moment? Happy to address anything further if you'd like more changes — otherwise I'd love to stop chasing the rebase treadmill. Thanks again for the thoughtful review on the |
Signed-off-by: Ilia Lazebnik <Ilia.lazebnik@gmail.com>
Checklist:
Summary
Switch env var rendering in all component deployments/statefulsets from
toYamltotpl (toYaml .) $, enabling Helm template expressions insideenv[].valuefields.This is a backwards-compatible change — plain string values continue to work as before.
Note: when using template expressions, reference root-level values with
$.Values.x(not.Values.x) since the dot context inside the env list is the list element.Example use case — auto-setting
GOMEMLIMITfrom the container memory limit in a parent chart/values overlay: