Skip to content

Commit

Permalink
docs: Add containerd install guide
Browse files Browse the repository at this point in the history
Create a containerd installation guide.

Fixes: kata-containers#738.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Sep 16, 2020
1 parent 059e642 commit f831a95
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions docs/install/containerd/containerd-install-guide.md
@@ -0,0 +1,99 @@
# Install Kata Containers with containerd

1. Perform initial checks

Check to see if Kata Containers is already installed:

```bash
$ command -v kata-runtime &>/dev/null && { echo >&2 "ERROR: Please remove existing Kata Containers installation"; exit 1; }
```

1. Install dependencies

```bash
$ source /etc/os-release || source /usr/lib/os-release
$ packages='containerd curl git jq'
$ case "$ID" in
$ debian|ubuntu) sudo apt-get -y install $packages ;;
$ *) echo >&2 "ERROR: Unsupported distro: $ID"; exit 1 ;;
$ esac
```
1. Install Kata Containers
```bash
$ tmpdir=$(mktemp -d)
$ pushd "$tmpdir" &>/dev/null
$ url="https://api.github.com/repos/kata-containers/runtime/releases/latest"
$ full_url=$(curl -sL "$url" | jq -r '.assets[0].browser_download_url')
$ arch=$(uname -m)
$ echo "$full_url" | grep -q "$arch" || { echo >&2 "ERROR: No Kata Containers package for $arch architecture"; exit 1; }
$ curl -LO "$full_url"
$ file=$(echo "$full_url" | awk -F\/ '{print $NF}')
$ sudo tar -C / -xvf "./${file}"
$ popd &>/dev/null
```
Show version details:
```bash
$ export PATH=$PATH:/opt/kata/bin
$ kata-runtime --version
```
1. Configure containerd
Stop the service to allow the configuration to be modified:
```bash
$ sudo systemctl stop containerd
```
Backup the original containerd configuration:
```bash
$ cfg="/etc/containerd/config.toml"
$ sudo grep -q "io.containerd.kata.v2" "$cfg" || sudo cp "$cfg" "${cfg}.ORIGINAL"
```
Add the Kata Containers configuration details:
```bash
$ sudo grep -q "io.containerd.kata.v2" "$cfg" || cat <<EOT | sudo tee -a "$cfg"
$ [plugins]
$ [plugins.cri]
$ [plugins.cri.containerd]
no_pivot = false
default_runtime_name = "kata"
[plugins.cri.containerd.runtimes.kata]
runtime_type = "io.containerd.kata.v2"
$ [plugins.linux]
$ shim = "/usr/bin/containerd-shim"
$ shim_debug = true
$ EOT
```
Allow the containerd service to find the Kata shim:
```bash
$ sudo ln -sf /opt/kata/bin/containerd-shim-kata-v2 /usr/bin/
```
Restart the service:
```bash
$ sudo systemctl restart containerd
```
1. Run Kata Containers
You are now ready to run Kata Containers:
```bash
$ image="docker.io/library/busybox:latest"
$ sudo ctr image pull "$image"
$ sudo ctr run --runtime "io.containerd.kata.v2" --rm -t "$image" test-kata uname -m
```
The previous command shows details of the kernel version running inside the
container, which is different to the host kernel version.

0 comments on commit f831a95

Please sign in to comment.