Update Ubuntu/Debian installation instructions to use Signed-By option (#26906)

The use of `apt-key` to install has also been removed as it is now deprecated
and will be last available in Debian 11 and Ubuntu 22.04.

Also updates the Docker repository setup instructions in container-runtimes.md,
to now refer to the respective instructions at https://docs.docker.com/engine/install/
which has already made the move to use the signed-by option.
This commit is contained in:
Terry Moschou
2021-03-08 21:15:28 +10:30
parent 86bb7aaec1
commit 21382af32e
3 changed files with 219 additions and 237 deletions
@@ -89,134 +89,102 @@ EOF
sudo sysctl --system sudo sysctl --system
``` ```
Install containerd: Install `containerd`:
{{< tabs name="tab-cri-containerd-installation" >}} {{< tabs name="tab-cri-containerd-installation" >}}
{{% tab name="Ubuntu 16.04" %}} {{% tab name="Ubuntu 16.04" %}}
```shell 1. Setup the [Docker Engine repository for Ubuntu](https://docs.docker.com/engine/install/ubuntu/#set-up-the-repository)
# (Install containerd)
## Set up the repository
### Install packages to allow apt to use a repository over HTTPS
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
```
```shell 2. Install `containerd`:
## Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key --keyring /etc/apt/trusted.gpg.d/docker.gpg add -
```
```shell ```shell
## Add Docker apt repository. sudo apt-get update && sudo apt-get install -y containerd.io
sudo add-apt-repository \ ```
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
```
```shell 3. Configure `containerd`:
## Install containerd
sudo apt-get update && sudo apt-get install -y containerd.io
```
```shell ```shell
# Configure containerd sudo mkdir -p /etc/containerd
sudo mkdir -p /etc/containerd containerd config default | sudo tee /etc/containerd/config.toml
containerd config default | sudo tee /etc/containerd/config.toml ```
```
4. Restart `containerd`:
```shell
sudo systemctl restart containerd
```
```shell
# Restart containerd
sudo systemctl restart containerd
```
{{% /tab %}} {{% /tab %}}
{{% tab name="Ubuntu 18.04/20.04" %}} {{% tab name="Ubuntu 18.04/20.04" %}}
```shell 1. Install `containerd`:
# (Install containerd)
sudo apt-get update && sudo apt-get install -y containerd
```
```shell ```shell
# Configure containerd sudo apt-get update && sudo apt-get install -y containerd
sudo mkdir -p /etc/containerd ```
containerd config default | sudo tee /etc/containerd/config.toml
``` 2. Configure `containerd`:
```shell
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
```
3. Restart `containerd`:
```shell
sudo systemctl restart containerd
```
```shell
# Restart containerd
sudo systemctl restart containerd
```
{{% /tab %}} {{% /tab %}}
{{% tab name="Debian 9+" %}} {{% tab name="Debian 9+" %}}
```shell 1. Setup the [Docker Engine repository for Debian](https://docs.docker.com/engine/install/debian/#set-up-the-repository)
# (Install containerd)
## Set up the repository
### Install packages to allow apt to use a repository over HTTPS
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
```
```shell 2. Install `containerd`:
## Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key --keyring /etc/apt/trusted.gpg.d/docker.gpg add -
```
```shell ```shell
## Add Docker apt repository. sudo apt-get update && sudo apt-get install -y containerd.io
sudo add-apt-repository \ ```
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
```
```shell 3. Configure `containerd`:
## Install containerd
sudo apt-get update && sudo apt-get install -y containerd.io
```
```shell ```shell
# Set default containerd configuration sudo mkdir -p /etc/containerd
sudo mkdir -p /etc/containerd containerd config default | sudo tee /etc/containerd/config.toml
containerd config default | sudo tee /etc/containerd/config.toml ```
```
4. Restart `containerd`:
```shell
sudo systemctl restart containerd
```
```shell
# Restart containerd
sudo systemctl restart containerd
```
{{% /tab %}} {{% /tab %}}
{{% tab name="CentOS/RHEL 7.4+" %}} {{% tab name="CentOS/RHEL 7.4+" %}}
```shell 1. Setup the [Docker Engine repository for CentOS/RHEL](https://docs.docker.com/engine/install/centos/#set-up-the-repository)
# (Install containerd)
## Set up the repository
### Install required packages
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
```
```shell 2. Install `containerd`:
## Add docker repository
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
```
```shell ```shell
## Install containerd sudo yum update -y && sudo yum install -y containerd.io
sudo yum update -y && sudo yum install -y containerd.io ```
```
```shell 3. Configure `containerd`:
## Configure containerd
sudo mkdir -p /etc/containerd ```shell
containerd config default | sudo tee /etc/containerd/config.toml sudo mkdir -p /etc/containerd
``` containerd config default | sudo tee /etc/containerd/config.toml
```
4. Restart `containerd`:
```shell
sudo systemctl restart containerd
```
```shell
# Restart containerd
sudo systemctl restart containerd
```
{{% /tab %}} {{% /tab %}}
{{% tab name="Windows (PowerShell)" %}} {{% tab name="Windows (PowerShell)" %}}
@@ -224,33 +192,35 @@ sudo systemctl restart containerd
Start a Powershell session, set `$Version` to the desired version (ex: `$Version=1.4.3`), and then run the following commands: Start a Powershell session, set `$Version` to the desired version (ex: `$Version=1.4.3`), and then run the following commands:
<br /> <br />
```powershell 1. Download `containerd`:
# (Install containerd)
# Download containerd
curl.exe -L https://github.com/containerd/containerd/releases/download/v$Version/containerd-$Version-windows-amd64.tar.gz -o containerd-windows-amd64.tar.gz
tar.exe xvf .\containerd-windows-amd64.tar.gz
```
```powershell ```powershell
# Extract and configure curl.exe -L https://github.com/containerd/containerd/releases/download/v$Version/containerd-$Version-windows-amd64.tar.gz -o containerd-windows-amd64.tar.gz
Copy-Item -Path ".\bin\" -Destination "$Env:ProgramFiles\containerd" -Recurse -Force tar.exe xvf .\containerd-windows-amd64.tar.gz
cd $Env:ProgramFiles\containerd\ ```
.\containerd.exe config default | Out-File config.toml -Encoding ascii
# Review the configuration. Depending on setup you may want to adjust: 2. Extract and configure:
# - the sandbox_image (Kubernetes pause image)
# - cni bin_dir and conf_dir locations
Get-Content config.toml
# (Optional - but highly recommended) Exclude containerd from Windows Defender Scans ```powershell
Add-MpPreference -ExclusionProcess "$Env:ProgramFiles\containerd\containerd.exe" Copy-Item -Path ".\bin\" -Destination "$Env:ProgramFiles\containerd" -Recurse -Force
``` cd $Env:ProgramFiles\containerd\
.\containerd.exe config default | Out-File config.toml -Encoding ascii
```powershell # Review the configuration. Depending on setup you may want to adjust:
# Start containerd # - the sandbox_image (Kubernetes pause image)
.\containerd.exe --register-service # - cni bin_dir and conf_dir locations
Start-Service containerd Get-Content config.toml
```
# (Optional - but highly recommended) Exclude containerd from Windows Defender Scans
Add-MpPreference -ExclusionProcess "$Env:ProgramFiles\containerd\containerd.exe"
```
3. Start `containerd`:
```powershell
.\containerd.exe --register-service
Start-Service containerd
```
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
@@ -465,97 +435,66 @@ Use the following commands to install Docker on your system:
{{< tabs name="tab-cri-docker-installation" >}} {{< tabs name="tab-cri-docker-installation" >}}
{{% tab name="Ubuntu 16.04+" %}} {{% tab name="Ubuntu 16.04+" %}}
```shell 1. Setup the [Docker Engine repository for Ubuntu](https://docs.docker.com/engine/install/ubuntu/#set-up-the-repository)
# (Install Docker CE)
## Set up the repository:
### Install packages to allow apt to use a repository over HTTPS
sudo apt-get update && sudo apt-get install -y \
apt-transport-https ca-certificates curl software-properties-common gnupg2
```
```shell 2. Install Docker CE:
# Add Docker's official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key --keyring /etc/apt/trusted.gpg.d/docker.gpg add -
```
```shell ```shell
# Add the Docker apt repository: sudo apt-get update && sudo apt-get install -y \
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
```
```shell
# Install Docker CE
sudo apt-get update && sudo apt-get install -y \
containerd.io=1.2.13-2 \ containerd.io=1.2.13-2 \
docker-ce=5:19.03.11~3-0~ubuntu-$(lsb_release -cs) \ docker-ce=5:19.03.11~3-0~ubuntu-$(lsb_release -cs) \
docker-ce-cli=5:19.03.11~3-0~ubuntu-$(lsb_release -cs) docker-ce-cli=5:19.03.11~3-0~ubuntu-$(lsb_release -cs)
``` ```
```shell 3. Set up the Docker daemon:
## Create /etc/docker
sudo mkdir /etc/docker
```
```shell ```shell
# Set up the Docker daemon sudo mkdir /etc/docker
cat <<EOF | sudo tee /etc/docker/daemon.json cat <<EOF | sudo tee /etc/docker/daemon.json
{ {
"exec-opts": ["native.cgroupdriver=systemd"], "exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file", "log-driver": "json-file",
"log-opts": { "log-opts": {
"max-size": "100m" "max-size": "100m"
}, },
"storage-driver": "overlay2" "storage-driver": "overlay2"
} }
EOF EOF
``` ```
```shell 4. Create `/etc/systemd/system/docker.service.d`:
# Create /etc/systemd/system/docker.service.d
sudo mkdir -p /etc/systemd/system/docker.service.d ```shell
``` sudo mkdir -p /etc/systemd/system/docker.service.d
```
5. Restart Docker:
```shell
sudo systemctl daemon-reload
sudo systemctl restart docker
```
```shell
# Restart Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
```
{{% /tab %}} {{% /tab %}}
{{% tab name="CentOS/RHEL 7.4+" %}} {{% tab name="CentOS/RHEL 7.4+" %}}
```shell 1. Setup the [Docker Engine repository for CentOS/RHEL](https://docs.docker.com/engine/install/centos/#set-up-the-repository)
# (Install Docker CE)
## Set up the repository
### Install required packages
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
```
```shell 2. Install Docker CE:
## Add the Docker repository
sudo yum-config-manager --add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
```
```shell ```shell
# Install Docker CE sudo yum update -y && sudo yum install -y \
sudo yum update -y && sudo yum install -y \
containerd.io-1.2.13 \ containerd.io-1.2.13 \
docker-ce-19.03.11 \ docker-ce-19.03.11 \
docker-ce-cli-19.03.11 docker-ce-cli-19.03.11
``` ```
```shell 3. Set up the Docker daemon:
## Create /etc/docker
sudo mkdir /etc/docker
```
```shell ```shell
# Set up the Docker daemon sudo mkdir /etc/docker
cat <<EOF | sudo tee /etc/docker/daemon.json cat <<EOF | sudo tee /etc/docker/daemon.json
{ {
"exec-opts": ["native.cgroupdriver=systemd"], "exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file", "log-driver": "json-file",
"log-opts": { "log-opts": {
@@ -565,20 +504,23 @@ cat <<EOF | sudo tee /etc/docker/daemon.json
"storage-opts": [ "storage-opts": [
"overlay2.override_kernel_check=true" "overlay2.override_kernel_check=true"
] ]
} }
EOF EOF
``` ```
```shell 4. Create `/etc/systemd/system/docker.service.d`:
# Create /etc/systemd/system/docker.service.d
sudo mkdir -p /etc/systemd/system/docker.service.d ```shell
``` sudo mkdir -p /etc/systemd/system/docker.service.d
```
5. Restart Docker:
```shell
sudo systemctl daemon-reload
sudo systemctl restart docker
```
```shell
# Restart Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
```
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
@@ -175,16 +175,34 @@ For more information on version skews, see:
{{< tabs name="k8s_install" >}} {{< tabs name="k8s_install" >}}
{{% tab name="Debian-based distributions" %}} {{% tab name="Debian-based distributions" %}}
```bash
sudo apt-get update && sudo apt-get install -y apt-transport-https curl 1. Update the `apt` package index and install packages needed to use the Kubernetes `apt` repository:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list ```shell
deb https://apt.kubernetes.io/ kubernetes-xenial main sudo apt-get update
EOF sudo apt-get install -y apt-transport-https ca-certificates wget
sudo apt-get update ```
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl 2. Download the Google Cloud public signing key:
```
```shell
sudo wget -O /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
```
3. Add the Kubernetes `apt` repository:
```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, install `kubelet`, `kubeadm` and `kubectl`, and pin their version:
```shell
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
```
{{% /tab %}} {{% /tab %}}
{{% tab name="Red Hat-based distributions" %}} {{% tab name="Red Hat-based distributions" %}}
```bash ```bash
@@ -100,13 +100,35 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:
### Install using native package management ### Install using native package management
{{< tabs name="kubectl_install" >}} {{< tabs name="kubectl_install" >}}
{{< tab name="Ubuntu, Debian or HypriotOS" codelang="bash" >}} {{% tab name="Ubuntu, Debian or HypriotOS" %}}
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 - 1. Update the `apt` package index and install packages needed to use the Kubernetes `apt` repository:
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update ```shell
sudo apt-get install -y kubectl sudo apt-get update
{{< /tab >}} sudo apt-get install -y apt-transport-https ca-certificates wget
```
2. Download the Google Cloud public signing key:
```shell
sudo wget -O /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
```
3. Add the Kubernetes `apt` repository:
```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`:
```shell
sudo apt-get update
sudo apt-get install -y kubectl
```
{{% /tab %}}
{{< tab name="CentOS, RHEL or Fedora" codelang="bash" >}}cat <<EOF > /etc/yum.repos.d/kubernetes.repo {{< tab name="CentOS, RHEL or Fedora" codelang="bash" >}}cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes] [kubernetes]