From b90aa9e75ea5de3d11587cd231b1fd1733cff295 Mon Sep 17 00:00:00 2001 From: windsonsea Date: Fri, 22 Dec 2023 16:37:14 +0800 Subject: [PATCH] [zh] Remove dual-hosted info about kops and kubespray --- .../setup/production-environment/_index.md | 9 +- .../production-environment/tools/_index.md | 40 ++ .../production-environment/tools/kops.md | 438 ------------------ .../production-environment/tools/kubespray.md | 313 ------------- 4 files changed, 44 insertions(+), 756 deletions(-) delete mode 100644 content/zh-cn/docs/setup/production-environment/tools/kops.md delete mode 100644 content/zh-cn/docs/setup/production-environment/tools/kubespray.md diff --git a/content/zh-cn/docs/setup/production-environment/_index.md b/content/zh-cn/docs/setup/production-environment/_index.md index 9db16d45b8..d245de1d1e 100644 --- a/content/zh-cn/docs/setup/production-environment/_index.md +++ b/content/zh-cn/docs/setup/production-environment/_index.md @@ -589,13 +589,12 @@ needs of your cluster's workloads: [API 服务器](/zh-cn/docs/setup/production-environment/tools/kubeadm/ha-topology/)这些功能组件配置高可用能力。 - 选择使用 [kubeadm](/zh-cn/docs/setup/production-environment/tools/kubeadm/)、 - [kops](/zh-cn/docs/setup/production-environment/tools/kops/) 或 - [Kubespray](/zh-cn/docs/setup/production-environment/tools/kubespray/) 作为部署方法。 + [kops](https://kops.sigs.k8s.io/) 或 + [Kubespray](https://kubespray.io/) 作为部署方法。 + + +搭建你自己的 Kubernetes 生产集群有许多方法和工具。例如: + +- [kubeadm](/zh-cn/docs/setup/production-environment/tools/kubeadm/) + + +- [kops](https://kops.sigs.k8s.io/):自动化集群制备工具。 + 有关教程、最佳实践、配置选项和社区联系信息,请查阅 + [`kOps` 网站](https://kops.sigs.k8s.io/)。 + + +- [kubespray](https://kubespray.io/): + 提供了 [Ansible](https://docs.ansible.com/) Playbook、 + [清单(inventory)](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/ansible.md#inventory)、 + 制备工具和通用 OS/Kubernetes 集群配置管理任务领域的知识。 + 你可以通过 Slack 频道 [#kubespray](https://kubernetes.slack.com/messages/kubespray/) 联系此社区。 diff --git a/content/zh-cn/docs/setup/production-environment/tools/kops.md b/content/zh-cn/docs/setup/production-environment/tools/kops.md deleted file mode 100644 index 9edfdddf13..0000000000 --- a/content/zh-cn/docs/setup/production-environment/tools/kops.md +++ /dev/null @@ -1,438 +0,0 @@ ---- -title: 使用 kOps 安装 Kubernetes -content_type: task -weight: 20 ---- - - - - - -本篇快速入门介绍了如何在 AWS 上轻松安装 Kubernetes 集群。 -本篇使用了一个名为 [`kOps`](https://github.com/kubernetes/kops) 的工具。 - - -`kOps` 是一个自动化的制备系统: - - -* 全自动安装流程 -* 使用 DNS 识别集群 -* 自我修复:一切都在自动扩缩组中运行 -* 支持多种操作系统(Amazon Linux、Debian、Flatcar、RHEL、Rocky 和 Ubuntu), - 参考 [images.md](https://github.com/kubernetes/kops/blob/master/docs/operations/images.md)。 -* 支持高可用,参考 - [high_availability.md](https://github.com/kubernetes/kops/blob/master/docs/operations/high_availability.md)。 -* 可以直接提供或者生成 terraform 清单,参考 - [terraform.md](https://github.com/kubernetes/kops/blob/master/docs/terraform.md)。 - -## {{% heading "prerequisites" %}} - - -* 你必须安装 [kubectl](/zh-cn/docs/tasks/tools/)。 -* 你必须安装[安装](https://github.com/kubernetes/kops#installing) `kops` - 到 64 位的(AMD64 和 Intel 64)设备架构上。 -* 你必须拥有一个 [AWS 账户](https://docs.aws.amazon.com/zh_cn/polly/latest/dg/setting-up.html), - 生成 [IAM 秘钥](https://docs.aws.amazon.com/zh_cn/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) - 并[配置](https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/cli-chap-configure.html#cli-quick-configuration) - 该秘钥。IAM 用户需要[足够的权限许可](https://github.com/kubernetes/kops/blob/master/docs/getting_started/aws.md#setup-iam-user)。 - - - - -## 创建集群 {#creating-a-cluster} - -### (1/5) 安装 kops - -#### 安装 - -从[下载页面](https://github.com/kubernetes/kops/releases)下载 kops -(从源代码构建也很方便): - -{{< tabs name="kops_installation" >}} -{{% tab name="macOS" %}} - - -使用下面的命令下载最新发布版本: - -```shell -curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-darwin-amd64 -``` - - -要下载特定版本,使用特定的 kops 版本替换下面命令中的部分: - -```shell -$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4) -``` - - -例如,要下载 kops v1.20.0,输入: - -```shell -curl -LO https://github.com/kubernetes/kops/releases/download/v1.20.0/kops-darwin-amd64 -``` - - -令 kops 二进制文件可执行: - -```shell -chmod +x kops-darwin-amd64 -``` - - -将 kops 二进制文件移到你的 PATH 下: - -```shell -sudo mv kops-darwin-amd64 /usr/local/bin/kops -``` - - -你也可以使用 [Homebrew](https://brew.sh/) 安装 kops: - -```shell -brew update && brew install kops -``` -{{% /tab %}} -{{% tab name="Linux" %}} - - -使用命令下载最新发布版本: - -```shell -curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64 -``` - - -要下载 kops 的特定版本,用特定的 kops 版本替换下面命令中的部分: - -```shell -$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4) -``` - - -例如,要下载 kops v1.20 版本,输入: - -```shell -curl -LO https://github.com/kubernetes/kops/releases/download/v1.20.0/kops-linux-amd64 -``` - - -令 kops 二进制文件可执行: - -```shell -chmod +x kops-linux-amd64 -``` - - -将 kops 二进制文件移到 PATH 下: - -```shell -sudo mv kops-linux-amd64 /usr/local/bin/kops -``` - - -你也可以使用 [Homebrew](https://docs.brew.sh/Homebrew-on-Linux) 来安装 kops。 - -```shell -brew update && brew install kops -``` - -{{% /tab %}} -{{< /tabs >}} - - -### (2/5) 为你的集群创建一个 route53 域名 - -kops 在集群内部和外部都使用 DNS 进行发现操作,这样你可以从客户端访问 -Kubernetes API 服务器。 - - -kops 对集群名称有明显的要求:它应该是有效的 DNS 名称。这样一来,你就不会再使集群混乱, -可以与同事明确共享集群,并且无需依赖记住 IP 地址即可访问集群。 - - -你可以,或许应该使用子域名来划分集群。作为示例,我们将使用域名 `useast1.dev.example.com`。 -这样,API 服务器端点域名将为 `api.useast1.dev.example.com`。 - - -Route53 托管区域可以服务子域名。你的托管区域可能是 `useast1.dev.example.com`, -还有 `dev.example.com` 甚至 `example.com`。 -kops 可以与以上任何一种配合使用,因此通常你出于组织原因选择不同的托管区域。 -例如,允许你在 `dev.example.com` 下创建记录,但不能在 `example.com` 下创建记录。 - - -假设你使用 `dev.example.com` 作为托管区域。你可以使用 -[正常流程](https://docs.aws.amazon.com/zh_cn/Route53/latest/DeveloperGuide/CreatingNewSubdomain.html) -或者使用诸如 `aws route53 create-hosted-zone --name dev.example.com --caller-reference 1` -之类的命令来创建该托管区域。 - - -然后,你必须在父域名中设置你的 DNS 记录,以便该域名中的记录可以被解析。 -在这里,你将在 `example.com` 中为 `dev` 创建 DNS 记录。 -如果它是根域名,则可以在域名注册机构配置 DNS 记录。 -例如,你需要在购买 `example.com` 的地方配置 `example.com`。 - - -检查你的 route53 域已经被正确设置(这是导致问题的最常见原因!)。 -如果你安装了 dig 工具,则可以通过运行以下步骤再次检查集群是否配置正确: - -`dig NS dev.example.com` - - -你应该看到 Route53 分配了你的托管区域的 4 条 DNS 记录。 - - -### (3/5) 创建一个 S3 存储桶来存储集群状态 - -kops 使你即使在安装后也可以管理集群。为此,它必须跟踪已创建的集群及其配置、所使用的密钥等。 -此信息存储在 S3 存储桶中。S3 权限用于控制对存储桶的访问。 - - -多个集群可以使用同一 S3 存储桶,并且你可以在管理同一集群的同事之间共享一个 -S3 存储桶 - 这比传递 kubecfg 文件容易得多。 -但是有权访问 S3 存储桶的任何人都将拥有对所有集群的管理访问权限, -因此你不想在运营团队之外共享它。 - - -因此,通常每个运维团队都有一个 S3 存储桶(而且名称通常对应于上面托管区域的名称!) - - -在我们的示例中,我们选择 `dev.example.com` 作为托管区域,因此我们选择 -`clusters.dev.example.com` 作为 S3 存储桶名称。 - - -* 导出 `AWS_PROFILE` 文件(如果你需要选择一个配置文件用来使 AWS CLI 正常工作) -* 使用 `aws s3 mb s3://clusters.dev.example.com` 创建 S3 存储桶 -* 你可以进行 `export KOPS_STATE_STORE=s3://clusters.dev.example.com` 操作, - 然后 kops 将默认使用此位置。 - 我们建议将其放入你的 bash profile 文件或类似文件中。 - - -### (4/5) 建立你的集群配置 - -运行 `kops create cluster` 以创建你的集群配置: - -`kops create cluster --zones=us-east-1c useast1.dev.example.com` - - -kops 将为你的集群创建配置。请注意,它**仅**创建配置,实际上并没有创建云资源。 -你将在下一步中使用 `kops update cluster` 进行创建。 -这使你有机会查看配置或进行更改。 - - -它打印出可用于进一步探索的命令: - - -* 使用以下命令列出集群:`kops get cluster` -* 使用以下命令编辑该集群:`kops edit cluster useast1.dev.example.com` -* 使用以下命令编辑你的节点实例组:`kops edit ig --name = useast1.dev.example.com nodes` -* 使用以下命令编辑你的主实例组:`kops edit ig --name = useast1.dev.example.com master-us-east-1c` - - -如果这是你第一次使用 kops,请花几分钟尝试一下!实例组是一组实例,将被注册为 Kubernetes 节点。 -在 AWS 上,这是通过 auto-scaling-groups 实现的。你可以有多个实例组。 -例如,你可能想要混合了 Spot 实例和按需实例的节点,或者混合了 GPU 实例和非 GPU 实例的节点。 - - -### (5/5) 在 AWS 中创建集群 - -运行 `kops update cluster` 以在 AWS 中创建集群: - -`kops update cluster useast1.dev.example.com --yes` - - -这需要几秒钟的时间才能运行,但实际上集群可能需要几分钟才能准备就绪。 -每当更改集群配置时,都会使用 `kops update cluster` 工具。 -它将在集群中应用你对配置进行的更改,根据需要重新配置 AWS 或者 Kubernetes。 - - -例如,在你运行 `kops edit ig nodes` 之后,然后运行 `kops update cluster --yes` -应用你的配置,有时你还必须运行 `kops rolling-update cluster` 立即回滚更新配置。 - - -如果没有 `--yes` 参数,`kops update cluster` 操作将向你显示其操作的预览效果。这对于生产集群很方便! - - -### 探索其他附加组件 - -请参阅[附加组件列表](/zh-cn/docs/concepts/cluster-administration/addons/)探索其他附加组件, -包括用于 Kubernetes 集群的日志记录、监视、网络策略、可视化和控制的工具。 - - -## 清理 {#cleanup} - -* 删除集群:`kops delete cluster useast1.dev.example.com --yes` - -## {{% heading "whatsnext" %}} - - -* 了解有关 Kubernetes 的[概念](/zh-cn/docs/concepts/)和 - [`kubectl`](/zh-cn/docs/reference/kubectl/) 的更多信息。 -* 参阅 `kOps` [进阶用法](https://kops.sigs.k8s.io/) 获取教程、最佳实践和进阶配置选项。 -* 通过 Slack:[社区讨论](https://kops.sigs.k8s.io/contributing/#other-ways-to-communicate-with-the-contributors) - 参与 `kOps` 社区讨论。(访问 https://slack.k8s.io/ 获取此 Slack 工作空间的邀请) -* 通过解决或提出一个 [GitHub Issue](https://github.com/kubernetes/kops/issues) 来为 `kOps` 做贡献。 diff --git a/content/zh-cn/docs/setup/production-environment/tools/kubespray.md b/content/zh-cn/docs/setup/production-environment/tools/kubespray.md deleted file mode 100644 index 5980bed292..0000000000 --- a/content/zh-cn/docs/setup/production-environment/tools/kubespray.md +++ /dev/null @@ -1,313 +0,0 @@ ---- -title: 使用 Kubespray 安装 Kubernetes -content_type: concept -weight: 30 ---- - - - - - -此快速入门有助于使用 [Kubespray](https://github.com/kubernetes-sigs/kubespray) -安装在 GCE、Azure、OpenStack、AWS、vSphere、Equinix Metal(曾用名 Packet)、Oracle Cloud -Infrastructure(实验性)或 Baremetal 上托管的 Kubernetes 集群。 - - -Kubespray 是由若干 [Ansible](https://docs.ansible.com/) Playbook、 -[清单(inventory)](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/ansible.md#inventory)、 -制备工具和通用 OS/Kubernetes 集群配置管理任务的领域知识组成的。 - -Kubespray 提供: - - -- 高可用性集群 -- 可组合属性(例如可选择网络插件) -- 支持大多数流行的 Linux 发行版 - - Flatcar Container Linux - - Debian Bullseye、Buster、Jessie、Stretch - - Ubuntu 16.04、18.04、20.04、22.04 - - CentOS/RHEL 7、8、9 - - Fedora 35、36 - - Fedora CoreOS - - openSUSE Leap 15.x/Tumbleweed - - Oracle Linux 7、8、9 - - Alma Linux 8、9 - - Rocky Linux 8、9 - - Kylin Linux Advanced Server V10 - - Amazon Linux 2 -- 持续集成测试 - - -要选择最适合你的用例的工具,请阅读 -[kubeadm](/zh-cn/docs/reference/setup-tools/kubeadm/) 和 -[kops](/zh-cn/docs/setup/production-environment/tools/kops/) -之间的[这份比较](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/comparisons.md)。 - - - - -## 创建集群 {#creating-a-cluster} - -### (1/5)满足下层设施要求 - - -按以下[要求](https://github.com/kubernetes-sigs/kubespray#requirements)来配置服务器: - - -* **Kubernetes** 的最低版本要求为 V1.22 -* **在将运行 Ansible 命令的计算机上安装 Ansible v2.11(或更高版本)、Jinja 2.11(或更高版本)和 python-netaddr** -* 目标服务器必须**能够访问 Internet** 才能拉取 Docker 镜像。否则, - 需要其他配置([请参见离线环境](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/offline-environment.md)) -* 目标服务器配置为允许 **IPv4 转发** -* 如果针对 Pod 和 Service 使用 IPv6,则目标服务器配置为允许 **IPv6 转发** -* **防火墙不是由 kubespray 管理的**。你需要根据需求设置适当的规则策略。为了避免部署过程中出现问题,可以禁用防火墙。 -* 如果从非 root 用户帐户运行 kubespray,则应在目标服务器中配置正确的特权升级方法并指定 - `ansible_become` 标志或命令参数 `--become` 或 `-b` - - -Kubespray 提供以下实用程序来帮助你设置环境: - -* 为以下云驱动提供的 [Terraform](https://www.terraform.io/) 脚本: - * [AWS](https://github.com/kubernetes-sigs/kubespray/tree/master/contrib/terraform/aws) - * [OpenStack](https://github.com/kubernetes-sigs/kubespray/tree/master/contrib/terraform/openstack) - * [Equinix Metal](https://github.com/kubernetes-sigs/kubespray/tree/master/contrib/terraform/equinix) - - -### (2/5)编写清单文件 - -设置服务器后,请创建一个 -[Ansible 的清单文件](https://docs.ansible.com/ansible/latest/network/getting_started/first_inventory.html)。 -你可以手动执行此操作,也可以通过动态清单脚本执行此操作。有关更多信息,请参阅 -“[建立你自己的清单](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md#building-your-own-inventory)”。 - -### (3/5)规划集群部署 - -Kubespray 能够自定义部署的许多方面: - - -* 选择部署模式:kubeadm 或非 kubeadm -* CNI(网络)插件 -* DNS 配置 -* 控制平面的选择:本机/可执行文件或容器化 -* 组件版本 -* Calico 路由反射器 -* 组件运行时选项 - * {{< glossary_tooltip term_id="docker" >}} - * {{< glossary_tooltip term_id="containerd" >}} - * {{< glossary_tooltip term_id="cri-o" >}} -* 证书生成方式 - - -可以修改[变量文件](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html)以进行 -Kubespray 定制。 -如果你刚刚开始使用 Kubespray,请考虑使用 Kubespray 默认设置来部署你的集群并探索 Kubernetes。 - - -### (4/5)部署集群 - -接下来,部署你的集群: - -使用 [ansible-playbook](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md#starting-custom-deployment) -进行集群部署。 - -```shell -ansible-playbook -i your/inventory/inventory.ini cluster.yml -b -v \ - --private-key=~/.ssh/private_key -``` - - -大型部署(超过 100 个节点) -可能需要[特定的调整](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/large-deployments.md), -以获得最佳效果。 - - -### (5/5)验证部署 - -Kubespray 提供了一种使用 -[Netchecker](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/netcheck.md) -验证 Pod 间连接和 DNS 解析的方法。 -Netchecker 确保 netchecker-agents Pod 可以解析 DNS 请求, -并在默认命名空间内对每个请求执行 ping 操作。 -这些 Pod 模仿其他工作负载类似的行为,并用作集群运行状况指示器。 - - -## 集群操作 {#cluster-operations} - -Kubespray 提供了其他 Playbook 来管理集群: **scale** 和 **upgrade**。 - - -### 扩展集群 {#scale-your-cluster} - -你可以通过运行 scale playbook 向集群中添加工作节点。有关更多信息, -请参见 “[添加节点](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md#adding-nodes)”。 -你可以通过运行 remove-node playbook 来从集群中删除工作节点。有关更多信息, -请参见 “[删除节点](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md#remove-nodes)”。 - - -### 升级集群 {#upgrade-your-cluster} - -你可以通过运行 upgrade-cluster Playbook 来升级集群。有关更多信息,请参见 -“[升级](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/upgrades.md)”。 - - -## 清理 {#cleanup} - -你可以通过 [reset playbook](https://github.com/kubernetes-sigs/kubespray/blob/master/reset.yml) -重置节点并清除所有与 Kubespray 一起安装的组件。 - -{{< caution >}} - -运行 reset playbook 时,请确保不要意外地将生产集群作为目标! -{{< /caution >}} - - -## 反馈 {#feedback} - -* Slack 频道:[#kubespray](https://kubernetes.slack.com/messages/kubespray/) - (你可以在[此处](https://slack.k8s.io/)获得邀请)。 -* [GitHub 问题](https://github.com/kubernetes-sigs/kubespray/issues)。 - -## {{% heading "whatsnext" %}} - - -* 查看有关 Kubespray - [路线图](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/roadmap.md)的计划工作。 -* 查阅有关 [Kubespray](https://github.com/kubernetes-sigs/kubespray) 的更多信息。