Skip to content

Commit 6f498cf

Browse files
committed
[zh] Sync concepts section (6)
1 parent 2ac91aa commit 6f498cf

File tree

4 files changed

+144
-36
lines changed

4 files changed

+144
-36
lines changed

content/zh/docs/concepts/services-networking/dns-pod-service.md

Lines changed: 90 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,23 @@ title: Pod 与 Service 的 DNS
33
content_type: concept
44
weight: 20
55
---
6+
<!--
7+
reviewers:
8+
- davidopp
9+
- thockin
10+
title: DNS for Services and Pods
11+
content_type: concept
12+
weight: 20
13+
-->
14+
615
<!-- overview -->
716

817
<!--
9-
This page provides an overview of DNS support by Kubernetes.
18+
Kubernetes creates DNS records for services and pods. You can contact
19+
services with consistent DNS names instead of IP addresses.
1020
-->
11-
本页面提供 Kubernetes 对 DNS 的支持的概述。
21+
Kubernetes 为服务和 Pods 创建 DNS 记录。
22+
你可以使用一致的 DNS 名称而非 IP 地址来访问服务。
1223

1324
<!-- body -->
1425

@@ -21,40 +32,93 @@ resolve DNS names.
2132
-->
2233
## 介绍
2334

24-
Kubernetes DNS 在群集上调度 DNS Pod 和服务,并配置 kubelet 以告知各个容器使用 DNS 服务的 IP 来解析 DNS 名称。
35+
Kubernetes DNS 在集群上调度 DNS Pod 和服务,并配置 kubelet 以告知各个容器
36+
使用 DNS 服务的 IP 来解析 DNS 名称。
2537

2638
<!--
27-
### What things get DNS names?
28-
2939
Every Service defined in the cluster (including the DNS server itself) is
30-
assigned a DNS name. By default, a client Pod's DNS search list will
31-
include the Pod's own namespace and the cluster's default domain. This is best
32-
illustrated by example:
40+
assigned a DNS name. By default, a client Pod's DNS search list includes the
41+
Pod's own namespace and the cluster's default domain.
42+
-->
43+
集群中定义的每个 Service (包括 DNS 服务器自身)都被赋予一个 DNS 名称。
44+
默认情况下,客户端 Pod 的 DNS 搜索列表会包含 Pod 自身的名字空间和集群
45+
的默认域。
46+
47+
<!--
48+
### Namespaces of Services
49+
50+
A DNS query may return different results based on the namespace of the pod making
51+
it. DNS queries that don't specify a namespace are limited to the pod's
52+
namespace. Access services in other namespaces by specifying it in the DNS query.
3353
34-
Assume a Service named `foo` in the Kubernetes namespace `bar`. A Pod running
35-
in namespace `bar` can look up this service by simply doing a DNS query for
36-
`foo`. A Pod running in namespace `quux` can look up this service by doing a
37-
DNS query for `foo.bar`.
54+
For example, consider a pod in a `test` namespace. A `data` service is in
55+
the `prod` namespace.
3856
39-
The following sections detail the supported record types and layout that is
57+
A query for `data` returns no results, because it uses the pod's `test` namespace.
58+
59+
A query for `data.prod` returns the intended result, because it specifies the
60+
namespace.
61+
-->
62+
### Service 的名字空间
63+
64+
DNS 查询可能因为执行查询的 Pod 所在的名字空间而返回不同的结果。
65+
不指定名字空间的 DNS 查询会被限制在 Pod 所在的名字空间内。
66+
要访问其他名字空间中的服务,需要在 DNS 查询中给出名字空间。
67+
68+
例如,假定名字空间 `test` 中存在一个 Pod,`prod` 名字空间中存在一个服务
69+
`data`
70+
71+
Pod 查询 `data` 时没有返回结果,因为使用的是 Pod 的名字空间 `test`
72+
73+
Pod 查询 `data.prod` 时则会返回预期的结果,因为查询中指定了名字空间。
74+
75+
<!--
76+
DNS queries may be expanded using the pod's `/etc/resolv.conf`. Kubelet
77+
sets this file for each pod. For example, a query for just `data` may be
78+
expanded to `data.test.cluster.local`. The values of the `search` option
79+
are used to expand queries. To learn more about DNS queries, see
80+
[the `resolv.conf` manual page.](https://www.man7.org/linux/man-pages/man5/resolv.conf.5.html)
81+
-->
82+
DNS 查询可以使用 Pod 中的 `/etc/resolv.conf` 展开。kubelet 会为每个 Pod
83+
生成此文件。例如,对 `data` 的查询可能被展开为 `data.test.cluster.local`
84+
`search` 选项的取值会被用来展开查询。要进一步了解 DNS 查询,可参阅
85+
[`resolv.conf` 手册页面](https://www.man7.org/linux/man-pages/man5/resolv.conf.5.html)
86+
87+
```
88+
nameserver 10.32.0.10
89+
search <namespace>.svc.cluster.local svc.cluster.local cluster.local
90+
options ndots:5
91+
```
92+
93+
<!--
94+
In summary, a pod in the _test_ namespace can successfully resolve either
95+
`data.prod` or `data.prod.cluster.local`.
96+
-->
97+
概括起来,名字空间 `test` 中的 Pod 可以成功地解析 `data.prod` 或者
98+
`data.prod.cluster.local`
99+
100+
<!--
101+
### DNS Records
102+
103+
What objects get DNS records?
104+
-->
105+
### DNS 记录 {#dns-records}
106+
107+
哪些对象会获得 DNS 记录呢?
108+
109+
1. Services
110+
2. Pods
111+
112+
<!--
113+
The following sections detail the supported DNS record types and layout that is
40114
supported. Any other layout or names or queries that happen to work are
41115
considered implementation details and are subject to change without warning.
42116
For more up-to-date specification, see
43117
[Kubernetes DNS-Based Service Discovery](https://github.com/kubernetes/dns/blob/master/docs/specification.md).
44118
-->
45-
## 哪些对象会有 DNS 名字? {#what-things-get-dns-names}
46-
47-
在集群中定义的每个 Service(包括 DNS 服务器自身)都会被指派一个 DNS 名称。
48-
默认,一个客户端 Pod 的 DNS 搜索列表将包含该 Pod 自己的名字空间和集群默认域。
49-
如下示例是一个很好的说明:
50-
51-
假设在 Kubernetes 集群的名字空间 `bar` 中,定义了一个服务 `foo`
52-
运行在名字空间 `bar` 中的 Pod 可以简单地通过 DNS 查询 `foo` 来找到该服务。
53-
运行在名字空间 `quux` 中的 Pod 可以通过 DNS 查询 `foo.bar` 找到该服务。
54-
55-
以下各节详细介绍了受支持的记录类型和支持的布局。
119+
以下各节详细介绍了被支持的 DNS 记录类型和被支持的布局。
56120
其它布局、名称或者查询即使碰巧可以工作,也应视为实现细节,
57-
将来很可能被更改而且不会因此出现警告
121+
将来很可能被更改而且不会因此发出警告
58122
有关最新规范请查看
59123
[Kubernetes 基于 DNS 的服务发现](https://github.com/kubernetes/dns/blob/master/docs/specification.md)
60124

@@ -301,7 +365,7 @@ If a Pod enables this feature and its FQDN is longer than 64 character, it will
301365

302366
如果 Pod 启用这一特性,而其 FQDN 超出 64 字符,Pod 的启动会失败。
303367
Pod 会一直出于 `Pending` 状态(通过 `kubectl` 所看到的 `ContainerCreating`),
304-
并产生错误事件,例如
368+
并产生错误事件,例如
305369
"Failed to construct FQDN from pod hostname and cluster domain, FQDN
306370
`long-FQDN` is too long (64 characters is the max, 70 characters requested)."
307371
(无法基于 Pod 主机名和集群域名构造 FQDN,FQDN `long-FQDN` 过长,至多 64

content/zh/docs/concepts/services-networking/ingress-controllers.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Kubernetes as a project supports and maintains [AWS](https://github.com/kubernet
2424
-->
2525
为了让 Ingress 资源工作,集群必须有一个正在运行的 Ingress 控制器。
2626

27-
与作为 `kube-controller-manager` 可执行文件的一部分运行的其他类型的控制器不同,Ingress 控制器不是随集群自动启动的。
27+
与作为 `kube-controller-manager` 可执行文件的一部分运行的其他类型的控制器不同,
28+
Ingress 控制器不是随集群自动启动的。
2829
基于此页面,你可选择最适合你的集群的 ingress 控制器实现。
2930

3031
Kubernetes 作为一个项目,目前支持和维护
@@ -54,15 +55,18 @@ Kubernetes 作为一个项目,目前支持和维护
5455
* [AKS 应用程序网关 Ingress 控制器](https://azure.github.io/application-gateway-kubernetes-ingress/)
5556
是一个配置 [Azure 应用程序网关](https://docs.microsoft.com/azure/application-gateway/overview)
5657
的 Ingress 控制器。
57-
* [Ambassador](https://www.getambassador.io/) API 网关是一个基于 [Envoy](https://www.envoyproxy.io) 的 Ingress
58+
* [Ambassador](https://www.getambassador.io/) API 网关是一个基于
59+
[Envoy](https://www.envoyproxy.io) 的 Ingress
5860
控制器。
59-
* [Apache APISIX Ingress 控制器](https://github.com/apache/apisix-ingress-controller) 是一个基于 [Apache APISIX 网关](https://github.com/apache/apisix) 的 Ingress 控制器。
61+
* [Apache APISIX Ingress 控制器](https://github.com/apache/apisix-ingress-controller)
62+
是一个基于 [Apache APISIX 网关](https://github.com/apache/apisix) 的 Ingress 控制器。
6063
* [Avi Kubernetes Operator](https://github.com/vmware/load-balancer-and-ingress-services-for-kubernetes)
6164
使用 [VMware NSX Advanced Load Balancer](https://avinetworks.com/)
6265
提供第 4 到第 7 层的负载均衡。
6366
* [Citrix Ingress 控制器](https://github.com/citrix/citrix-k8s-ingress-controller#readme)
6467
可以用来与 Citrix Application Delivery Controller 一起使用。
65-
* [Contour](https://projectcontour.io/) 是一个基于 [Envoy](https://www.envoyproxy.io/) 的 Ingress 控制器。
68+
* [Contour](https://projectcontour.io/) 是一个基于 [Envoy](https://www.envoyproxy.io/)
69+
的 Ingress 控制器。
6670
* [EnRoute](https://getenroute.io/) 是一个基于 [Envoy](https://www.envoyproxy.io) API 网关,
6771
可以作为 Ingress 控制器来执行。
6872
<!--
@@ -82,7 +86,8 @@ Kubernetes 作为一个项目,目前支持和维护
8286
让你能够使用 Ingress 来配置 F5 BIG-IP 虚拟服务器。
8387
* [Gloo](https://gloo.solo.io) 是一个开源的、基于 [Envoy](https://www.envoyproxy.io)
8488
Ingress 控制器,能够提供 API 网关功能,
85-
* [HAProxy Ingress](https://haproxy-ingress.github.io/) 针对 [HAProxy](https://www.haproxy.org/#desc)
89+
* [HAProxy Ingress](https://haproxy-ingress.github.io/) 针对
90+
[HAProxy](https://www.haproxy.org/#desc)
8691
的 Ingress 控制器。
8792
* [用于 Kubernetes 的 HAProxy Ingress 控制器](https://github.com/haproxytech/kubernetes-ingress#readme)
8893
也是一个针对 [HAProxy](https://www.haproxy.org/#desc) 的 Ingress 控制器。
@@ -96,6 +101,7 @@ Kubernetes 作为一个项目,目前支持和维护
96101
* [Skipper](https://opensource.zalando.com/skipper/kubernetes/ingress-controller/) HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress, designed as a library to build your custom proxy.
97102
* The [Traefik Kubernetes Ingress provider](https://doc.traefik.io/traefik/providers/kubernetes-ingress/) is an
98103
ingress controller for the [Traefik](https://traefik.io/traefik/) proxy.
104+
* [Tyk Operator](https://github.com/TykTechnologies/tyk-operator) extends Ingress with Custom Resources to bring API Management capabilities to Ingress. Tyk Operator works with the Open Source Tyk Gateway & Tyk Cloud control plane.
99105
* [Voyager](https://appscode.com/products/voyager) is an ingress controller for
100106
[HAProxy](https://www.haproxy.org/#desc).
101107
-->
@@ -109,8 +115,11 @@ Kubernetes 作为一个项目,目前支持和维护
109115
设计用来作为构造你自己的定制代理的库。
110116
* [Traefik Kubernetes Ingress 提供程序](https://doc.traefik.io/traefik/providers/kubernetes-ingress/)
111117
是一个用于 [Traefik](https://traefik.io/traefik/) 代理的 Ingress 控制器。
112-
* [Voyager](https://appscode.com/products/voyager) 是一个针对 [HAProxy](https://www.haproxy.org/#desc)
113-
的 Ingress 控制器。
118+
* [Tyk Operator](https://github.com/TykTechnologies/tyk-operator)
119+
使用自定义资源扩展 Ingress,为之带来 API 管理能力。Tyk Operator
120+
使用开源的 Tyk Gateway & Tyk Cloud 控制面。
121+
* [Voyager](https://appscode.com/products/voyager) 是一个针对
122+
[HAProxy](https://www.haproxy.org/#desc) 的 Ingress 控制器。
114123

115124
<!--
116125
## Using multiple Ingress controllers

content/zh/docs/concepts/services-networking/ingress.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,32 @@ IngressClass 资源包含额外的配置,其中包括应当实现该类的控
411411

412412
<!--
413413
IngressClass resources contain an optional parameters field. This can be used to
414-
reference additional configuration for this class.
414+
reference additional implementation-specific configuration for this class.
415415
-->
416-
IngressClass 资源包含一个可选的 `parameters` 字段,可用于为该类引用额外配置。
416+
IngressClass 资源包含一个可选的 `parameters` 字段,可用于为该类引用额外的、
417+
特定于具体实现的配置。
418+
419+
<!--
420+
#### Namespace-scoped parameters
421+
-->
422+
#### 名字空间域的参数
423+
424+
{{< feature-state for_k8s_version="v1.21" state="alpha" >}}
425+
426+
<!--
427+
`Parameters` field has a `scope` and `namespace` field that can be used to
428+
reference a namespace-specific resource for configuration of an Ingress class.
429+
`Scope` field defaults to `Cluster`, meaning, the default is cluster-scoped
430+
resource. Setting `Scope` to `Namespace` and setting the `Namespace` field
431+
will reference a parameters resource in a specific namespace:
432+
-->
433+
`parameters` 字段有一个 `scope``namespace` 字段,可用来引用特定
434+
于名字空间的资源,对 Ingress 类进行配置。
435+
`scope` 字段默认为 `Cluster`,表示默认是集群作用域的资源。
436+
`scope` 设置为 `Namespace` 并设置 `namespace` 字段就可以引用某特定
437+
名字空间中的参数资源。
438+
439+
{{< codenew file="service/networking/namespaced-params.yaml" >}}
417440

418441
<!--
419442
### Deprecated Annotation
@@ -488,7 +511,7 @@ There are existing Kubernetes concepts that allow you to expose a single Service
488511

489512
<!--
490513
If you create it using `kubectl apply -f` you should be able to view the state
491-
of the Ingress you just added:
514+
of the Ingress you added:
492515
-->
493516
如果使用 `kubectl apply -f` 创建此 Ingress,则应该能够查看刚刚添加的 Ingress 的状态:
494517

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: IngressClass
3+
metadata:
4+
name: external-lb
5+
spec:
6+
controller: example.com/ingress-controller
7+
parameters:
8+
apiGroup: k8s.example.com
9+
kind: IngressParameters
10+
name: external-lb
11+
namespace: external-configuration
12+
scope: Namespace

0 commit comments

Comments
 (0)