diff --git a/Developer-Guide.md b/Developer-Guide.md index 56cd2ffc..b1fddff6 100644 --- a/Developer-Guide.md +++ b/Developer-Guide.md @@ -24,6 +24,15 @@ * [Troubleshoot Kata Containers](#troubleshoot-kata-containers) * [Appendices](#appendices) * [Checking Docker default runtime](#checking-docker-default-runtime) + * [Setting up a debug console](#setting-up-a-debug-console) + * [Create a custom image containing a shell](#create-a-custom-image-containing-a-shell) + * [Create a debug systemd service](#create-a-debug-systemd-service) + * [Build the debug image](#build-the-debug-image) + * [Configure runtime for custom debug image](#configure-runtime-for-custom-debug-image) + * [Ensure debug options are valid](#ensure-debug-options-are-valid) + * [Create a container](#create-a-container) + * [Connect to the virtual machine using the debug console](#connect-to-the-virtual-machine-using-the-debug-console) + * [Obtain details of the image](#obtain-details-of-the-image) # Warning @@ -277,6 +286,8 @@ To perform analysis on Kata logs, use the [`kata-log-parser`](https://github.com/kata-containers/tests/tree/master/cmd/log-parser) tool. +See also [Setting up a debug console](#setting-up-a-debug-console). + # Appendices ## Checking Docker default runtime @@ -284,3 +295,122 @@ tool. ``` $ sudo docker info 2>/dev/null | grep -i "default runtime" | cut -d: -f2- | grep -q runc && echo "SUCCESS" || echo "ERROR: Incorrect default Docker runtime" ``` + +## Setting up a debug console + +By default, it is not possible to login to a virtual machine since this could +be sensitive from a security perspective. However it also requires additional +packages in the rootfs which means the image used to boot each virtual machine +would be larger. + +If you wish to be able to login to a virtual machine that hosts your +containers, follow the steps below which assume a rootfs image. + +### Create a custom image containing a shell + +To be able to login to a virtual machine, you must [create a custom +rootfs](#create-a-rootfs-image) containing a shell such as `bash(1)`. + +For example using CentOS: + +``` +$ cd $GOPATH/src/github.com/kata-containers/osbuilder/rootfs-builder +$ export ROOTFS_DIR=${GOPATH}/src/github.com/kata-containers/osbuilder/rootfs-builder/rootfs +$ script -fec 'sudo -E GOPATH=$GOPATH USE_DOCKER=true EXTRA_PKGS="bash" ./rootfs.sh centos' +``` + +### Create a debug systemd service + +Create the service file that will start the shell in the rootfs directory: + +``` +$ cat < /tmp/configuration.toml +$ sudo install /tmp/configuration.toml /usr/share/defaults/kata-containers/configuration.toml +``` + +### Create a container + +Create a container as normal. For example using Docker: + +``` +$ sudo docker run -ti busybox sh +``` + +### Connect to the virtual machine using the debug console + +``` +$ id=$(sudo docker ps -q --no-trunc) +$ console="/var/run/vc/sbs/${id}/console.sock" +$ sudo socat "stdin,raw,echo=0,escape=0x11" "unix-connect:${console}" +``` + +**Note**: You need to press the `RETURN` key to see the shell prompt. + +To disconnect from the virtual machine, type `CONTROL+q` (hold down the +`CONTROL` key and press `q`). + +### Obtain details of the image + +If the image was created using +[osbuilder](https://github.com/kata-containers/osbuilder), the following YAML +file will exist and contain details of the image and how it was created: + +``` +$ cat /var/lib/osbuilder/osbuilder.yaml +```