[zh-cn] resync /tasks/tools/install-kubectl-linux.md

pull/35403/head
Michael 2022-07-26 20:45:06 +08:00
parent b43d6c9b7e
commit c9b6674c65
1 changed files with 51 additions and 36 deletions

View File

@ -171,49 +171,65 @@ Or use this for detailed view of version:
### 用原生包管理工具安装 {#install-using-native-package-management}
{{< tabs name="kubectl_install" >}}
{{% tab name="Ubuntu、Debian 或 HypriotOS" %}}
{{% tab name="基于 Debian 的发行版" %}}
<!--
1. Update the `apt` package index and install packages needed to use the Kubernetes `apt` repository:
-->
1. 更新 `apt` 包索引,并安装使用 Kubernetes `apt` 仓库所需要的包:
<!--
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 apt-get update
sudo apt-get install -y ca-certificates curl
```
<!--
If you use Debian 9 (stretch) or earlier you would also need to install `apt-transport-https`:
-->
{{< note >}}
```shell
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
```
如果你使用 Debian 9stretch或更早版本则你还需要安装 `apt-transport-https`
<!--
3. Add the Kubernetes `apt` repository:
-->
3. 添加 Kubernetes `apt` 仓库:
```shell
sudo apt-get install -y apt-transport-https
```
```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
```
{{< /note >}}
<!--
2. Download the Google Cloud public signing key:
-->
<!--
4. Update `apt` package index with the new repository and install kubectl:
-->
4. 更新 `apt` 包索引,使之包含新的仓库并安装 kubectl
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
```
```shell
sudo apt-get update
sudo apt-get install -y kubectl
```
{{% /tab %}}
{{% tab name="基于 Red Hat 的发行版" %}}
{{< tab name="基于 Red Hat 的发行版" codelang="bash" >}}
```shell
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
@ -223,9 +239,7 @@ gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
sudo yum install -y kubectl
```
{{% /tab %}}
{{< /tab >}}
{{< /tabs >}}
<!--
@ -352,6 +366,7 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
kubectl-convert: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match
```
{{< note >}}
<!--
Download the same version of the binary and checksum.