Skip to content

Instantly share code, notes, and snippets.

@jodh-intel
Last active January 25, 2018 16:42
Show Gist options
  • Save jodh-intel/c7c2f154fcdefcf316d7d29bdf940e1a to your computer and use it in GitHub Desktop.
Save jodh-intel/c7c2f154fcdefcf316d7d29bdf940e1a to your computer and use it in GitHub Desktop.
Running Kata Containers with the Clear Containers runtime

See the newer instructions here:


Assumptions

  • You already have Clear Containers and Docker installed.

Build & install Kata proxy

go get -d github.com/kata-containers/proxy
cd $GOPATH/src/github.com/kata-containers/proxy && make && sudo make install

Build and install Kata shim

go get -d github.com/kata-containers/shim
cd $GOPATH/src/github.com/kata-containers/shim && make && sudo make install

Build & install Clear Containers runtime for Kata

go get -d github.com/clearcontainers/runtime
cd $GOPATH/src/github.com/clearcontainers/runtime && make build-kata-system && sudo make install-kata-system

Enable full debug

sudo sed -i -e 's/^# *\(enable_debug\).*=.*$/\1 = true/g' /usr/share/defaults/kata-containers/configuration.toml

Create an image

Build the Kata agent

go get -d github.com/kata-containers/agent
cd $GOPATH/src/github.com/kata-containers/agent && make

Get the osbuilder

go get -d github.com/kata-containers/osbuilder

Create a rootfs image

cd $GOPATH/src/github.com/kata-containers/osbuilder/rootfs-builder
script -fec 'sudo -E GOPATH=$GOPATH ./rootfs.sh clearlinux USE_DOCKER=true'

Add the agent to the image

sudo install -m 0755 -o root -g root -t rootfs/bin ../../agent/kata-agent
sudo install -m 0444 ../../agent/kata-containers.target rootfs/usr/lib/systemd/system/
sudo install -m 0444 ../../agent/kata-containers.target rootfs/usr/lib/systemd/system/

Build the image

cd $GOPATH/src/github.com/kata-containers/osbuilder/image-builder
script -fec 'sudo ./image_builder.sh ../rootfs-builder/rootfs'

Install the image

commit=$(git log --format=%h -1 HEAD)
date=$(date +%Y-%m-%d-%T.%N%z)

image="kata-containers-${date}-${commit}"
sudo install -o root -g root -m 0640 -D kata-containers.img "/usr/share/kata-containers/${image}"
(cd /usr/share/kata-containers && sudo rm -f kata-containers.img && sudo ln -s "$image" kata-containers.img)

Install guest kernel images

sudo cp /usr/share/clear-containers/vmlinu*.container /usr/share/kata-containers/

Update Docker config

sudo sed -i 's!^\(ExecStart=[^$].*$\)!\1 --add-runtime kata-runtime=/usr/local/bin/kata-runtime!g' /etc/systemd/system/docker.service.d/clear-containers.conf

Test

sudo docker run -ti --runtime kata-runtime busybox sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment