Skip to content

Commit b779712

Browse files
authored
Merge pull request #20345 from senique/patch-2
Update names.md
2 parents 3906a09 + 4fadc3a commit b779712

File tree

1 file changed

+104
-10
lines changed
  • content/zh/docs/concepts/overview/working-with-objects

1 file changed

+104
-10
lines changed
Lines changed: 104 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
---
2-
title: 名称
2+
title: 对象名称和IDs
33
content_template: templates/concept
44
weight: 20
55
---
66

77
{{% capture overview %}}
88

99
<!--
10-
All objects in the Kubernetes REST API are unambiguously identified by a Name and a UID.
10+
Each object in your cluster has a [_Name_](#names) that is unique for that type of resource.
11+
Every Kubernetes object also has a [_UID_](#uids) that is unique across your whole cluster.
12+
13+
For example, you can only have one Pod named `myapp-1234` within the same [namespace](/docs/concepts/overview/working-with-objects/namespaces/), but you can have one Pod and one Deployment that are each named `myapp-1234`.
1114
-->
1215

13-
Kubernetes REST API 中的所有对象都由名称和 UID 明确标识。
16+
集群中的每一个对象都一个[_名称_](#名称) 来标识在同类资源中的唯一性。
17+
18+
每个 Kubernetes 对象也有一个[_UID_](#uids) 来标识在整个集群中的唯一性。
19+
20+
比如,在同一个[namespace](/docs/concepts/overview/working-with-objects/namespaces/)中只能命名一个名为 `myapp-1234` 的 Pod, 但是可以命名一个 Pod 和一个 Deployment 同为 `myapp-1234`.
1421

1522
<!--
1623
For non-unique user-provided attributes, Kubernetes provides [labels](/docs/user-guide/labels) and [annotations](/docs/concepts/overview/working-with-objects/annotations/).
1724
18-
See the [identifiers design doc](https://git.k8s.io/community/contributors/design-proposals/architecture/identifiers.md) for the precise syntax rules for Names and UIDs.
25+
See the [identifiers design doc](https://git.k8s.io/community/contributors/design-proposals/architecture/identifiers.md) for the precise syntax rules for Names and
26+
27+
28+
29+
30+
31+
32+
.
1933
-->
2034

2135
对于非唯一的用户提供的属性,Kubernetes 提供了[标签](/docs/user-guide/labels)[注释](/docs/concepts/overview/working-with-objects/annotations/)
@@ -28,24 +42,78 @@ See the [identifiers design doc](https://git.k8s.io/community/contributors/desig
2842
{{% capture body %}}
2943

3044
<!--
31-
## Names1
45+
## Names
3246
-->
3347

3448
## 名称
3549

3650
{{< glossary_definition term_id="name" length="all" >}}
3751

3852
<!--
39-
By convention, the names of Kubernetes resources should be up to maximum length of 253 characters and consist of lower case alphanumeric characters, `-`, and `.`, but certain resources have more specific restrictions.
53+
Below are three types of commonly used name constraints for resources.
54+
-->
55+
56+
以下是比较常见的三种资源命名约束。
57+
58+
<!--
59+
### DNS Subdomain Names
60+
61+
Most resource types require a name that can be used as a DNS subdomain name
62+
as defined in [RFC 1123](https://tools.ietf.org/html/rfc1123).
63+
This means the name must:
64+
65+
- contain no more than 253 characters
66+
- contain only lowercase alphanumeric characters, '-' or '.'
67+
- start with an alphanumeric character
68+
- end with an alphanumeric character
4069
-->
4170

42-
按照惯例,Kubernetes 资源的名称最大长度应为 253 个字符,由小写字母、数字、`-``.` 组成,但某些资源有更具体的限制。
71+
### DNS 子域名
72+
73+
某些资源类型需要一个 name 来作为一个 DNS 子域名,见定义 [RFC 1123](https://tools.ietf.org/html/rfc1123)。也就是命名必须满足如下规则:
74+
75+
- 不能超过253个字符
76+
- 只能包含字母数字,以及'-' 和 '.'
77+
- 须以字母数字开头
78+
- 须以字母数字结尾
4379

4480
<!--
45-
For example, here’s the configuration file with a Pod name as `nginx-demo` and a Container name as `nginx`:
81+
### DNS Label Names
82+
83+
Some resource types require their names to follow the DNS
84+
label standard as defined in [RFC 1123](https://tools.ietf.org/html/rfc1123).
85+
This means the name must:
86+
87+
- contain at most 63 characters
88+
- contain only lowercase alphanumeric characters or '-'
89+
- start with an alphanumeric character
90+
- end with an alphanumeric character
4691
-->
4792

48-
例如,下面是一个配置文件,Pod 名为 `nginx-demo`,容器名为 `nginx`
93+
### DNS 标签名称
94+
95+
某些资源类型需要其名称遵循 DNS 标签的标准,见[RFC 1123](https://tools.ietf.org/html/rfc1123)。也就是命名必须满足如下规则:
96+
97+
- 最多63个字符
98+
- 只能包含字母数字,以及'-'
99+
- 须以字母数字开头
100+
- 须以字母数字结尾
101+
102+
<!--
103+
Some resource types require their names to be able to be safely encoded as a
104+
path segment. In other words, the name may not be "." or ".." and the name may
105+
not contain "/" or "%".
106+
-->
107+
108+
### Path 部分名称
109+
110+
一些用与 Path 部分的资源类型要求名称能被安全的 encode。换句话说,其名称不能含有这些字符 "."、".."、"/"或"%"。
111+
112+
<!--
113+
Here’s an example manifest for a Pod named `nginx-demo`.
114+
-->
115+
116+
下面是一个名为`nginx-demo`的 Pod 的配置清单:
49117

50118
```yaml
51119
apiVersion: v1
@@ -55,13 +123,39 @@ metadata:
55123
spec:
56124
containers:
57125
- name: nginx
58-
image: nginx:1.7.9
126+
image: nginx:1.14.2
59127
ports:
60128
- containerPort: 80
61129
```
130+
{{< note >}}
131+
<!--
132+
Some resource types have additional restrictions on their names.
133+
-->
134+
135+
某些资源类型可能有其相应的附加命名约束。
136+
137+
{{< /note >}}
138+
62139
63140
## UIDs
64141
65142
{{< glossary_definition term_id="uid" length="all" >}}
66143
144+
<!--
145+
Kubernetes UIDs are universally unique identifiers (also known as UUIDs).
146+
UUIDs are standardized as ISO/IEC 9834-8 and as ITU-T X.667.
147+
-->
148+
Kubernetes UIDs 是通用的唯一标识符 (也叫 UUIDs).
149+
UUIDs 是标准化的,见 ISO/IEC 9834-8 和 ITU-T X.667.
150+
151+
{{% /capture %}}
152+
153+
{{% capture whatsnext %}}
154+
<!--
155+
* Read about [labels](/docs/concepts/overview/working-with-objects/labels/) in Kubernetes.
156+
* See the [Identifiers and Names in Kubernetes](https://git.k8s.io/community/contributors/design-proposals/architecture/identifiers.md) design document.
157+
-->
158+
* 阅读关于 Kubernetes [labels](/docs/concepts/overview/working-with-objects/labels/)。
159+
* 更多参见 [Kubernetes 标识符和名称设计文档](https://git.k8s.io/community/contributors/design-proposals/architecture/identifiers.md).
160+
67161
{{% /capture %}}

0 commit comments

Comments
 (0)