From 3be4bb5aa3175a910f74e2ef515c00c870ed787b Mon Sep 17 00:00:00 2001 From: bryan Date: Tue, 28 Apr 2020 20:20:24 +0800 Subject: [PATCH] translate Container Environment into chinese Fix some text errors resolve conversation resolve conversation --- .../containers/container-environment.md | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 content/zh/docs/concepts/containers/container-environment.md diff --git a/content/zh/docs/concepts/containers/container-environment.md b/content/zh/docs/concepts/containers/container-environment.md new file mode 100644 index 0000000000..26d599f9fd --- /dev/null +++ b/content/zh/docs/concepts/containers/container-environment.md @@ -0,0 +1,96 @@ +--- +title: 容器环境 +content_template: templates/concept +weight: 20 +--- + +{{% capture overview %}} + + +本页描述了在容器环境里容器可用的资源。 + +{{% /capture %}} + + +{{% capture body %}} + + +## 容器环境 + +Kubernetes 的容器环境给容器提供了几个重要的资源: + +* 文件系统,其中包含一个[镜像](/docs/concepts/containers/images/) 和一个或多个的[卷](/docs/concepts/storage/volumes/)。 +* 容器自身的信息。 +* 集群中其他对象的信息。 + + +### 容器信息 + +容器的 *hostname* 是它所运行在的 pod 的名称。它可以通过 `hostname` 命令或者调用 libc 中的 [`gethostname`](http://man7.org/linux/man-pages/man2/gethostname.2.html) 函数来获取。 + +Pod 名称和命名空间可以通过 [downward API](/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/) 使用环境变量。 + +Pod 定义中的用户所定义的环境变量也可在容器中使用,就像在 Docker 镜像中静态指定的任何环境变量一样。 + + +### 集群信息 + +创建容器时正在运行的所有服务的列表都可用作该容器的环境变量。这些环境变量与 Docker 链接的语法匹配。 + +对于名为 *foo* 的服务,当映射到名为 *bar* 的容器时,以下变量是被定义了的: + +```shell +FOO_SERVICE_HOST= +FOO_SERVICE_PORT= +``` + + +Service 具有专用的 IP 地址。如果启用了 [DNS插件](http://releases.k8s.io/{{< param "githubbranch" >}}/cluster/addons/dns/),就可以在容器中通过 DNS 来访问。 + +{{% /capture %}} + +{{% capture whatsnext %}} + + +* 学习更多有关[容器生命周期钩子](/docs/concepts/containers/container-lifecycle-hooks/)的知识。 +* 动手获得经验[将处理程序附加到容器生命周期事件](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/)。 + +{{% /capture %}}