Concept-Kubernetes container environment

This section describes the resources available to the container in the container environment.

Container environment

The Kubernetes container environment provides some important resources for containers:

  • The file system, which is a combination of mirror (please look forward to ~~) and one or more volumes (please look forward to ~~)
  • Information about the container itself;
  • Information about other objects in the cluster.

Container information

The host name of the container is the name of the Pod in which the container runs. It can hostnamecommand or in libc gethostname calls to get the function.

Pod name and namespace can be used as environment variables through the downward API (please look forward to ~~).

The container can also use the user-defined environment variables in the Pod definition and any environment variables statically specified in the Docker image.

Cluster information

The list of all services that were running when the container was created can be used by the container as an environment variable. These environment variables match the syntax of the Docker link.

For the foo service mapped to the container 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>

If the DNS add- on is enabled , the service has a dedicated IP address and can be made available to the container through DNS.

What to do next

Published 232 original articles · Liked 14 · Visits 20,000+

Guess you like

Origin blog.csdn.net/stevenchen1989/article/details/105615952