默认情况下在kubernetes中创建了哪些环境变量 [英] What environment variables are created in kubernetes by default

查看:224
本文介绍了默认情况下在kubernetes中创建了哪些环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在k8s文档中找不到这个,我只是想知道k8s在每个容器中创建的默认环境变量是什么.不是用户创建的默认值,而是类似(这只是一个示例),例如{service_name}_PORT之类的东西.我只想知道默认情况下容器中可用的信息.

I can't find this in the k8s documentation, I'm just wondering what are the default environment variables that are created in every container by k8s. Not user created defaults, but like (and this is just an example) maybe something like {service_name}_PORT or something like that. I just wanna know what information is available in a container by default.

推荐答案

来自K8S文档;

容器信息-ENV的

容器的主机名是容器在其中运行的Pod的名称.可通过hostname命令或libc中的gethostname函数调用来使用它.

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.

Pod名称和名称空间可用作环境变量.

The Pod name and namespace are available as environment variables.

这些是我正在运行的MiniKube集群中的其他ENV:

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

HOSTNAME=something-api-234234234-skm70
SHLVL=1
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_HOST=x.x.x.x
PWD=/

Pod定义中的用户定义环境变量以及Docker映像中静态指定的任何环境变量也可用于容器.

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.

集群信息-ENV的

创建容器时正在运行的所有服务的列表可供该容器用作环境变量.这些环境变量与Docker链接的语法匹配.

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.

对于映射到名为bar的容器端口的名为foo的服务,定义了以下变量:

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>

参考: https://kubernetes.io/docs/concepts/容器/容器环境变量/

这篇关于默认情况下在kubernetes中创建了哪些环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆