|
| 1 | +# Runtime Handler Quickstart (Shim V2) |
| 2 | + |
| 3 | +This document describes how to install and run `containerd-shim-runsc-v1` using |
| 4 | +the containerd runtime handler support. This requires containerd 1.2 or later. |
| 5 | + |
| 6 | +## Requirements |
| 7 | + |
| 8 | +- **runsc**: See the [gVisor documentation](https://github.com/google/gvisor) for information on how to install runsc. |
| 9 | +- **containerd**: See the [containerd website](https://containerd.io/) for information on how to install containerd. |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | +### Install containerd-shim-runsc-v1 |
| 14 | + |
| 15 | +1. Build and install `containerd-shim-runsc-v1`. |
| 16 | + |
| 17 | +<!-- TODO: Use a release once we have one available. --> |
| 18 | +[embedmd]:# (../test/e2e/shim-install.sh shell /{ # Step 1\(dev\)/ /^}/) |
| 19 | +```shell |
| 20 | +{ # Step 1(dev): Build and install gvisor-containerd-shim and containerd-shim-runsc-v1 |
| 21 | + make |
| 22 | + sudo make install |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +### Configure containerd |
| 27 | + |
| 28 | +1. Update `/etc/containerd/config.toml`. Make sure `containerd-shim-runsc-v1` is |
| 29 | + in `${PATH}`. |
| 30 | + |
| 31 | +[embedmd]:# (../test/e2e/runtime-handler-shim-v2/install.sh shell /{ # Step 1/ /^}/) |
| 32 | +```shell |
| 33 | +{ # Step 1: Create containerd config.toml |
| 34 | +cat <<EOF | sudo tee /etc/containerd/config.toml |
| 35 | +disabled_plugins = ["restart"] |
| 36 | +[plugins.linux] |
| 37 | + shim_debug = true |
| 38 | +[plugins.cri.containerd.runtimes.runsc] |
| 39 | + runtime_type = "io.containerd.runsc.v1" |
| 40 | +EOF |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +2. Restart `containerd` |
| 45 | + |
| 46 | +```shell |
| 47 | +sudo systemctl restart containerd |
| 48 | +``` |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +You can run containers in gVisor via containerd's CRI. |
| 53 | + |
| 54 | +### Install crictl |
| 55 | + |
| 56 | +1. Download and install the crictl binary: |
| 57 | + |
| 58 | +[embedmd]:# (../test/e2e/crictl-install.sh shell /{ # Step 1/ /^}/) |
| 59 | +```shell |
| 60 | +{ # Step 1: Download crictl |
| 61 | +wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.13.0/crictl-v1.13.0-linux-amd64.tar.gz |
| 62 | +tar xf crictl-v1.13.0-linux-amd64.tar.gz |
| 63 | +sudo mv crictl /usr/local/bin |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +2. Write the crictl configuration file |
| 68 | + |
| 69 | +[embedmd]:# (../test/e2e/crictl-install.sh shell /{ # Step 2/ /^}/) |
| 70 | +```shell |
| 71 | +{ # Step 2: Configure crictl |
| 72 | +cat <<EOF | sudo tee /etc/crictl.yaml |
| 73 | +runtime-endpoint: unix:///run/containerd/containerd.sock |
| 74 | +EOF |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +### Create the nginx Sandbox in gVisor |
| 79 | + |
| 80 | +1. Pull the nginx image |
| 81 | + |
| 82 | +[embedmd]:# (../test/e2e/runtime-handler/usage.sh shell /{ # Step 1/ /^}/) |
| 83 | +```shell |
| 84 | +{ # Step 1: Pull the nginx image |
| 85 | +sudo crictl pull nginx |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +2. Create the sandbox creation request |
| 90 | + |
| 91 | +[embedmd]:# (../test/e2e/runtime-handler/usage.sh shell /{ # Step 2/ /^EOF\n}/) |
| 92 | +```shell |
| 93 | +{ # Step 2: Create sandbox.json |
| 94 | +cat <<EOF | tee sandbox.json |
| 95 | +{ |
| 96 | + "metadata": { |
| 97 | + "name": "nginx-sandbox", |
| 98 | + "namespace": "default", |
| 99 | + "attempt": 1, |
| 100 | + "uid": "hdishd83djaidwnduwk28bcsb" |
| 101 | + }, |
| 102 | + "linux": { |
| 103 | + }, |
| 104 | + "log_directory": "/tmp" |
| 105 | +} |
| 106 | +EOF |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +3. Create the pod in gVisor |
| 111 | + |
| 112 | +[embedmd]:# (../test/e2e/runtime-handler/usage.sh shell /{ # Step 3/ /^}/) |
| 113 | +```shell |
| 114 | +{ # Step 3: Create the sandbox |
| 115 | +SANDBOX_ID=$(sudo crictl runp --runtime runsc sandbox.json) |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +### Run the nginx Container in the Sandbox |
| 120 | + |
| 121 | +1. Create the nginx container creation request |
| 122 | + |
| 123 | +[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 1/ /^EOF\n}/) |
| 124 | +```shell |
| 125 | +{ # Step 1: Create nginx container config |
| 126 | +cat <<EOF | tee container.json |
| 127 | +{ |
| 128 | + "metadata": { |
| 129 | + "name": "nginx" |
| 130 | + }, |
| 131 | + "image":{ |
| 132 | + "image": "nginx" |
| 133 | + }, |
| 134 | + "log_path":"nginx.0.log", |
| 135 | + "linux": { |
| 136 | + } |
| 137 | +} |
| 138 | +EOF |
| 139 | +} |
| 140 | +``` |
| 141 | + |
| 142 | +2. Create the nginx container |
| 143 | + |
| 144 | +[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 2/ /^}/) |
| 145 | +```shell |
| 146 | +{ # Step 2: Create nginx container |
| 147 | +CONTAINER_ID=$(sudo crictl create ${SANDBOX_ID} container.json sandbox.json) |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +3. Start the nginx container |
| 152 | + |
| 153 | +[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 3/ /^}/) |
| 154 | +```shell |
| 155 | +{ # Step 3: Start nginx container |
| 156 | +sudo crictl start ${CONTAINER_ID} |
| 157 | +} |
| 158 | +``` |
| 159 | + |
| 160 | +### Validate the container |
| 161 | + |
| 162 | +1. Inspect the created pod |
| 163 | + |
| 164 | +[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 1/ /^}/) |
| 165 | +```shell |
| 166 | +{ # Step 1: Inspect the pod |
| 167 | +sudo crictl inspectp ${SANDBOX_ID} |
| 168 | +} |
| 169 | +``` |
| 170 | + |
| 171 | +2. Inspect the nginx container |
| 172 | + |
| 173 | +[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 2/ /^}/) |
| 174 | +```shell |
| 175 | +{ # Step 2: Inspect the container |
| 176 | +sudo crictl inspect ${CONTAINER_ID} |
| 177 | +} |
| 178 | +``` |
| 179 | + |
| 180 | +3. Verify that nginx is running in gVisor |
| 181 | + |
| 182 | +[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 3/ /^}/) |
| 183 | +```shell |
| 184 | +{ # Step 3: Check dmesg |
| 185 | +sudo crictl exec ${CONTAINER_ID} dmesg | grep -i gvisor |
| 186 | +} |
| 187 | +``` |
0 commit comments