Skip to content

Commit c822fc9

Browse files
milantracygvisor-bot
authored andcommitted
Update gVisor's containerd quick start.
Adding ctr instructions for an easier verification. PiperOrigin-RevId: 733017114
1 parent 0c17600 commit c822fc9

File tree

1 file changed

+68
-8
lines changed

1 file changed

+68
-8
lines changed

g3doc/user_guide/containerd/quick_start.md

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,77 @@ version = 2
3434
EOF
3535
```
3636

37-
Restart `containerd`:
37+
> Consider using the version header `version = 3` if you are using containerd
38+
> 2.x. See the difference at
39+
> [containerd version header](https://github.com/containerd/containerd/blob/v2.0.2/docs/PLUGINS.md#version-header)
40+
41+
### Install CNI plugins
42+
43+
Typically, you will have to install CNI plugins to complete the following steps.
44+
45+
For the quick start, it is sufficient to install the plugins with default
46+
settings by running the script from the containerd project:
47+
48+
```shell
49+
git clone --depth=1 -b {CONTAINERD_VERSION} https://github.com/containerd/containerd.git
50+
cd containerd && ./script/setup/install-cni
51+
```
52+
53+
### Restart `containerd`
3854

3955
```shell
4056
sudo systemctl restart containerd
4157
```
4258

4359
## Usage
4460

45-
You can run containers in gVisor via containerd's CRI.
61+
You can run containers in gVisor via [ctr] or [crictl].
62+
63+
[ctr]: https://github.com/projectatomic/containerd/blob/master/docs/cli.md
64+
[crictl]: https://github.com/kubernetes-sigs/cri-tools/blob/master/docs/crictl.md
65+
66+
### ctr
67+
68+
The tool `ctr` communicates directly with containerd, and it is a part of each
69+
containerd release.
70+
71+
#### Running a container
72+
73+
Now run your container using the runsc runtime:
74+
75+
```shell
76+
sudo ctr image pull docker.io/library/hello-world:latest
77+
sudo ctr run --runtime io.containerd.runsc.v1 -t --rm docker.io/library/hello-world:latest hello-wrold
78+
```
79+
80+
#### Verify the runtime
81+
82+
You can verify that you are running in gVisor using the dmesg command.
83+
84+
```shell
85+
$ sudo ctr image pull docker.io/library/busybox:latest
86+
$ sudo ctr run --runtime io.containerd.run.runsc.v1 -t --rm docker.io/library/busybox:latest gvisord dmesg
87+
[ 0.000000] Starting gVisor...
88+
[ 0.445958] Forking spaghetti code...
89+
[ 0.794963] Feeding the init monster...
90+
[ 0.842573] Synthesizing system calls...
91+
[ 0.985066] Generating random numbers by fair dice roll...
92+
[ 1.444465] Mounting deweydecimalfs...
93+
[ 1.546130] Waiting for children...
94+
[ 1.689078] Searching for socket adapter...
95+
[ 2.026282] Accelerating teletypewriter to 9600 baud...
96+
[ 2.274752] Creating process schedule...
97+
[ 2.498083] Reticulating splines...
98+
[ 2.675603] Setting up VFS...
99+
[ 2.750186] Setting up FUSE...
100+
[ 2.789133] Ready!
101+
```
102+
103+
### crictl
104+
105+
Alternatively, you can use crictl which designed for CRI-compatible containers.
46106

47-
### Install crictl
107+
#### Install crictl
48108

49109
Download and install the `crictl` binary:
50110

@@ -64,7 +124,7 @@ runtime-endpoint: unix:///run/containerd/containerd.sock
64124
EOF
65125
```
66126

67-
### Create the nginx sandbox in gVisor
127+
#### Create the nginx sandbox in gVisor
68128

69129
Pull the nginx image:
70130

@@ -96,7 +156,7 @@ Create the pod in gVisor:
96156
SANDBOX_ID=$(sudo crictl runp --runtime runsc sandbox.json)
97157
```
98158

99-
### Run the nginx container in the sandbox
159+
#### Run the nginx container in the sandbox
100160

101161
Create the nginx container creation request:
102162

@@ -128,7 +188,7 @@ Start the nginx container:
128188
sudo crictl start ${CONTAINER_ID}
129189
```
130190

131-
### Validate the container
191+
#### Validate the container
132192

133193
Inspect the created pod:
134194

@@ -148,7 +208,7 @@ Verify that nginx is running in gVisor:
148208
sudo crictl exec ${CONTAINER_ID} dmesg | grep -i gvisor
149209
```
150210

151-
### Set up the Kubernetes RuntimeClass
211+
#### Set up the Kubernetes RuntimeClass
152212

153213
Install the RuntimeClass for gVisor:
154214

@@ -184,7 +244,7 @@ Verify that the Pod is running:
184244
kubectl get pod nginx-gvisor -o wide
185245
```
186246

187-
## What's next
247+
### What's next
188248

189249
This setup is already done for you on [GKE Sandbox]. It is an easy way to get
190250
started with gVisor.

0 commit comments

Comments
 (0)