Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs to change Container runtime #30141

Merged
merged 17 commits into from
Feb 11, 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
title: "Migrating Container runtime from dockershim to conatiainerd"
Debanitrkl marked this conversation as resolved.
Show resolved Hide resolved
weight: 10
content_type: task
---

- Drain Node
```
# replace <node-to-drain> with the name of your node you are draining
kubectl drain <node-to-drain> --ignore-daemonsets
```
- Stop docker
Debanitrkl marked this conversation as resolved.
Show resolved Hide resolved
```
systemctl stop kubelet
systemctl stop docker
```
- Install & start containerd


### For linux systems
Debanitrkl marked this conversation as resolved.
Show resolved Hide resolved
Use the following commands to install Containerd on your system:

Install and configure prerequisites:
Copy link
Member

@neolit123 neolit123 Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the guide seems to be duplicating steps that already existing the in the "installing a container runtime" page:
https://kubernetes.io/docs/setup/production-environment/container-runtimes/
instead we can cross-link.

the steps can be generalized as:

  • drain node
  • stop kubelet
  • uninstall old CR
  • install new CR (CR of your chose, not picking a preference in this page, cross-link to the main CR page)
  • update kubelet config and kubeadm bits (optional)
  • restart kubelet
  • uncordon node
  • check if the node / pods work

i know that it works and i've seen users already do it, but before we merge such a guide for hotswap SIG node must tell us if this is even supported and if something unpredictable can happen. cgroup (drivers)? proper cleanup after uninstalling the old CR - logs, container state, etc?

cc @SergeyKanzhelev

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do want a “dummies guide to” here, because the Docker deprecation is already worrying quite a few people.


```shell
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

# Setup required sysctl params, these persist across reboots.
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF

# Apply sysctl params without reboot
sudo sysctl --system
```

Install containerd:

1. Install the `containerd.io` package from the official Docker repositories.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use the Docker repository for this? I would recommend that people fetch it from their
OS distribution or, failing that, from source and build it.

I suspect that telling people to get containerd from Docker is liable to add to the confusion.

Instructions for setting up the Docker repository for your respective Linux distribution and
installing the `containerd.io` package can be found at
[Install Docker Engine](https://docs.docker.com/engine/install/#server).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Instructions for setting up the Docker repository for your respective Linux distribution and
installing the `containerd.io` package can be found at
[Install Docker Engine](https://docs.docker.com/engine/install/#server).
You can find instructions for installing `containerd` at
[Starting Containerd](https://containerd.io/docs/getting-started/#starting-containerd).


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
```
### For windows powershell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider splitting this into two task pages, one for Linux nodes and one for Windows nodes.


Start a Powershell session, set `$Version` to the desired version (ex: `$Version=1.4.3`),
and then run the following commands:

1. Download containerd:

```powershell
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
```

2. Extract and configure:

```powershell
Copy-Item -Path ".\bin\" -Destination "$Env:ProgramFiles\containerd" -Recurse -Force
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:
# - 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
Add-MpPreference -ExclusionProcess "$Env:ProgramFiles\containerd\containerd.exe"
```
Copy link
Contributor

@MadhavJivrajani MadhavJivrajani Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I usually prefer each command to typically be its own code section (unless relevant commands can be grouped in order for the text description to explain things more effectively) with a description above it and the comments can be put as text and not as comments.
    • Please use this for reference.
  • # (Optional - but highly recommended) Exclude containerd from Windows Defender Scans: Please describe why this is recommended.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This piece of code block has also been taken from the documentation here https://github.com/kubernetes/website/blob/main/content/en/docs/setup/production-environment/container-runtimes.md#container-runtimes, but yes I will add more descriptions to make this more clear and if required separately group them.


3. Start containerd:

```powershell
.\containerd.exe --register-service
Start-Service containerd
```
- configure kubelet to use containerd
Edit the file `/var/lib/kubelet/kubeadm-flags.env` and add the containerd runtime to the flags. `--container-runtime=remote` and `--container-runtimeendpoint=unix:///run/containerd/containerd.sock"`
Debanitrkl marked this conversation as resolved.
Show resolved Hide resolved

- restart kubelet
`systemctl start kubelet`

- verify pods are running
Run `kubectl get nodes -o wide` and containerd appears as the runtime for the node we just changed.
Copy link
Contributor

@MadhavJivrajani MadhavJivrajani Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- configure kubelet to use containerd
Edit the file `/var/lib/kubelet/kubeadm-flags.env` and add the containerd runtime to the flags. `--container-runtime=remote` and `--container-runtimeendpoint=unix:///run/containerd/containerd.sock"`

This is not rendered on separate lines if that was your original intent. And same for the ones below and above it as well.


- finally if everything goes well remove docker
```
apt purge docker-ce docker-ce-cli
OR
yum remove docker-ce docker-ce-cli
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Is this still under Windows Powershell?
  • Not sure if the OR here is the right way to go about it. Maybe a separate code section?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try this myself took it from the reference here https://kruyt.org/migrate-docker-containerd-kubernetes/. Also, I guess given the formatting style of this doc a separate code section would be better

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use https://kubernetes.io/docs/contribute/style/hugo-shortcodes/#tabs and have a tab for Debian-heritage systems and another for RedHat-heritage systems.