Skip to content

Commit

Permalink
[zh] Resync task files (5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tengqm committed May 14, 2021
1 parent 42313ab commit 29c0554
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 161 deletions.
Expand Up @@ -4,11 +4,9 @@ description: "在 macOS 上实现 Bash 自动补全的一些可选配置。"
headless: true
---
<!--
---
title: "bash auto-completion on macOS"
description: "Some optional configuration for bash auto-completion on macOS."
headless: true
---
-->

<!--
Expand Down Expand Up @@ -154,20 +152,23 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
```

<!--
- If you installed kubectl with Homebrew (as explained [above](#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything.
- If you installed kubectl with Homebrew (as explained [here](/docs/tasks/tools/install-kubectl-macos/#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything.
-->
- 如果你是用 Homebrew 安装的 kubectl([如上所述](#install-with-homebrew-on-macos)),
那么 kubectl 补全脚本应该已经安装到目录 `/usr/local/etc/bash_completion.d/kubectl` 中了。
这种情况下,你什么都不需要做。
- 如果你是用 Homebrew 安装的 kubectl(如
[此页面](/zh/docs/tasks/install-with-homebrew-on-macos/#install-with-homebrew-on-macos)
所描述),则kubectl 补全脚本应该已经安装到目录 `/usr/local/etc/bash_completion.d/kubectl`
中了。这种情况下,你什么都不需要做。

{{< note >}}
<!--
The Homebrew installation of bash-completion v2 sources all the files in the `BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work.
-->
用 Hommbrew 安装的 bash-completion v2 会初始化 目录 `BASH_COMPLETION_COMPAT_DIR` 中的所有文件,这就是后两种方法能正常工作的原因。
{{< /note >}}
{{< note >}}
<!--
The Homebrew installation of bash-completion v2 sources all the files in the `BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work.
-->
用 Hommbrew 安装的 bash-completion v2 会初始化 目录 `BASH_COMPLETION_COMPAT_DIR`
中的所有文件,这就是后两种方法能正常工作的原因。
{{< /note >}}

<!--
In any case, after reloading your shell, kubectl completion should be working.
-->
总之,重新加载 shell 之后,kubectl 补全功能将立即生效。

129 changes: 85 additions & 44 deletions content/zh/docs/tasks/tools/install-kubectl-linux.md
Expand Up @@ -8,7 +8,6 @@ card:
title: 在 Linux 系统中安装 kubectl
---
<!--
---
reviewers:
- mikedanese
title: Install and Set Up kubectl on Linux
Expand All @@ -18,18 +17,17 @@ card:
name: tasks
weight: 20
title: Install kubectl on Linux
---
-->

## {{% heading "prerequisites" %}}

<!--
You must use a kubectl version that is within one minor version difference of your cluster.
For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master.
You must use a kubectl version that is within one minor version difference of your cluster. For example, a v{{< skew latestVersion >}} client can communicate with v{{< skew prevMinorVersion >}}, v{{< skew latestVersion >}}, and v{{< skew nextMinorVersion >}} control planes.
Using the latest version of kubectl helps avoid unforeseen issues.
-->
kubectl 版本和集群版本之间的差异必须在一个小版本号内。
例如:v1.2 版本的客户端只能与 v1.1、v1.2 和 v1.3 版本的集群一起工作。
例如:v{{< skew latestVersion >}} 版本的客户端能与 v{{< skew prevMinorVersion >}}、
v{{< skew latestVersion >}} 和 v{{< skew nextMinorVersion >}} 版本的控制面通信。
用最新版的 kubectl 有助于避免不可预见的问题。

<!--
Expand All @@ -42,16 +40,16 @@ The following methods exist for installing kubectl on Linux:
-->
在 Linux 系统中安装 kubectl 有如下几种方法:

- [{{% heading "prerequisites" %}}](#{{% heading "prerequisites" %}})
- [在 Linux 系统中安装 kubectl](#install-kubectl-on-linux)
- [用 curl 在 Linux 系统中安装 kubectl](#install-kubectl-binary-with-curl-on-linux)
- [用原生包管理工具安装](#install-using-native-package-management)
- [用其他包管理工具安装](#install-using-other-package-management)
- [作为谷歌云 SDK 的一部分,在 Linux 中安装](#install-on-linux-as-part-of-the-google-cloud-sdk)
- [验证 kubectl 配置](#verify-kubectl-configration)
- [可选的 kubectl 配置](#optional-kubectl-configurations)
- [启用 shell 自动补全功能](#enable-shell-autocompletion)
- [{{% heading "whatsnext" %}}](#{{% heading "whatsnext" %}})
<!--
- [Install kubectl binary with curl on Linux](#install-kubectl-binary-with-curl-on-linux)
- [Install using native package management](#install-using-native-package-management)
- [Install using other package management](#install-using-other-package-management)
- [Install on Linux as part of the Google Cloud SDK](#install-on-linux-as-part-of-the-google-cloud-sdk)
-->
- [用 curl 在 Linux 系统中安装 kubectl](#install-kubectl-binary-with-curl-on-linux)
- [用原生包管理工具安装](#install-using-native-package-management)
- [用其他包管理工具安装](#install-using-other-package-management)
- [作为谷歌云 SDK 的一部分,在 Linux 中安装](#install-on-linux-as-part-of-the-google-cloud-sdk)

<!--
### Install kubectl binary with curl on Linux
Expand All @@ -68,26 +66,27 @@ The following methods exist for installing kubectl on Linux:
```

{{< note >}}
<!--
To download a specific version, replace the `$(curl -L -s https://dl.k8s.io/release/stable.txt)` portion of the command with the specific version.
<!--
To download a specific version, replace the `$(curl -L -s https://dl.k8s.io/release/stable.txt)` portion of the command with the specific version.
For example, to download version {{< param "fullversion" >}} on Linux, type:
-->
如需下载某个指定的版本,请用指定版本号替换该命令的这一部分: `$(curl -L -s https://dl.k8s.io/release/stable.txt)`
For example, to download version {{< param "fullversion" >}} on Linux, type:
-->
如需下载某个指定的版本,请用指定版本号替换该命令的这一部分:
`$(curl -L -s https://dl.k8s.io/release/stable.txt)`

例如,要在 Linux 中下载 {{< param "fullversion" >}} 版本,请输入:
例如,要在 Linux 中下载 {{< param "fullversion" >}} 版本,请输入:

```bash
curl -LO https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/linux/amd64/kubectl
```
{{< /note >}}

<!--
1. Validate the binary (optional)
<!--
1. Validate the binary (optional)
Download the kubectl checksum file:
-->
1. 验证该可执行文件(可选步骤)
Download the kubectl checksum file:
-->
2. 验证该可执行文件(可选步骤)

下载 kubectl 校验和文件:

Expand Down Expand Up @@ -130,10 +129,10 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:
下载的 kubectl 与校验和文件版本必须相同。
{{< /note >}}

<!--
1. Install kubectl
-->
1. 安装 kubectl
<!--
1. Install kubectl
-->
3. 安装 kubectl

```bash
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Expand All @@ -148,15 +147,14 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:
```bash
mkdir -p ~/.local/bin/kubectl
mv ./kubectl ~/.local/bin/kubectl
# and then add ~/.local/bin/kubectl to $PATH
# 之后将 ~/.local/bin/kubectl 添加到 $PATH
```

{{< /note >}}

<!--
1. Test to ensure the version you installed is up-to-date:
-->
1. 执行测试,以保障你安装的版本是最新的:
<!--
1. Test to ensure the version you installed is up-to-date:
-->
4. 执行测试,以保障你安装的版本是最新的:

```bash
kubectl version --client
Expand All @@ -169,14 +167,49 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:

{{< tabs name="kubectl_install" >}}
{{< tab name="Ubuntu、Debian 或 HypriotOS" codelang="bash" >}}
sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2 curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

<!--
1. Update the `apt` package index and install packages needed to use the Kubernetes `apt` repository:
-->
1. 更新 `apt` 包索引,并安装使用 Kubernetes `apt` 仓库锁需要的包:

```shell
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
```

<!--
2. Download the Google Cloud public signing key:
-->
2. 下载 Google Cloud 公开签名秘钥:

```shell
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
```

<!--
3. Add the Kubernetes `apt` repository:
-->
3. 添加 Kubernetes `apt` 仓库:

```shell
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
```

<!--
4. Update `apt` package index with the new repository and install kubectl:
-->
4. 更新 `apt` 包索引,使之包含新的仓库并安装 kubectl:

```shell
sudo apt-get update
sudo apt-get install -y kubectl
```

{{< /tab >}}

{{< tab name="CentOS、RHEL 或 Fedora" codelang="bash" >}}cat <<EOF > /etc/yum.repos.d/kubernetes.repo
{{< tab name="基于 Red Hat 的发行版" codelang="bash" >}}
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
Expand All @@ -199,7 +232,8 @@ yum install -y kubectl
<!--
If you are on Ubuntu or another Linux distribution that support [snap](https://snapcraft.io/docs/core/install) package manager, kubectl is available as a [snap](https://snapcraft.io/) application.
-->
如果你使用的 Ubuntu 或其他 Linux 发行版,内建支持 [snap](https://snapcraft.io/docs/core/install) 包管理工具,
如果你使用的 Ubuntu 或其他 Linux 发行版,内建支持
[snap](https://snapcraft.io/docs/core/install) 包管理工具,
则可用 [snap](https://snapcraft.io/) 命令安装 kubectl。

```shell
Expand All @@ -213,7 +247,8 @@ kubectl version --client
<!--
If you are on Linux and using [Homebrew](https://docs.brew.sh/Homebrew-on-Linux) package manager, kubectl is available for [installation](https://docs.brew.sh/Homebrew-on-Linux#install).
-->
如果你使用 Linux 系统,并且装了 [Homebrew](https://docs.brew.sh/Homebrew-on-Linux) 包管理工具,
如果你使用 Linux 系统,并且装了 [Homebrew](https://docs.brew.sh/Homebrew-on-Linux)
包管理工具,
则可以使用这种方式[安装](https://docs.brew.sh/Homebrew-on-Linux#install) kubectl。

```shell
Expand All @@ -239,6 +274,11 @@ kubectl version --client

{{< include "included/verify-kubectl.md" >}}

<!--
## Optional kubectl configurations
### Enable shell autocompletion
-->
## kubectl 的可选配置 {#optional-kubectl-configurations}

### 启用 shell 自动补全功能 {#enable-shell-autocompletion}
Expand All @@ -260,3 +300,4 @@ kubectl 为 Bash 和 Zsh 提供自动补全功能,可以减轻许多输入的
## {{% heading "whatsnext" %}}

{{< include "included/kubectl-whats-next.md" >}}

0 comments on commit 29c0554

Please sign in to comment.