What environment variables are created in kubernetes by default What environment variables are created in kubernetes by default kubernetes kubernetes

What environment variables are created in kubernetes by default


From the K8S Documentation;

Container information - ENV's

The hostname of a Container is the name of the Pod in which the Container is running. It is available through the hostname command or the gethostname function call in libc.

The Pod name and namespace are available as environment variables.

These are the additional ENV's in a MiniKube cluster I have running:

HOSTNAME=something-api-234234234-skm70SHLVL=1HOME=/rootPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binKUBERNETES_SERVICE_PORT_HTTPS=443KUBERNETES_SERVICE_HOST=x.x.x.xPWD=/

User defined environment variables from the Pod definition are also available to the Container, as are any environment variables specified statically in the Docker image.

Cluster Information - ENV's

A list of all services that were running when a Container was created is available to that Container as environment variables. Those environment variables match the syntax of Docker links.

For a service named foo that maps to a container port named bar, the following variables are defined:

FOO_SERVICE_HOST=<the host the service is running on>FOO_SERVICE_PORT=<the port the service is running on>

Ref: https://kubernetes.io/docs/concepts/containers/container-environment/