@@ -34,17 +34,77 @@ version = 2
34
34
EOF
35
35
```
36
36
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 `
38
54
39
55
``` shell
40
56
sudo systemctl restart containerd
41
57
```
42
58
43
59
## Usage
44
60
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.
46
106
47
- ### Install crictl
107
+ #### Install crictl
48
108
49
109
Download and install the ` crictl ` binary:
50
110
@@ -64,7 +124,7 @@ runtime-endpoint: unix:///run/containerd/containerd.sock
64
124
EOF
65
125
```
66
126
67
- ### Create the nginx sandbox in gVisor
127
+ #### Create the nginx sandbox in gVisor
68
128
69
129
Pull the nginx image:
70
130
@@ -96,7 +156,7 @@ Create the pod in gVisor:
96
156
SANDBOX_ID=$( sudo crictl runp --runtime runsc sandbox.json)
97
157
```
98
158
99
- ### Run the nginx container in the sandbox
159
+ #### Run the nginx container in the sandbox
100
160
101
161
Create the nginx container creation request:
102
162
@@ -128,7 +188,7 @@ Start the nginx container:
128
188
sudo crictl start ${CONTAINER_ID}
129
189
```
130
190
131
- ### Validate the container
191
+ #### Validate the container
132
192
133
193
Inspect the created pod:
134
194
@@ -148,7 +208,7 @@ Verify that nginx is running in gVisor:
148
208
sudo crictl exec ${CONTAINER_ID} dmesg | grep -i gvisor
149
209
```
150
210
151
- ### Set up the Kubernetes RuntimeClass
211
+ #### Set up the Kubernetes RuntimeClass
152
212
153
213
Install the RuntimeClass for gVisor:
154
214
@@ -184,7 +244,7 @@ Verify that the Pod is running:
184
244
kubectl get pod nginx-gvisor -o wide
185
245
```
186
246
187
- ## What's next
247
+ ### What's next
188
248
189
249
This setup is already done for you on [ GKE Sandbox] . It is an easy way to get
190
250
started with gVisor.
0 commit comments