[zh] translation for admin 1
parent
0297612be4
commit
ea36ff4621
|
@ -1,76 +1,83 @@
|
|||
---
|
||||
title: 开启服务拓扑
|
||||
content_type: task
|
||||
min-kubernetes-server-version: 1.17
|
||||
---
|
||||
|
||||
<!-- overview -->
|
||||
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
|
||||
<!--
|
||||
This page provides an overview of enabling Service Topology in Kubernetes.
|
||||
This feature, specifically the alpha `topologyKeys` field, is deprecated since
|
||||
Kubernetes v1.21.
|
||||
[Topology Aware Hints](/docs/concepts/services-networking/topology-aware-hints/),
|
||||
introduced in Kubernetes v1.21, provide similar functionality.
|
||||
-->
|
||||
本页面提供了在 Kubernetes 中启用服务拓扑的概述。
|
||||
这项功能,特别是 Alpha 状态的 `topologyKeys` 字段,在 kubernetes v1.21 中已经弃用。
|
||||
在 kubernetes v1.21 加入的[拓扑感知提示](/zh/docs/concepts/services-networking/topology-aware-hints/)
|
||||
提供了类似的功能。
|
||||
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||
|
||||
|
||||
<!-- steps -->
|
||||
<!--
|
||||
## Introduction
|
||||
|
||||
_Service Topology_ enables a service to route traffic based upon the Node
|
||||
_Service Topology_ enables a {{< glossary_tooltip term_id="service">}} to route traffic based upon the Node
|
||||
topology of the cluster. For example, a service can specify that traffic be
|
||||
preferentially routed to endpoints that are on the same Node as the client, or
|
||||
in the same availability zone.
|
||||
-->
|
||||
## 介绍
|
||||
|
||||
_服务拓扑(Service Topology)_ 使服务能够根据集群中的 Node 拓扑来路由流量。
|
||||
_服务拓扑(Service Topology)_ 使 {{< glossary_tooltip term_id="service" text="服务">}}
|
||||
能够根据集群中的 Node 拓扑来路由流量。
|
||||
比如,服务可以指定将流量优先路由到与客户端位于同一节点或者同一可用区域的端点上。
|
||||
|
||||
<!--
|
||||
## Prerequisites
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||
|
||||
<!--
|
||||
The following prerequisites are needed in order to enable topology aware service
|
||||
routing:
|
||||
|
||||
* Kubernetes 1.17 or later
|
||||
* {{< glossary_tooltip text="Kube-proxy" term_id="kube-proxy" >}} running in iptables mode or IPVS mode
|
||||
* Enable [Endpoint Slices](/docs/concepts/services-networking/endpoint-slices/)
|
||||
* Kubernetes v1.17 or later
|
||||
* Configure {{< glossary_tooltip text="kube-proxy" term_id="kube-proxy" >}} to run in iptables mode or IPVS mode
|
||||
-->
|
||||
## 先决条件
|
||||
|
||||
需要下面列的先决条件,才能启用拓扑感知的服务路由:
|
||||
|
||||
* Kubernetes 1.17 或更新版本
|
||||
* {{< glossary_tooltip text="Kube-proxy" term_id="kube-proxy" >}} 以 iptables 或者 IPVS 模式运行
|
||||
* 启用[端点切片](/zh/docs/concepts/services-networking/endpoint-slices/)
|
||||
* 配置 {{< glossary_tooltip text="kube-proxy" term_id="kube-proxy" >}} 以 iptables 或者 IPVS 模式运行
|
||||
<!-- steps -->
|
||||
|
||||
<!--
|
||||
## Enable Service Topology
|
||||
|
||||
{{< feature-state for_k8s_version="v1.17" state="alpha" >}}
|
||||
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
|
||||
|
||||
To enable service topology, enable the `ServiceTopology` and `EndpointSlice` feature gate for all Kubernetes components:
|
||||
To enable service topology, enable the `ServiceTopology`
|
||||
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) for all Kubernetes components:
|
||||
-->
|
||||
## 启用服务拓扑
|
||||
|
||||
{{< feature-state for_k8s_version="v1.17" state="alpha" >}}
|
||||
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
|
||||
|
||||
要启用服务拓扑功能,需要为所有 Kubernetes 组件启用 `ServiceTopology` 和 `EndpointSlice` 特性门控:
|
||||
要启用服务拓扑功能,需要为所有 Kubernetes 组件启用 `ServiceTopology`
|
||||
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/):
|
||||
|
||||
```
|
||||
--feature-gates="ServiceTopology=true,EndpointSlice=true"
|
||||
--feature-gates="ServiceTopology=true`
|
||||
```
|
||||
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
<!--
|
||||
* Read about the [Service Topology](/docs/concepts/services-networking/service-topology) concept
|
||||
* Read about [Endpoint Slices](/docs/concepts/services-networking/endpoint-slices)
|
||||
* Read about [Topology Aware Hints](/docs/concepts/services-networking/topology-aware-hints/), the replacement for the `topologyKeys` field.
|
||||
* Read about [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
|
||||
* Read about the [Service Topology](/docs/concepts/services-networking/service-topology/) concept
|
||||
* Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
|
||||
-->
|
||||
* 阅读[服务拓扑](/zh/docs/concepts/services-networking/service-topology)概念
|
||||
|
||||
* 阅读[拓扑感知提示](/zh/docs/concepts/services-networking/topology-aware-hints/),该技术是用来替换 `topologyKeys` 字段的。
|
||||
* 阅读[端点切片](/zh/docs/concepts/services-networking/endpoint-slices)
|
||||
* 阅读[服务拓扑](/zh/docs/concepts/services-networking/service-topology)概念
|
||||
* 阅读[通过服务来连接应用](/zh/docs/concepts/services-networking/connect-applications-service/)
|
|
@ -12,15 +12,11 @@ content_type: task
|
|||
|
||||
<!-- overview -->
|
||||
|
||||
{{< feature-state for_k8s_version="v1.10" state="beta" >}}
|
||||
|
||||
<!--
|
||||
A subset of the Kubelet's configuration parameters may be
|
||||
set via an on-disk config file, as a substitute for command-line flags.
|
||||
This functionality is considered beta in v1.10.
|
||||
--->
|
||||
通过保存在硬盘的配置文件设置 kubelet 的部分配置参数,这可以作为命令行参数的替代。
|
||||
此功能在 v1.10 中为 beta 版。
|
||||
|
||||
<!--
|
||||
Providing parameters via a config file is the recommended approach because
|
||||
|
@ -28,27 +24,19 @@ it simplifies node deployment and configuration management.
|
|||
--->
|
||||
建议通过配置文件的方式提供参数,因为这样可以简化节点部署和配置管理。
|
||||
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
<!--
|
||||
- A v1.10 or higher Kubelet binary must be installed for beta functionality.
|
||||
-->
|
||||
- 需要安装 1.10 或更高版本的 kubelet 可执行文件,才能使用此 beta 功能。
|
||||
|
||||
<!-- steps -->
|
||||
|
||||
<!--
|
||||
## Create the config file
|
||||
|
||||
The subset of the Kubelet's configuration that can be configured via a file
|
||||
is defined by the `KubeletConfiguration` struct
|
||||
[here (v1beta1)](https://github.com/kubernetes/kubernetes/blob/{{< param "docsbranch" >}}/staging/src/k8s.io/kubelet/config/v1beta1/types.go).
|
||||
is defined by the
|
||||
[`KubeletConfiguration`](/docs/reference/config-api/kubelet-config.v1beta1/)
|
||||
struct.
|
||||
-->
|
||||
## 创建配置文件
|
||||
|
||||
`KubeletConfiguration` 结构体定义了可以通过文件配置的 Kubelet 配置子集,
|
||||
该结构体在 [这里(v1beta1)](https://github.com/kubernetes/kubernetes/blob/{{< param "docsbranch" >}}/staging/src/k8s.io/kubelet/config/v1beta1/types.go)
|
||||
可以找到。
|
||||
[`KubeletConfiguration`](/zh/docs/reference/config-api/kubelet-config.v1beta1/) 结构体定义了可以通过文件配置的 Kubelet 配置子集,
|
||||
|
||||
<!--
|
||||
The configuration file must be a JSON or YAML representation of the parameters
|
||||
|
@ -60,38 +48,47 @@ Here is an example of what this file might look like:
|
|||
确保 kubelet 可以读取该文件。
|
||||
|
||||
下面是一个 Kubelet 配置文件示例:
|
||||
|
||||
```yaml
|
||||
kind: KubeletConfiguration
|
||||
```
|
||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
kind: KubeletConfiguration
|
||||
address: "192.168.0.8",
|
||||
port: 20250,
|
||||
serializeImagePulls: false,
|
||||
evictionHard:
|
||||
memory.available: "200Mi"
|
||||
```
|
||||
|
||||
|
||||
<!--
|
||||
In the example, the Kubelet is configured to evict Pods when available memory drops below 200Mi.
|
||||
In the example, the Kubelet is configured to serve on IP address 192.168.0.8 and port 20250, pull images in parallel,
|
||||
and evict Pods when available memory drops below 200Mi.
|
||||
All other Kubelet configuration values are left at their built-in defaults, unless overridden
|
||||
by flags. Command line flags which target the same value as a config file will override that value.
|
||||
|
||||
For a trick to generate a configuration file from a live node, see
|
||||
[Reconfigure a Node's Kubelet in a Live Cluster](/docs/tasks/administer-cluster/reconfigure-kubelet).
|
||||
-->
|
||||
在这个示例中, 当可用内存低于 200Mi 时, kubelet 将会开始驱逐 Pods。
|
||||
在这个示例中, Kubelet 被设置为在地址 192.168.0.8 端口 20250 上提供服务,以并行方式拖拽镜像,
|
||||
当可用内存低于 200Mi 时, kubelet 将会开始驱逐 Pods。
|
||||
没有声明的其余配置项都将使用默认值,除非使用命令行参数来重载。
|
||||
命令行中的参数将会覆盖配置文件中的对应值。
|
||||
|
||||
作为一个小技巧,你可以从活动节点生成配置文件,相关方法请查看
|
||||
[重新配置活动集群节点的 kubelet](/zh/docs/tasks/administer-cluster/reconfigure-kubelet)。
|
||||
|
||||
<!--
|
||||
## Start a Kubelet process configured via the config file
|
||||
|
||||
{{< note >}}
|
||||
If you use kubeadm to initialize your cluster, use the kubelet-config while creating your cluster with `kubeadmin init`.
|
||||
See [configuring kubelet using kubeadm](/docs/setup/production-environment/tools/kubeadm/kubelet-integration/) for details.
|
||||
{{< /note >}}
|
||||
|
||||
Start the Kubelet with the `--config` flag set to the path of the Kubelet's config file.
|
||||
The Kubelet will then load its config from this file.
|
||||
--->
|
||||
|
||||
## 启动通过配置文件配置的 Kubelet 进程
|
||||
|
||||
{{< note >}}
|
||||
如果你使用 kubeadm 初始化你的集群,在使用 `kubeadmin init` 创建你的集群的时候请使用 kubelet-config。
|
||||
更多细节请阅读[使用 kubeadm 配置 kubelet](/zh/docs/setup/production-environment/tools/kubeadm/kubelet-integration/)
|
||||
{{< /note >}}
|
||||
|
||||
启动 Kubelet 需要将 `--config` 参数设置为 Kubelet 配置文件的路径。Kubelet 将从此文件加载其配置。
|
||||
|
||||
<!--
|
||||
|
@ -121,17 +118,12 @@ In the above example, this version is `kubelet.config.k8s.io/v1beta1`.
|
|||
|
||||
<!-- discussion -->
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
<!--
|
||||
## Relationship to Dynamic Kubelet Config
|
||||
|
||||
If you are using the [Dynamic Kubelet Configuration](/docs/tasks/administer-cluster/reconfigure-kubelet)
|
||||
feature, the combination of configuration provided via `--config` and any flags which override these values
|
||||
is considered the default "last known good" configuration by the automatic rollback mechanism.
|
||||
- Learn more about kubelet configuration by checking the
|
||||
[`KubeletConfiguration`](/docs/reference/config-api/kubelet-config.v1beta1/)
|
||||
reference.
|
||||
--->
|
||||
## 与动态 Kubelet 配置的关系
|
||||
|
||||
如果你正在使用[动态 kubelet 配置](/zh/docs/tasks/administer-cluster/reconfigure-kubelet)特性,
|
||||
那么自动回滚机制将认为通过 `--config` 提供的配置与覆盖这些值的任何参数的组合是
|
||||
"最后已知正常(last known good)" 的配置。
|
||||
|
||||
|
||||
- 参阅 [`KubeletConfiguration`](/zh/docs/reference/config-api/kubelet-config.v1beta1/)
|
||||
进一步学习 kubelet 的配置。
|
||||
|
|
|
@ -99,14 +99,14 @@ Kubernetes 负责编排和调度 Pod;在每一个节点上,
|
|||
使用抽象的容器运行时接口,所以你可以任意选用兼容的容器运行时。
|
||||
|
||||
<!--
|
||||
In its earliest releases, Kubernetes offered compatibility with just one container runtime: Docker.
|
||||
In its earliest releases, Kubernetes offered compatibility with one container runtime: Docker.
|
||||
Later in the Kubernetes project's history, cluster operators wanted to adopt additional container runtimes.
|
||||
The CRI was designed to allow this kind of flexibility - and the kubelet began supporting CRI. However,
|
||||
because Docker existed before the CRI specification was invented, the Kubernetes project created an
|
||||
adapter component, `dockershim`. The dockershim adapter allows the kubelet to interact with Docker as
|
||||
if Docker were a CRI compatible runtime.
|
||||
-->
|
||||
在早期版本中,Kubernetes 提供的兼容性只支持一个容器运行时:Docker。
|
||||
在早期版本中,Kubernetes 提供的兼容性支持一个容器运行时:Docker。
|
||||
在 Kubernetes 发展历史中,集群运营人员希望采用更多的容器运行时。
|
||||
于是 CRI 被设计出来满足这类灵活性需要 - 而 kubelet 亦开始支持 CRI。
|
||||
然而,因为 Docker 在 CRI 规范创建之前就已经存在,Kubernetes 就创建了一个适配器组件:`dockershim`。
|
||||
|
@ -144,7 +144,7 @@ or execute something inside container using `docker exec`.
|
|||
<!--
|
||||
If you're running workloads via Kubernetes, the best way to stop a container is through
|
||||
the Kubernetes API rather than directly through the container runtime (this advice applies
|
||||
for all container runtimes, not just Docker).
|
||||
for all container runtimes, not only Docker).
|
||||
-->
|
||||
{{< note >}}
|
||||
|
||||
|
|
|
@ -196,6 +196,39 @@ itself. To attempt an eviction (perhaps more REST-precisely, to attempt to
|
|||
Pod 的 Eviction 子资源可以看作是一种策略控制的 DELETE 操作,作用于 Pod 本身。
|
||||
要尝试驱逐(更准确地说,尝试 *创建* 一个 Eviction),需要用 POST 发出所尝试的操作。这里有一个例子:
|
||||
|
||||
{{< tabs name="Eviction_example" >}}
|
||||
{{% tab name="policy/v1" %}}
|
||||
<!--
|
||||
{{< note >}}
|
||||
`policy/v1` Eviction is available in v1.22+. Use `policy/v1beta1` with prior releases.
|
||||
{{< /note >}}
|
||||
-->
|
||||
{{< note >}}
|
||||
`policy/v1` 驱逐在 v1.22+ 中可用。在之前版本中请使用 `policy/v1beta1` 。
|
||||
{{< /note >}}
|
||||
|
||||
|
||||
```json
|
||||
{
|
||||
"apiVersion": "policy/v1",
|
||||
"kind": "Eviction",
|
||||
"metadata": {
|
||||
"name": "quux",
|
||||
"namespace": "default"
|
||||
}
|
||||
}
|
||||
```
|
||||
{{% /tab %}}
|
||||
{{% tab name="policy/v1beta1" %}}
|
||||
<!--
|
||||
{{< note >}}
|
||||
Deprecated in v1.22 in favor of `policy/v1`
|
||||
{{< /note >}}
|
||||
-->
|
||||
{{< note >}}
|
||||
在 v1.22 中已弃用,以 `policy/v1` 取代
|
||||
{{< /note >}}
|
||||
|
||||
```json
|
||||
{
|
||||
"apiVersion": "policy/v1beta1",
|
||||
|
@ -206,6 +239,8 @@ Pod 的 Eviction 子资源可以看作是一种策略控制的 DELETE 操作,
|
|||
}
|
||||
}
|
||||
```
|
||||
{{% /tab %}}
|
||||
{{< /tabs >}}
|
||||
|
||||
<!--
|
||||
You can attempt an eviction using `curl`:
|
||||
|
@ -219,8 +254,8 @@ curl -v -H 'Content-type: application/json' http://127.0.0.1:8080/api/v1/namespa
|
|||
<!--
|
||||
The API can respond in one of three ways:
|
||||
|
||||
- If the eviction is granted, then the pod is deleted just as if you had sent
|
||||
a `DELETE` request to the pod's URL and you get back `200 OK`.
|
||||
- If the eviction is granted, then the Pod is deleted as if you sent
|
||||
a `DELETE` request to the Pod's URL and received back `200 OK`.
|
||||
- If the current state of affairs wouldn't allow an eviction by the rules set
|
||||
forth in the budget, you get back `429 Too Many Requests`. This is
|
||||
typically used for generic rate limiting of *any* requests, but here we mean
|
||||
|
|
Loading…
Reference in New Issue