From 4fadc3a22975bab09566c952958c91fd59cd058e Mon Sep 17 00:00:00 2001 From: senique Date: Wed, 15 Apr 2020 11:07:44 +0800 Subject: [PATCH] Update names.md Update to the latest version in EN. https://kubernetes.io/docs/concepts/overview/working-with-objects/names/ --- .../overview/working-with-objects/names.md | 114 ++++++++++++++++-- 1 file changed, 104 insertions(+), 10 deletions(-) diff --git a/content/zh/docs/concepts/overview/working-with-objects/names.md b/content/zh/docs/concepts/overview/working-with-objects/names.md index 1b139eae76..bcf75f4991 100644 --- a/content/zh/docs/concepts/overview/working-with-objects/names.md +++ b/content/zh/docs/concepts/overview/working-with-objects/names.md @@ -1,5 +1,5 @@ --- -title: 名称 +title: 对象名称和IDs content_template: templates/concept weight: 20 --- @@ -7,15 +7,29 @@ weight: 20 {{% capture overview %}} -Kubernetes REST API 中的所有对象都由名称和 UID 明确标识。 +集群中的每一个对象都一个[_名称_](#名称) 来标识在同类资源中的唯一性。 + +每个 Kubernetes 对象也有一个[_UID_](#uids) 来标识在整个集群中的唯一性。 + +比如,在同一个[namespace](/docs/concepts/overview/working-with-objects/namespaces/)中只能命名一个名为 `myapp-1234` 的 Pod, 但是可以命名一个 Pod 和一个 Deployment 同为 `myapp-1234`. 对于非唯一的用户提供的属性,Kubernetes 提供了[标签](/docs/user-guide/labels)和[注释](/docs/concepts/overview/working-with-objects/annotations/)。 @@ -28,7 +42,7 @@ See the [identifiers design doc](https://git.k8s.io/community/contributors/desig {{% capture body %}} ## 名称 @@ -36,16 +50,70 @@ See the [identifiers design doc](https://git.k8s.io/community/contributors/desig {{< glossary_definition term_id="name" length="all" >}} -按照惯例,Kubernetes 资源的名称最大长度应为 253 个字符,由小写字母、数字、`-`和 `.` 组成,但某些资源有更具体的限制。 +以下是比较常见的三种资源命名约束。 -例如,下面是一个配置文件,Pod 名为 `nginx-demo`,容器名为 `nginx`: +### DNS 子域名 + +某些资源类型需要一个 name 来作为一个 DNS 子域名,见定义 [RFC 1123](https://tools.ietf.org/html/rfc1123)。也就是命名必须满足如下规则: + +- 不能超过253个字符 +- 只能包含字母数字,以及'-' 和 '.' +- 须以字母数字开头 +- 须以字母数字结尾 + + + +### DNS 标签名称 + +某些资源类型需要其名称遵循 DNS 标签的标准,见[RFC 1123](https://tools.ietf.org/html/rfc1123)。也就是命名必须满足如下规则: + +- 最多63个字符 +- 只能包含字母数字,以及'-' +- 须以字母数字开头 +- 须以字母数字结尾 + + + +### Path 部分名称 + +一些用与 Path 部分的资源类型要求名称能被安全的 encode。换句话说,其名称不能含有这些字符 "."、".."、"/"或"%"。 + + + +下面是一个名为`nginx-demo`的 Pod 的配置清单: ```yaml apiVersion: v1 @@ -55,13 +123,39 @@ metadata: spec: containers: - name: nginx - image: nginx:1.7.9 + image: nginx:1.14.2 ports: - containerPort: 80 ``` +{{< note >}} + + +某些资源类型可能有其相应的附加命名约束。 + +{{< /note >}} + ## UIDs {{< glossary_definition term_id="uid" length="all" >}} + +Kubernetes UIDs 是通用的唯一标识符 (也叫 UUIDs). +UUIDs 是标准化的,见 ISO/IEC 9834-8 和 ITU-T X.667. + +{{% /capture %}} + +{{% capture whatsnext %}} + +* 阅读关于 Kubernetes [labels](/docs/concepts/overview/working-with-objects/labels/)。 +* 更多参见 [Kubernetes 标识符和名称设计文档](https://git.k8s.io/community/contributors/design-proposals/architecture/identifiers.md). + {{% /capture %}}