|
| 1 | +# Kata Containers with ACRN |
| 2 | + |
| 3 | +This document provides an overview on how to run Kata containers with ACRN hypervisor and device model. |
| 4 | + |
| 5 | +- [Introduction](#introduction) |
| 6 | +- [Pre-requisites](#pre-requisites) |
| 7 | +- [Install and Configure Docker](#install-and-configure-docker) |
| 8 | +- [Configure Kata Containers with ACRN](#configure-kata-containers-with-acrn) |
| 9 | + |
| 10 | +## Introduction |
| 11 | + |
| 12 | +ACRN is a flexible, lightweight Type-1 reference hypervisor built with real-time and safety-criticality in mind. ACRN uses an open source platform making it optimized to streamline embedded development. |
| 13 | + |
| 14 | +Some of the key features being: |
| 15 | + |
| 16 | +- Small footprint - Approx. 25K lines of code (LOC). |
| 17 | +- Real Time - Low latency, faster boot time, improves overall responsiveness with hardware. |
| 18 | +- Adaptability - Multi-OS support for guest operating systems like Linux, Android, RTOSes. |
| 19 | +- Rich I/O mediators - Allows sharing of various I/O devices across VMs. |
| 20 | +- Optimized for a variety of IoT (Internet of Things) and embedded device solutions. |
| 21 | + |
| 22 | +Please refer to ACRN [documentation](https://projectacrn.github.io/latest/index.html) for more details on ACRN hypervisor and device model. |
| 23 | + |
| 24 | +## Pre-requisites |
| 25 | + |
| 26 | +This document requires the presence of the ACRN hypervisor and Kata Containers on your system. Install using the instructions available through the following links: |
| 27 | + |
| 28 | +- ACRN supported [Hardware](https://projectacrn.github.io/latest/hardware.html#supported-hardware). |
| 29 | +- ACRN [software](https://projectacrn.github.io/latest/getting-started/apl-nuc.html#use-the-script-to-set-up-acrn-automatically) setup. |
| 30 | +- Kata Containers installation: Automated installation does not seem to be supported for Clear Linux, so please use [manual installation](https://github.com/kata-containers/documentation/blob/master/Developer-Guide.md) steps. |
| 31 | + |
| 32 | +> **Note:** Create rootfs image and not initrd image. |
| 33 | +
|
| 34 | +In order to run Kata with ACRN, your container stack must provide block-based storage, such as device-mapper. |
| 35 | + |
| 36 | +> **Note:** Currently, you can only launch one VM from Kata Containers using ACRN hypervisor (SDC scenario) due to [this issue](https://github.com/kata-containers/runtime/issues/1785). |
| 37 | +
|
| 38 | +## Install and Configure Docker |
| 39 | + |
| 40 | +Install Docker 18.06 (as Docker 18.09 does not support device-mapper). To configure Docker for device-mapper and Kata, |
| 41 | + |
| 42 | +1. Stop Docker daemon if it is already running. |
| 43 | + |
| 44 | +```bash |
| 45 | +$ sudo systemctl stop docker |
| 46 | +``` |
| 47 | + |
| 48 | +2. Set `/etc/docker/daemon.json` with the following contents. |
| 49 | + |
| 50 | +``` |
| 51 | +{ |
| 52 | + "storage-driver": "devicemapper" |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +3. Restart docker. |
| 57 | + |
| 58 | +```bash |
| 59 | +$ sudo systemctl daemon-reload |
| 60 | +$ sudo systemctl restart docker |
| 61 | +``` |
| 62 | + |
| 63 | +4. Configure [Docker](https://github.com/kata-containers/documentation/blob/master/Developer-Guide.md#update-the-docker-systemd-unit-file) to use `kata-runtime`. |
| 64 | + |
| 65 | +## Configure Kata Containers with ACRN |
| 66 | + |
| 67 | +To configure Kata Containers with ACRN, copy the generated `configuration-acrn.toml` file when building the `kata-runtime` to either `/etc/kata-containers/configuration.toml` or `/usr/share/defaults/kata-containers/configuration.toml`. |
| 68 | + |
| 69 | +The following command shows full paths to the `configuration.toml` files that the runtime loads. It will use the first path that exists. (Please make sure the kernel and image paths are set correctly in the `configuration.toml` file) |
| 70 | + |
| 71 | +```bash |
| 72 | +$ sudo kata-runtime --kata-show-default-config-paths |
| 73 | +``` |
| 74 | + |
| 75 | +>**Warning:** Please offline CPUs using [this](offline_cpu.sh) script, else VM launches will fail. |
| 76 | +
|
| 77 | +```bash |
| 78 | +$ sudo ./offline_cpu.sh |
| 79 | +``` |
| 80 | + |
| 81 | +Start an ACRN based Kata Container, |
| 82 | + |
| 83 | +```bash |
| 84 | +$ sudo docker run -ti --runtime=kata-runtime busybox sh |
| 85 | +``` |
| 86 | + |
| 87 | +You will see ACRN(`acrn-dm`) is now running on your system, as well as a `kata-shim`, `kata-proxy`. You should obtain an interactive shell prompt. Verify that all the Kata processes terminate once you exit the container. |
| 88 | + |
| 89 | +```bash |
| 90 | +$ ps -ef | grep -E "kata|acrn" |
| 91 | +``` |
| 92 | + |
| 93 | +Validate ACRN hypervisor by using `kata-runtime kata-env`, |
| 94 | + |
| 95 | +```sh |
| 96 | +$ kata-runtime kata-env | awk -v RS= '/\[Hypervisor\]/' |
| 97 | +[Hypervisor] |
| 98 | + MachineType = "" |
| 99 | + Version = "DM version is: 1.2-unstable-254577a6-dirty (daily tag:acrn-2019w27.4-140000p) |
| 100 | + Path = "/usr/bin/acrn-dm" |
| 101 | + BlockDeviceDriver = "virtio-blk" |
| 102 | + EntropySource = "/dev/urandom" |
| 103 | + Msize9p = 0 |
| 104 | + MemorySlots = 10 |
| 105 | + Debug = false |
| 106 | + UseVSock = false |
| 107 | + SharedFS = "" |
| 108 | +``` |
0 commit comments