Home

ResourceFieldRef

ResourceFieldRef is a component of the Kubernetes Downward API that enables a container to expose its resource values, such as CPU and memory requests or limits, to the Pod at runtime. It allows these resource quantities to be injected into environment variables or consumed by downward API projections, facilitating dynamic configuration based on the container’s defined resources.

Usage and structure: ResourceFieldRef is used in the Pod specification where a container defines environment variables

Supported resources and behavior: The resource field generally supports the standard container resource names such as

Limitations and notes: ResourceFieldRef is part of the downward API and is primarily intended for configuration

See also: Downward API, FieldRef, Resource requirements.

with
a
valueFrom/resourceFieldRef
reference.
The
relevant
fields
typically
include
an
optional
containerName
(when
referencing
resources
from
another
container
in
the
same
Pod),
resource
(for
example,
requests.cpu,
limits.memory,
etc.),
and
an
optional
divisor
to
scale
the
returned
value.
The
value
produced
is
a
string
representing
the
specified
resource
quantity,
possibly
adjusted
by
the
divisor.
In
practice,
common
usage
is
to
expose
a
container’s
CPU
or
memory
requests
or
limits
as
an
environment
variable.
requests.cpu,
limits.cpu,
requests.memory,
and
limits.memory.
The
divisor
is
an
optional
scaling
factor
that
can
alter
the
unit
or
magnitude
of
the
reported
value.
The
value
reflects
the
resource
specification
defined
in
the
Pod
(not
the
container’s
runtime
usage)
and
remains
static
for
the
life
of
the
Pod
unless
the
Pod
spec
is
changed.
and
instrumentation,
not
real-time
usage
tracking.
It
is
commonly
used
to
adapt
application
behavior
to
the
resources
allocated
to
the
container.