From 3efa4ecb90ffa0caffae75193fc0aef7978a1760 Mon Sep 17 00:00:00 2001 From: Bingo Liao <44894824@qq.com> Date: Tue, 17 Nov 2020 08:12:11 +0800 Subject: [PATCH] other part of multicluster-management Signed-off-by: Bingo Liao <44894824@qq.com> --- .../zh/docs/multicluster-management/_index.md | 2 +- .../enable-multicluster/agent-connection.md | 64 ++++----- .../enable-multicluster/direct-connection.md | 32 ++--- .../import-cloud-hosted-k8s/_index.md | 2 +- .../import-cloud-hosted-k8s/import-aws-eks.md | 125 +++++++++++++++++- .../import-on-prem-k8s/_index.md | 2 +- .../introduction/kubefed-in-kubesphere.md | 2 +- .../introduction/overview.md | 4 +- .../remove-cluster/_index.md | 2 +- 9 files changed, 176 insertions(+), 59 deletions(-) diff --git a/content/zh/docs/multicluster-management/_index.md b/content/zh/docs/multicluster-management/_index.md index e34413344..50788ed0e 100644 --- a/content/zh/docs/multicluster-management/_index.md +++ b/content/zh/docs/multicluster-management/_index.md @@ -14,7 +14,7 @@ icon: "/images/docs/docs.svg" 本章演示如何使用 KubeSphere 的多集群功能导入异构集群以进行统一的管理。 -### [概要](../multicluster-management/introduction/overview/) +### [概述](../multicluster-management/introduction/overview/) 对多集群管理有个基本的了解,例如多集群管理的常见用例,以及 KubeSphere 可以通过多集群功能带来的好处。 diff --git a/content/zh/docs/multicluster-management/enable-multicluster/agent-connection.md b/content/zh/docs/multicluster-management/enable-multicluster/agent-connection.md index 69c1ce8cb..eb7a5cd5a 100644 --- a/content/zh/docs/multicluster-management/enable-multicluster/agent-connection.md +++ b/content/zh/docs/multicluster-management/enable-multicluster/agent-connection.md @@ -32,9 +32,9 @@ KubeSphere 的 [Tower](https://github.com/kubesphere/tower) 组件用于代理 - 选项 B - 使用 Kubectl: -```shell -kubectl edit cc ks-installer -n kubesphere-system -``` + ```shell + kubectl edit cc ks-installer -n kubesphere-system + ``` 向下滚动并将 `clusterRole` 的值设置为 `host` ,然后点击**更新**(如果使用 web 控制台)以使其生效: @@ -93,40 +93,40 @@ tower LoadBalancer 10.233.63.191 139.198.110.23 8080:30721/TCP 1. 如果看不到相应的地址显示出来(EXTERNAL-IP 处于 pending 状态),则需要手动设置代理地址。例如,您有一个可用的公有 IP 地址 `139.198.120.120`,并且此 IP 地址的端口 `8080` 被转发到集群的端口 `30721`。执行以下命令来检查服务。 -```shell -kubectl -n kubesphere-system get svc -``` + ```shell + kubectl -n kubesphere-system get svc + ``` -```shell -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -tower LoadBalancer 10.233.63.191 8080:30721/TCP 16h -``` + ```shell + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE + tower LoadBalancer 10.233.63.191 8080:30721/TCP 16h + ``` 2. 将 `proxyPublishAddress` 的值添加到 ks-installer 的配置文件中,并按如下所示输入公有 IP 地址和端口号。 -- 选项 A - 使用 web 控制台: + - 选项 A - 使用 web 控制台: -使用 `admin` 帐户登录控制台,然后进入**集群管理**页面上的 **CRDs**。输入关键字 `ClusterConfiguration`,然后进入其详细信息页面。编辑 `ks-installer` 的 YAML,类似于[启用可插拔组件](../../../pluggable-components/)。 + 使用 `admin` 帐户登录控制台,然后进入**集群管理**页面上的 **CRDs**。输入关键字 `ClusterConfiguration`,然后进入其详细信息页面。编辑 `ks-installer` 的 YAML,类似于[启用可插拔组件](../../../pluggable-components/)。 -- 选项 B - 使用 Kubectl: + - 选项 B - 使用 Kubectl: -```bash -kubectl -n kubesphere-system edit clusterconfiguration ks-installer -``` + ```bash + kubectl -n kubesphere-system edit clusterconfiguration ks-installer + ``` -定位到 `multicluster` 并为 `proxyPublishAddress` 添加新行来定义IP地址,以便访问 tower。 + 定位到 `multicluster` 并为 `proxyPublishAddress` 添加新行来定义IP地址,以便访问 tower。 -```yaml -multicluster: - clusterRole: host - proxyPublishAddress: http://139.198.120.120:8080 # Add this line to set the address to access tower -``` + ```yaml + multicluster: + clusterRole: host + proxyPublishAddress: http://139.198.120.120:8080 # Add this line to set the address to access tower + ``` 3. 保存配置并重启 `ks-apiserver`。 -```shell -kubectl -n kubesphere-system rollout restart deployment ks-apiserver -``` + ```shell + kubectl -n kubesphere-system rollout restart deployment ks-apiserver + ``` {{}} @@ -158,9 +158,9 @@ jwtSecret: "gfIwilcc0WjNGKJ5DLeksf2JKfcLgTZU" - 选项 B - 使用 Kubectl: -```shell -kubectl edit cc ks-installer -n kubesphere-system -``` + ```shell + kubectl edit cc ks-installer -n kubesphere-system + ``` 输入上面相应地方显示的 `jwtSecret`: @@ -203,18 +203,18 @@ multicluster: 1. 打开 H 集群仪表板,然后点击**添加集群**。 -![添加集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827231611.png) + ![添加集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827231611.png) 2. 输入要导入的集群的基本信息,然后单击**下一步**。 -![导入集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827211842.png) + ![导入集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827211842.png) 3. 在**连接方法**中,选择**集群连接代理**,然后点击**导入**。 -![代理](/images/docs/agent-en.png) + ![代理](/images/docs/agent-en.png) 4. 根据指示在 M 集群中创建一个 `agent.yaml` 文件,然后将 deployment 复制并粘贴到该文件中。在节点上执行 `kubectl create -f agent.yaml` 然后等待代理启动并运行。请确保 M 集群可以访问代理地址。 5. 当集群代理启动并运行时,您可以在 H 集群中看到已导入的集群。 -![Azure AKS](https://ap3.qingstor.com/kubesphere-website/docs/20200827231650.png) + ![Azure AKS](https://ap3.qingstor.com/kubesphere-website/docs/20200827231650.png) diff --git a/content/zh/docs/multicluster-management/enable-multicluster/direct-connection.md b/content/zh/docs/multicluster-management/enable-multicluster/direct-connection.md index efd29a5a7..b2fa37fe9 100644 --- a/content/zh/docs/multicluster-management/enable-multicluster/direct-connection.md +++ b/content/zh/docs/multicluster-management/enable-multicluster/direct-connection.md @@ -1,7 +1,7 @@ --- title: "直接连接" keywords: 'Kubernetes, KubeSphere, 多集群, 混合云, 直接连接' -description: '概要' +description: '概述' weight: 3011 --- @@ -28,13 +28,13 @@ weight: 3011 - 选项 A - 使用 web 控制台: -使用 `admin` 帐户登录控制台,然后进入**集群管理**页面上的 **CRDs**。输入关键字 `ClusterConfiguration`,然后转到其详细信息页面。编辑 `ks-installer` 的YAML,类似于[启用可插拔组件](../../../pluggable-components/)。 + 使用 `admin` 帐户登录控制台,然后进入**集群管理**页面上的 **CRDs**。输入关键字 `ClusterConfiguration`,然后转到其详细信息页面。编辑 `ks-installer` 的YAML,类似于[启用可插拔组件](../../../pluggable-components/)。 - 选项 B - 使用 Kubectl: -```shell -kubectl edit cc ks-installer -n kubesphere-system -``` + ```shell + kubectl edit cc ks-installer -n kubesphere-system + ``` 向下滚动并将 `clusterRole`的值设置为 `host`,然后点击**更新**(如果使用 web 控制台)以使其生效: @@ -86,13 +86,13 @@ jwtSecret: "gfIwilcc0WjNGKJ5DLeksf2JKfcLgTZU" - 选项 A - 使用 web 控制台: -使用 `admin` 帐户登录控制台,然后进入**集群管理**页面上的 **CRDs**。输入关键字`ClusterConfiguration`,然后进入其详细信息页面。编辑 ` ks-installer` 的 YAML,类似于[启用可插拔组件](../../../pluggable-components/)。 + 使用 `admin` 帐户登录控制台,然后进入**集群管理**页面上的 **CRDs**。输入关键字`ClusterConfiguration`,然后进入其详细信息页面。编辑 ` ks-installer` 的 YAML,类似于[启用可插拔组件](../../../pluggable-components/)。 - 选项 B - 使用 Kubectl: -```shell -kubectl edit cc ks-installer -n kubesphere-system -``` + ```shell + kubectl edit cc ks-installer -n kubesphere-system + ``` 输入上面相应地方显示的 `jwtSecret`: @@ -140,22 +140,22 @@ kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app= 1. 打开 H 集群仪表板,然后点击**添加集群**. -![添加集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827231611.png) + ![添加集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827231611.png) 2. 输入要导入的集群的基本信息,然后点击**下一步**. -![导入集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827211842.png) + ![导入集群](https://ap3.qingstor.com/kubesphere-website/docs/20200827211842.png) 3. 在**连接方法**中, 选择**直接连接到Kubernetes集群**. 4. [获取 KubeConfig](../retrieve-kubeconfig),复制成员集群的 KubeConfig 并将其粘贴到框中。 -{{< notice tip >}} -请确保在 H 集群的任何节点上都可以访问 KubeConfig 中的 `server` 地址。对于 `KubeSphere API 服务器` 地址,您可以填写 KubeSphere API 服务器地址或将其留空。 -{{}} + {{< notice tip >}} + 请确保在 H 集群的任何节点上都可以访问 KubeConfig 中的 `server` 地址。对于 `KubeSphere API 服务器` 地址,您可以填写 KubeSphere API 服务器地址或将其留空。 + {{}} -![导入集群 - 直接连接](/images/docs/direct_import_en.png) + ![导入集群 - 直接连接](/images/docs/direct_import_en.png) 5. 点击**导入**,然后等待集群初始化完成。 -![Azure AKS](https://ap3.qingstor.com/kubesphere-website/docs/20200827231650.png) + ![Azure AKS](https://ap3.qingstor.com/kubesphere-website/docs/20200827231650.png) diff --git a/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/_index.md b/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/_index.md index 545c12498..e507e855f 100644 --- a/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/_index.md +++ b/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/_index.md @@ -1,5 +1,5 @@ --- -linkTitle: "Import Cloud-hosted Kubernetes Cluster" +linkTitle: "导入云托管的 Kubernetes 集群" weight: 3010 _build: diff --git a/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/import-aws-eks.md b/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/import-aws-eks.md index 0002d42ed..40e9070cc 100644 --- a/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/import-aws-eks.md +++ b/content/zh/docs/multicluster-management/import-cloud-hosted-k8s/import-aws-eks.md @@ -1,10 +1,127 @@ --- -title: "Import AWS EKS Cluster" -keywords: 'kubernetes, kubesphere, multicluster, aws-eks' -description: 'Import AWS EKS Cluster' +title: "导入 AWS EKS 集群" +keywords: 'Kubernetes, KubeSphere, 多集群, Amazon eks' +description: '导入 AWS EKS 集群' weight: 2340 --- -TBD +在本节中,我们将向您展示如何使用[直接连接](../../enable-multicluster/direct-connection)方法将 EKS 导入 KubeSphere。 + +{{< notice note >}} +如果您打算使用[代理连接](../../enable-multicluster/agent-connection)导入 EKS,则可以跳过本章节并按照[代理连接](../../enable-multicluster/agent-connection)的文档逐步进行。 +{{}} + +[Amazon EKS](https://docs.aws.amazon.com/eks/index.html)不像标准 kubeadm 集群那样提供内置的 kubeconfig 文件。但是您可以通过参考此[文档](https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html)自动创建 kubeconfig。生成的 kubeconfig 将如下所示, + +```yaml +apiVersion: v1 +clusters: +- cluster: + server: + certificate-authority-data: + name: kubernetes +contexts: +- context: + cluster: kubernetes + user: aws + name: aws +current-context: aws +kind: Config +preferences: {} +users: +- name: aws + user: + exec: + apiVersion: client.authentication.k8s.io/v1alpha1 + command: aws + args: + - "eks" + - "get-token" + - "--cluster-name" + - "" + # - "--role" + # - "" + # env: + # - name: AWS_PROFILE + # value: "" +``` + +看起来不错,自动生成的 kubeconfig 只有一个问题,它要求在想要使用此 kubeconfig 的每台计算机上安装命令 `aws`(aws 命令行工具)。 + +## 不使用 `aws` 命令创建新的 kubeconfig +假设您有一个 EKS 集群,它已经安装了 KubeSphere,并且您已经按照上面的[文档](https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html)创建了一个自动生成的 kubeconfig。所以,现在我们可以从您的本地计算机访问 EKS。 + +```shell +~:# kubectl get node +NAME STATUS ROLES AGE VERSION +ip-10-0-47-38.cn-north-1.compute.internal Ready 11h v1.18.8-eks-7c9bda +ip-10-0-8-148.cn-north-1.compute.internal Ready 78m v1.18.8-eks-7c9bda +``` +上面的命令将显示您的 EKS 集群节点。 + +以下部分将获取由 KubeSphere 创建的 serviceaccount `kubesphere` 的令牌。它具有对集群的集群管理员访问权限,我们将其用作新的 kubeconfig 令牌。 + +```bash +TOKEN=$(kubectl -n kubesphere-system get secret $(kubectl -n kubesphere-system get sa kubesphere -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 -d) +kubectl config set-credentials kubesphere --token=${TOKEN} +kubectl config set-credentials --current --user=kubesphere +``` + +检查新的 kubeconfig。 +``` +~:# cat ~/.kube/config +``` + +如果一切正常,您将看到如下所示的新的 kubeconfig。注意用户部分,您会发现我们插入了一个新用户 `KubeSphere` 并将其设置为当前上下文用户。 + +```yaml +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZ...S0tLQo= + server: https://*.sk1.cn-north-1.eks.amazonaws.com.cn + name: arn:aws-cn:eks:cn-north-1:660450875567:cluster/EKS-LUSLVMT6 +contexts: +- context: + cluster: arn:aws-cn:eks:cn-north-1:660450875567:cluster/EKS-LUSLVMT6 + user: kubesphere + name: arn:aws-cn:eks:cn-north-1:660450875567:cluster/EKS-LUSLVMT6 +current-context: arn:aws-cn:eks:cn-north-1:660450875567:cluster/EKS-LUSLVMT6 +kind: Config +preferences: {} +users: +- name: arn:aws-cn:eks:cn-north-1:660450875567:cluster/EKS-LUSLVMT6 + user: + exec: + apiVersion: client.authentication.k8s.io/v1alpha1 + args: + - --region + - cn-north-1 + - eks + - get-token + - --cluster-name + - EKS-LUSLVMT6 + command: aws + env: null +- name: kubesphere + user: + token: eyJhbGciOiJSUzI1NiIsImtpZCI6ImlCRHF4SlE5a0JFNDlSM2xKWnY1Vkt5NTJrcDNqRS1Ta25IYkg1akhNRmsifQ.eyJpc3M................9KQtFULW544G-FBwURd6ArjgQ3Ay6NHYWZe3gWCHLmag9gF-hnzxequ7oN0LiJrA-al1qGeQv-8eiOFqX3RPCQgbybmix8qw5U6f-Rwvb47-xA +``` + +再次检查我们的新 kubeconfig 是否可以访问 EKS。 +``` +~:# kubectl get nodes +NAME STATUS ROLES AGE VERSION +ip-10-0-47-38.cn-north-1.compute.internal Ready 11h v1.18.8-eks-7c9bda +ip-10-0-8-148.cn-north-1.compute.internal Ready 78m v1.18.8-eks-7c9bda +``` + +创建新的 kubeconfig 后,我们可以使用它直接将 EKS 导入 KubeSphere。不要忘记与主集群[同步](https://github.com/kubesphere/community/blob/master/sig-multicluster/how-to-setup-multicluster-on-kubesphere/README.md#MemberCluster) `jwtSecret` + +![eks 导入](/images/docs/eks-kubeconfig.png) + +And wola! + +![eks 概述](/images/docs/eks-overview.png) diff --git a/content/zh/docs/multicluster-management/import-on-prem-k8s/_index.md b/content/zh/docs/multicluster-management/import-on-prem-k8s/_index.md index a5583e5da..ffeffb3e9 100644 --- a/content/zh/docs/multicluster-management/import-on-prem-k8s/_index.md +++ b/content/zh/docs/multicluster-management/import-on-prem-k8s/_index.md @@ -1,5 +1,5 @@ --- -linkTitle: "Import On-prem Kubernetes Cluster" +linkTitle: "导入本地 Kubernetes 集群" weight: 3010 _build: diff --git a/content/zh/docs/multicluster-management/introduction/kubefed-in-kubesphere.md b/content/zh/docs/multicluster-management/introduction/kubefed-in-kubesphere.md index ec13b734e..610df6e7d 100644 --- a/content/zh/docs/multicluster-management/introduction/kubefed-in-kubesphere.md +++ b/content/zh/docs/multicluster-management/introduction/kubefed-in-kubesphere.md @@ -1,7 +1,7 @@ --- title: "KubeSphere 中的 Kubernetes 联邦" keywords: 'Kubernetes, KubeSphere, 联邦, 多集群, 混合云' -description: '概要' +description: '概述' weight: 3007 --- diff --git a/content/zh/docs/multicluster-management/introduction/overview.md b/content/zh/docs/multicluster-management/introduction/overview.md index f6e827521..c1796d731 100644 --- a/content/zh/docs/multicluster-management/introduction/overview.md +++ b/content/zh/docs/multicluster-management/introduction/overview.md @@ -1,7 +1,7 @@ --- -title: "概要" +title: "概述" keywords: 'Kubernetes, KubeSphere, 多集群, 混合云' -description: '概要' +description: '概述' weight: 3006 --- diff --git a/content/zh/docs/multicluster-management/remove-cluster/_index.md b/content/zh/docs/multicluster-management/remove-cluster/_index.md index b303ded0a..ba0b7c01f 100644 --- a/content/zh/docs/multicluster-management/remove-cluster/_index.md +++ b/content/zh/docs/multicluster-management/remove-cluster/_index.md @@ -1,5 +1,5 @@ --- -linkTitle: "Remove Cluster" +linkTitle: "删除集群" weight: 3010 _build: