valueFromresourceFieldRef
valueFromresourceFieldRef is a feature in Kubernetes Pod specifications that allows an environment variable to be populated from a resource field reference. It is used within a container’s environment variable definition, under valueFrom and resourceFieldRef, to expose resource-related values of a container in the same pod.
- containerName (optional): the name of the target container in the pod whose resources are being referenced.
- resource (required): the specific resource field to reference. Typical values include requests.cpu, limits.cpu, requests.memory, limits.memory, requests.ephemeral-storage,
The referenced resource value is injected as a string into the environment variable at runtime. CPU values
- An environment variable that captures the CPU limit for a container named web:
- An environment variable that captures memory requests for the current container:
valueFromresourceFieldRef is a form of the Pod’s Downward API that enables dynamic configuration based on container