Skip to content

Commit 78f1dfd

Browse files
authored
Merge pull request #25131 from tengqm/zh-sync-konnectivity
[zh] sync tasks/extend-kubernetes/setup-konnectivity.md
2 parents 49092f3 + 7ba7891 commit 78f1dfd

File tree

1 file changed

+63
-13
lines changed

1 file changed

+63
-13
lines changed

content/zh/docs/tasks/extend-kubernetes/setup-konnectivity.md

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,71 @@ Konnectivity 服务为控制平面提供集群通信的 TCP 级别代理。
2020
## Configure the Konnectivity service
2121
2222
The following steps require an egress configuration, for example:
23+
-->
24+
## 配置 Konnectivity 服务
25+
26+
接下来的步骤需要出口配置,比如:
2327

2428
{{< codenew file="admin/konnectivity/egress-selector-configuration.yaml" >}}
2529

30+
<!--
2631
You need to configure the API Server to use the Konnectivity service
2732
and direct the network traffic to the cluster nodes:
2833
34+
1. Make sure that
35+
the `ServiceAccountTokenVolumeProjection` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
36+
is enabled. You can enable
37+
[service account token volume protection](/docs/tasks/configure-pod-container/configure-service-account/#service-account-token-volume-projection)
38+
by providing the following flags to the kube-apiserver:
39+
```
40+
--service-account-issuer=api
41+
--service-account-signing-key-file=/etc/kubernetes/pki/sa.key
42+
--api-audiences=system:konnectivity-server
43+
```
44+
-->
45+
你需要配置 API 服务器来使用 Konnectivity 服务,并将网络流量定向到集群节点:
46+
47+
1. 确保 `ServiceAccountTokenVolumeProjection`
48+
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
49+
被启用。你可以通过为 kube-apiserver 提供以下标志启用
50+
[服务账号令牌卷保护](/zh/docs/tasks/configure-pod-container/configure-service-account/#service-account-token-volume-projection)
51+
52+
```
53+
--service-account-issuer=api
54+
--service-account-signing-key-file=/etc/kubernetes/pki/sa.key
55+
--api-audiences=system:konnectivity-server
56+
```
57+
58+
<!--
2959
1. Create an egress configuration file such as `admin/konnectivity/egress-selector-configuration.yaml`.
3060
1. Set the `--egress-selector-config-file` flag of the API Server to the path of
3161
your API Server egress configuration file.
3262
-->
33-
## 配置 Konnectivity 服务
34-
35-
接下来的步骤需要出口配置,比如:
36-
3763
{{< codenew file="admin/konnectivity/egress-selector-configuration.yaml" >}}
64+
2. 创建一个出口配置文件比如 `admin/konnectivity/egress-selector-configuration.yaml`
65+
3. 将 API 服务器的 `--egress-selector-config-file` 参数设置为你的 API 服务器的
66+
离站流量配置文件路径。
3867

39-
您需要配置 API 服务器来使用 Konnectivity 服务,并将网络流量定向到集群节点:
40-
41-
1. 创建一个出口配置文件比如 `admin/konnectivity/egress-selector-configuration.yaml`
42-
1. 将 API 服务器的 `--egress-selector-config-file` 参数设置为你的 API 服务器的出口配置文件路径。
68+
<!--
69+
Generate or obtain a certificate and kubeconfig for konnectivity-server.
70+
For example, you can use the OpenSSL command line tool to issue a X.509 certificate,
71+
using the cluster CA certificate `/etc/kubernetes/pki/ca.crt` from a control-plane host.
72+
-->
73+
为 konnectivity-server 生成或者取得证书和 kubeconfig 文件。
74+
例如,你可以使用 OpenSSL 命令行工具,基于存放在某控制面主机上
75+
`/etc/kubernetes/pki/ca.crt` 文件中的集群 CA 证书来
76+
发放一个 X.509 证书,
77+
78+
```bash
79+
openssl req -subj "/CN=system:konnectivity-server" -new -newkey rsa:2048 -nodes -out konnectivity.csr -keyout konnectivity.key -out konnectivity.csr
80+
openssl x509 -req -in konnectivity.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out konnectivity.crt -days 375 -sha256
81+
SERVER=$(kubectl config view -o jsonpath='{.clusters..server}')
82+
kubectl --kubeconfig /etc/kubernetes/konnectivity-server.conf config set-credentials system:konnectivity-server --client-certificate konnectivity.crt --client-key konnectivity.key --embed-certs=true
83+
kubectl --kubeconfig /etc/kubernetes/konnectivity-server.conf config set-cluster kubernetes --server "$SERVER" --certificate-authority /etc/kubernetes/pki/ca.crt --embed-certs=true
84+
kubectl --kubeconfig /etc/kubernetes/konnectivity-server.conf config set-context system:konnectivity-server@kubernetes --cluster kubernetes --user system:konnectivity-server
85+
kubectl --kubeconfig /etc/kubernetes/konnectivity-server.conf config use-context system:konnectivity-server@kubernetes
86+
rm -f konnectivity.crt konnectivity.key konnectivity.csr
87+
```
4388

4489
<!--
4590
Next, you need to deploy the Konnectivity server and agents.
@@ -52,23 +97,28 @@ that the Kubernetes components are deployed as a {{< glossary_tooltip text="stat
5297
term_id="static-pod" >}} in your cluster. If not, you can deploy the Konnectivity
5398
server as a DaemonSet.
5499
-->
55-
接下来,你需要部署 Konnectivity 服务器和代理。[kubernetes-sigs/apiserver-network-proxy](https://github.com/kubernetes-sigs/apiserver-network-proxy) 是参考实现。
100+
接下来,你需要部署 Konnectivity 服务器和代理。
101+
[kubernetes-sigs/apiserver-network-proxy](https://github.com/kubernetes-sigs/apiserver-network-proxy)
102+
是一个参考实现。
56103

57-
在控制平面节点上部署 Konnectivity 服务,下面提供的 `konnectivity-server.yaml` 配置清单假定您在集群中
58-
将 Kubernetes 组件都是部署为{{< glossary_tooltip text="静态 Pod" term_id="static-pod" >}}。如果不是,你可以将 Konnectivity 服务部署为 DaemonSet。
104+
在控制面节点上部署 Konnectivity 服务。
105+
下面提供的 `konnectivity-server.yaml` 配置清单假定在你的集群中
106+
Kubernetes 组件都是部署为{{< glossary_tooltip text="静态 Pod" term_id="static-pod" >}} 的。
107+
如果不是,你可以将 Konnectivity 服务部署为 DaemonSet。
59108

60109
{{< codenew file="admin/konnectivity/konnectivity-server.yaml" >}}
61110

62111
<!--
63112
Then deploy the Konnectivity agents in your cluster:
64113
-->
65-
在您的集群中部署 Konnectivity 代理:
114+
在你的集群中部署 Konnectivity 代理:
66115

67116
{{< codenew file="admin/konnectivity/konnectivity-agent.yaml" >}}
68117

69118
<!--
70119
Last, if RBAC is enabled in your cluster, create the relevant RBAC rules:
71120
-->
72-
最后,如果您的集群开启了 RBAC,请创建相关的 RBAC 规则:
121+
最后,如果你的集群启用了 RBAC,请创建相关的 RBAC 规则:
73122

74123
{{< codenew file="admin/konnectivity/konnectivity-rbac.yaml" >}}
124+

0 commit comments

Comments
 (0)