End to end tests refs #3 (#10)

* Separate docs for containerd 1.1 and 1.2

The configuration for the untrusted workload annotation and runtime
class are different enough that it makes sense to separate the docs.

Commands in docs are taken from scripts in the docs/scripts directory.
These scripts can be used later for integration & doc tests (#3). The
docs can be updated using the embedmd tool:
https://github.com/campoy/embedmd

* Add basic e2e tests refs #3

Added end-to-end tests based on the quickstart workflows for
containerd 1.1 and containerd 1.2+.
This commit is contained in:
Ian Lewis
2019-01-14 23:41:01 -08:00
committed by Lantao Liu
parent 9e0866102b
commit bd2940861c
17 changed files with 791 additions and 113 deletions
+26
View File
@@ -0,0 +1,26 @@
dist: trusty
sudo: required
language: go
go: "1.11.x"
env:
- CONTAINERD_VERSION=1.1.5 RUNSC_VERSION=2018-12-07 TEST=untrusted-workload
- CONTAINERD_VERSION=1.2.1 RUNSC_VERSION=2018-12-07 TEST=untrusted-workload
- CONTAINERD_VERSION=1.2.1 RUNSC_VERSION=2018-12-07 TEST=runtime-handler
go_import_path: github.com/google/gvisor-containerd-shim
addons:
apt:
packages:
- socat
- conntrack
- ipset
before_install:
- uname -r
- sudo apt-get -q update
- sudo apt-get install -y libseccomp-dev/trusty-backports
script: ./test/e2e/${TEST}/test.sh
+8 -113
View File
@@ -1,125 +1,20 @@
# gvisor-containerd-shim
[![Build Status](https://travis-ci.org/google/gvisor-containerd-shim.svg?branch=master)](https://travis-ci.org/google/gvisor-containerd-shim)
[![Go Report Card](https://goreportcard.com/badge/github.com/google/gvisor-containerd-shim)](https://goreportcard.com/report/github.com/google/gvisor-containerd-shim)
gvisor-containerd-shim is a containerd shim for [gVisor](https://github.com/google/gvisor/). It implements the containerd v1 shim API. It can be used as a drop-in replacement for [containerd-shim](https://github.com/containerd/containerd/tree/master/cmd/containerd-shim) (though containerd-shim must still be installed). It allows the use of both gVisor (runsc) and normal containers in the same containerd installation by deferring to the runc shim if the desired runtime engine is not runsc.
## Requirements
- gvisor (runsc) >= a2ad8fe
- gvisor (runsc) >= 2018-12-07
- containerd, containerd-shim >= 1.1
## Installation
1. Download the latest release of the gvisor-containerd-shim and unpack the binary to the desired directory:
- [Untrusted Workload Quick Start (containerd >=1.1)](docs/untrusted-workload-quickstart.md)
- [Runtime Handler Quick Start (containerd >=1.2)](docs/runtime-handler-quickstart.md)
```
$ tar xf gvisor-containerd-shim.tar.gz
$ mv gvisor-containerd-shim /usr/local/bin
```
# Contributing
2. Create the configuration for the gvisor shim in `/etc/containerd/gvisor-containerd-shim.yaml`:
```
# This is the path to the default runc containerd-shim.
runc_shim = "/path/to/containerd-shim"
```
3. Update `/etc/containerd/config.toml`. Be sure to update the path to `gvisor-containerd-shim` and `runsc` if necessary:
```
disabled_plugins = ["restart"]
[plugins.linux]
shim = "/usr/local/bin/gvisor-containerd-shim"
shim_debug = true
# Uncomment the following 2 lines if you want runsc to be the default runtime.
# runtime = "/usr/local/bin/runsc"
# runtime_root = "/run/containerd/runsc"
# To support the untrusted-workload annotation.
[plugins.cri.containerd.untrusted_workload_runtime]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = "/usr/local/bin/runsc"
runtime_root = "/run/containerd/runsc"
[plugins.cri.containerd.runtimes.runsc]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = "/usr/local/bin/runsc"
runtime_root = "/run/containerd/runsc"
```
4. Restart `containerd`
## Usage
### CRI
You can run containers in gVisor via containerd's CRI.
1. Build and install crictl from HEAD:
```
$ go get github.com/kubernetes-sigs/cri-tools/cmd/crictl
$ sudo sh -c 'echo "runtime-endpoint: unix:///run/containerd/containerd.sock" > /etc/crictl.yaml'
```
2. Pull the busybox image
```
$ sudo crictl pull busybox
```
### Containerd 1.1
If running containerd 1.1 you will need to invoke `runsc` via the `io.kubernetes.cri.untrusted-workload` annotation.
1. Create a pod config:
```
$ cat > sandbox.json << EOL
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"annotations": {
"io.kubernetes.cri.untrusted-workload": "true"
},
"linux": {
},
"log_directory": "/tmp"
}
EOL
```
2. Run a sandbox with the `runsc` runtime.
```
$ sudo crictl runp sandbox.json
```
### Containerd 1.2
If running containerd 1.2 you can specify runsc as the runtime using the new runtime handler.
1. Create a pod config:
```
$ cat > sandbox.json << EOL
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {
},
"log_directory": "/tmp"
}
EOL
```
2. Run a sandbox with the `runsc` runtime.
```
$ sudo crictl runp --runtime=runsc sandbox.json
```
See [CONTRIBUTING.md](CONTRIBUTING.md).
+6
View File
@@ -0,0 +1,6 @@
# gvisor-containerd-shim docs
Everything you need to know about gvisor-containerd-shim
- [Untrusted Workload Quick Start (containerd >=1.1)](untrusted-workload-quickstart.md)
- [Runtime Handler Quick Start (containerd >=1.2)](runtime-handler-quickstart.md)
+214
View File
@@ -0,0 +1,214 @@
# Runtime Handler Quickstart
This document describes how to install and run the `gvisor-containerd-shim`
using the containerd runtime handler support. This requires containerd 1.2 or
later.
## Requirements
- **runsc**: See the [gVisor documentation](https://github.com/google/gvisor) for information on how to install runsc.
- **containerd**: See the [containerd website](https://containerd.io/) for information on how to install containerd.
## Install
### Install gvisor-containerd-shim
1. Download the latest release of the `gvisor-containerd-shim`. See the
[releases page](https://github.com/google/gvisor-containerd-shim/releases)
[embedmd]:# (../test/e2e/shim-install.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Download gvisor-containerd-shim
LATEST_RELEASE=$(wget -qO - https://api.github.com/repos/google/gvisor-containerd-shim/releases | grep -oP '(?<="browser_download_url": ")https://[^"]*' | head -1)
wget -O gvisor-containerd-shim
chmod +x gvisor-containerd-shim
}
```
2. Copy the binary to the desired directory:
[embedmd]:# (../test/e2e/shim-install.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Copy the binary to the desired directory
sudo mv gvisor-containerd-shim-* /usr/local/bin/gvisor-containerd-shim
}
```
3. Create the configuration for the gvisor shim in
`/etc/containerd/gvisor-containerd-shim.yaml`:
[embedmd]:# (../test/e2e/shim-install.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Create the gvisor-containerd-shim.yaml
cat <<EOF | sudo tee /etc/containerd/gvisor-containerd-shim.yaml
# This is the path to the default runc containerd-shim.
runc_shim = "/usr/local/bin/containerd-shim"
EOF
}
```
### Configure containerd
1. Update `/etc/containerd/config.toml`. Be sure to update the path to
`gvisor-containerd-shim` and `runsc` if necessary:
[embedmd]:# (../test/e2e/runtime-handler/install.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Create containerd config.toml
cat <<EOF | sudo tee /etc/containerd/config.toml
disabled_plugins = ["restart"]
[plugins.linux]
shim = "/usr/local/bin/gvisor-containerd-shim"
shim_debug = true
[plugins.cri.containerd.runtimes.runsc]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = "/usr/local/bin/runsc"
runtime_root = "/run/containerd/runsc"
EOF
}
```
2. Restart `containerd`
```shell
sudo systemctl restart containerd
```
## Usage
You can run containers in gVisor via containerd's CRI.
### Install crictl
1. Download and install the crictl binary:
[embedmd]:# (../test/e2e/crictl-install.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Download crictl
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.13.0/crictl-v1.13.0-linux-amd64.tar.gz
tar xf crictl-v1.13.0-linux-amd64.tar.gz
sudo mv crictl /usr/local/bin
}
```
2. Write the crictl configuration file
[embedmd]:# (../test/e2e/crictl-install.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Configure crictl
cat <<EOF | sudo tee /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
EOF
}
```
### Create the nginx Sandbox in gVisor
1. Pull the nginx image
[embedmd]:# (../test/e2e/runtime-handler/usage.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Pull the nginx image
sudo crictl pull nginx
}
```
2. Create the sandbox creation request
[embedmd]:# (../test/e2e/runtime-handler/usage.sh shell /{ # Step 2/ /^EOF\n}/)
```shell
{ # Step 2: Create sandbox.json
cat <<EOF | tee sandbox.json
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {
},
"log_directory": "/tmp"
}
EOF
}
```
3. Create the pod in gVisor
[embedmd]:# (../test/e2e/runtime-handler/usage.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Create the sandbox
SANDBOX_ID=$(sudo crictl runp --runtime runsc sandbox.json)
}
```
### Run the nginx Container in the Sandbox
1. Create the nginx container creation request
[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 1/ /^EOF\n}/)
```shell
{ # Step 1: Create nginx container config
cat <<EOF | tee container.json
{
"metadata": {
"name": "nginx"
},
"image":{
"image": "nginx"
},
"log_path":"nginx.0.log",
"linux": {
}
}
EOF
}
```
2. Create the nginx container
[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Create nginx container
CONTAINER_ID=$(sudo crictl create ${SANDBOX_ID} container.json sandbox.json)
}
```
3. Start the nginx container
[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Start nginx container
sudo crictl start ${CONTAINER_ID}
}
```
### Validate the container
1. Inspect the created pod
[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Inspect the pod
sudo crictl inspectp ${SANDBOX_ID}
}
```
2. Inspect the nginx container
[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Inspect the container
sudo crictl inspect ${CONTAINER_ID}
}
```
3. Verify that nginx is running in gVisor
[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Check dmesg
sudo crictl exec ${CONTAINER_ID} dmesg | grep -i gvisor
}
```
+220
View File
@@ -0,0 +1,220 @@
# Untrusted Workload Quickstart
This document describes how to install and run the `gvisor-containerd-shim`
using the untrusted workload CRI extension. This requires containerd 1.1 or
later.
*Note: The untrusted workload CRI extension is deprecated by containerd. If you
are using containerd 1.2, please consider using runtime handler.*
## Requirements
- **runsc**: See the [gVisor documentation](https://github.com/google/gvisor) for information on how to install runsc.
- **containerd**: See the [containerd website](https://containerd.io/) for information on how to install containerd.
## Install
### Install gvisor-containerd-shim
1. Download the latest release of the `gvisor-containerd-shim`. See the
[releases page](https://github.com/google/gvisor-containerd-shim/releases)
[embedmd]:# (../test/e2e/shim-install.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Download gvisor-containerd-shim
LATEST_RELEASE=$(wget -qO - https://api.github.com/repos/google/gvisor-containerd-shim/releases | grep -oP '(?<="browser_download_url": ")https://[^"]*' | head -1)
wget -O gvisor-containerd-shim
chmod +x gvisor-containerd-shim
}
```
2. Copy the binary to the desired directory:
[embedmd]:# (../test/e2e/shim-install.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Copy the binary to the desired directory
sudo mv gvisor-containerd-shim-* /usr/local/bin/gvisor-containerd-shim
}
```
3. Create the configuration for the gvisor shim in
`/etc/containerd/gvisor-containerd-shim.yaml`:
[embedmd]:# (../test/e2e/shim-install.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Create the gvisor-containerd-shim.yaml
cat <<EOF | sudo tee /etc/containerd/gvisor-containerd-shim.yaml
# This is the path to the default runc containerd-shim.
runc_shim = "/usr/local/bin/containerd-shim"
EOF
}
```
### Configure containerd
1. Update `/etc/containerd/config.toml`. Be sure to update the path to
`gvisor-containerd-shim` and `runsc` if necessary:
[embedmd]:# (../test/e2e/untrusted-workload/install.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Create containerd config.toml
cat <<EOF | sudo tee /etc/containerd/config.toml
disabled_plugins = ["restart"]
[plugins.linux]
shim = "/usr/local/bin/gvisor-containerd-shim"
shim_debug = true
[plugins.cri.containerd.untrusted_workload_runtime]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = "/usr/local/bin/runsc"
runtime_root = "/run/containerd/runsc"
EOF
}
```
2. Restart `containerd`
```shell
sudo systemctl restart containerd
```
## Usage
You can run containers in gVisor via containerd's CRI.
### Install crictl
1. Download and install the crictl binary:
[embedmd]:# (../test/e2e/crictl-install.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Download crictl
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.13.0/crictl-v1.13.0-linux-amd64.tar.gz
tar xf crictl-v1.13.0-linux-amd64.tar.gz
sudo mv crictl /usr/local/bin
}
```
2. Write the crictl configuration file
[embedmd]:# (../test/e2e/crictl-install.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Configure crictl
cat <<EOF | sudo tee /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
EOF
}
```
### Create the nginx Sandbox in gVisor
1. Pull the nginx image
[embedmd]:# (../test/e2e/untrusted-workload/usage.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Pull the nginx image
sudo crictl pull nginx
}
```
2. Create the sandbox creation request
[embedmd]:# (../test/e2e/untrusted-workload/usage.sh shell /{ # Step 2/ /^EOF\n}/)
```shell
{ # Step 2: Create sandbox.json
cat <<EOF | tee sandbox.json
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"annotations": {
"io.kubernetes.cri.untrusted-workload": "true"
},
"linux": {
},
"log_directory": "/tmp"
}
EOF
}
```
3. Create the pod in gVisor
[embedmd]:# (../test/e2e/untrusted-workload/usage.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Create the sandbox
SANDBOX_ID=$(sudo crictl runp sandbox.json)
}
```
### Run the nginx Container in the Sandbox
1. Create the nginx container creation request
[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 1/ /^EOF\n}/)
```shell
{ # Step 1: Create nginx container config
cat <<EOF | tee container.json
{
"metadata": {
"name": "nginx"
},
"image":{
"image": "nginx"
},
"log_path":"nginx.0.log",
"linux": {
}
}
EOF
}
```
2. Create the nginx container
[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Create nginx container
CONTAINER_ID=$(sudo crictl create ${SANDBOX_ID} container.json sandbox.json)
}
```
3. Start the nginx container
[embedmd]:# (../test/e2e/run-container.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Start nginx container
sudo crictl start ${CONTAINER_ID}
}
```
### Validate the container
1. Inspect the created pod
[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 1/ /^}/)
```shell
{ # Step 1: Inspect the pod
sudo crictl inspectp ${SANDBOX_ID}
}
```
2. Inspect the nginx container
[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 2/ /^}/)
```shell
{ # Step 2: Inspect the container
sudo crictl inspect ${CONTAINER_ID}
}
```
3. Verify that nginx is running in gVisor
[embedmd]:# (../test/e2e/validate.sh shell /{ # Step 3/ /^}/)
```shell
{ # Step 3: Check dmesg
sudo crictl exec ${CONTAINER_ID} dmesg | grep -i gvisor
}
```
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
# A script to install containerd and CNI plugins for e2e testing
wget -q --https-only \
https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz \
https://github.com/containernetworking/plugins/releases/download/v0.6.0/cni-plugins-amd64-v0.6.0.tgz
sudo mkdir -p /etc/containerd /etc/cni/net.d /opt/cni/bin
sudo tar -xvf cni-plugins-amd64-v0.6.0.tgz -C /opt/cni/bin/
sudo tar -xvf containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz -C /
cat <<EOF | sudo tee /etc/cni/net.d/10-bridge.conf
{
"cniVersion": "0.3.1",
"name": "bridge",
"type": "bridge",
"bridge": "cnio0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"ranges": [
[{"subnet": "10.200.0.0/24"}]
],
"routes": [{"dst": "0.0.0.0/0"}]
}
}
EOF
cat <<EOF | sudo tee /etc/cni/net.d/99-loopback.conf
{
"cniVersion": "0.3.1",
"type": "loopback"
}
EOF
sudo PATH=$PATH containerd -log-level debug &> /tmp/containerd-cri.log &
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# A sample script for installing crictl.
set -ex
{ # Step 1: Download crictl
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.13.0/crictl-v1.13.0-linux-amd64.tar.gz
tar xf crictl-v1.13.0-linux-amd64.tar.gz
sudo mv crictl /usr/local/bin
}
{ # Step 2: Configure crictl
cat <<EOF | sudo tee /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
EOF
}
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
# A sample script to run a container in an existing pod
set -ex
{ # Step 1: Create nginx container config
cat <<EOF | tee container.json
{
"metadata": {
"name": "nginx"
},
"image":{
"image": "nginx"
},
"log_path":"nginx.0.log",
"linux": {
}
}
EOF
}
{ # Step 2: Create nginx container
CONTAINER_ID=$(sudo crictl create ${SANDBOX_ID} container.json sandbox.json)
}
{ # Step 3: Start nginx container
sudo crictl start ${CONTAINER_ID}
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
# Sample script to install runsc
wget -q --https-only \
https://storage.googleapis.com/gvisor/releases/nightly/${RUNSC_VERSION}/runsc
chmod +x runsc
sudo mv runsc /usr/local/bin/
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
# A sample script for installing and configuring the gvisor-containerd-shim to
# use the containerd runtime handler.
set -ex
{ # Step 1: Create containerd config.toml
cat <<EOF | sudo tee /etc/containerd/config.toml
disabled_plugins = ["restart"]
[plugins.linux]
shim = "/usr/local/bin/gvisor-containerd-shim"
shim_debug = true
[plugins.cri.containerd.runtimes.runsc]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = "/usr/local/bin/runsc"
runtime_root = "/run/containerd/runsc"
EOF
}
{ # Step 2: Restart containerd
sudo pkill containerd
sudo containerd -log-level debug &> /tmp/containerd-cri.log &
}
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Runs end-to-end tests for gvisor-containerd-shim to test the use of runtime
# handler. This should work on containerd 1.2+
# This is meant to be run in a VM as it makes a fairly invasive install of
# containerd.
set -ex
# Install containerd
. ./test/e2e/containerd-install.sh
# Install gVisor
. ./test/e2e/runsc-install.sh
# Install gvisor-containerd-shim
. ./test/e2e/shim-install.sh
# Test installation/configuration
. ./test/e2e/runtime-handler/install.sh
# Install crictl
. ./test/e2e/crictl-install.sh
# Test usage
. ./test/e2e/runtime-handler/usage.sh
# Run a container in the sandbox
. ./test/e2e/run-container.sh
# Validate the pod and container
. ./test/e2e/validate.sh
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
# A sample script for testing the gvisor-containerd-shim # using untrusted
# workload extension.
set -ex
{ # Step 1: Pull the nginx image
sudo crictl pull nginx
}
{ # Step 2: Create sandbox.json
cat <<EOF | tee sandbox.json
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {
},
"log_directory": "/tmp"
}
EOF
}
{ # Step 3: Create the sandbox
SANDBOX_ID=$(sudo crictl runp --runtime runsc sandbox.json)
}
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
# A sample script to install gvisor-containerd-shim
set -ex
# Build gvisor-containerd-shim
if [ "${INSTALL_LATEST}" === "1" ]; then
{ # Step 1: Download gvisor-containerd-shim
LATEST_RELEASE=$(wget -qO - https://api.github.com/repos/google/gvisor-containerd-shim/releases | grep -oP '(?<="browser_download_url": ")https://[^"]*' | head -1)
wget -O gvisor-containerd-shim
chmod +x gvisor-containerd-shim
}
else
make
mv bin/gvisor-containerd-shim gvisor-containerd-shim-dev
fi
{ # Step 2: Copy the binary to the desired directory
sudo mv gvisor-containerd-shim-* /usr/local/bin/gvisor-containerd-shim
}
{ # Step 3: Create the gvisor-containerd-shim.yaml
cat <<EOF | sudo tee /etc/containerd/gvisor-containerd-shim.yaml
# This is the path to the default runc containerd-shim.
runc_shim = "/usr/local/bin/containerd-shim"
EOF
}
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
# A sample script for installing and configuring the gvisor-containerd-shim to
# use the untrusted workload extension.
set -ex
{ # Step 1: Create containerd config.toml
cat <<EOF | sudo tee /etc/containerd/config.toml
disabled_plugins = ["restart"]
[plugins.linux]
shim = "/usr/local/bin/gvisor-containerd-shim"
shim_debug = true
[plugins.cri.containerd.untrusted_workload_runtime]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = "/usr/local/bin/runsc"
runtime_root = "/run/containerd/runsc"
EOF
}
{ # Step 2: Restart containerd
sudo pkill containerd
sudo containerd -log-level debug &> /tmp/containerd-cri.log &
}
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Runs end-to-end tests for gvisor-containerd-shim to test using the
# untrusted workload extension. This should work on containerd 1.1+
# This is meant to be run in a VM as it makes a fairly invasive install of
# containerd.
set -ex
# Install containerd
. ./test/e2e/containerd-install.sh
# Install gVisor
. ./test/e2e/runsc-install.sh
# Install gvisor-containerd-shim
. ./test/e2e/shim-install.sh
# Test installation/configuration
. ./test/e2e/untrusted-workload/install.sh
# Install crictl
. ./test/e2e/crictl-install.sh
# Test usage
. ./test/e2e/untrusted-workload/usage.sh
# Run a container in the sandbox
. ./test/e2e/run-container.sh
# Validate the pod and container
. ./test/e2e/validate.sh
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# A sample script for testing the gvisor-containerd-shim # using untrusted
# workload extension.
set -ex
{ # Step 1: Pull the nginx image
sudo crictl pull nginx
}
{ # Step 2: Create sandbox.json
cat <<EOF | tee sandbox.json
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"annotations": {
"io.kubernetes.cri.untrusted-workload": "true"
},
"linux": {
},
"log_directory": "/tmp"
}
EOF
}
{ # Step 3: Create the sandbox
SANDBOX_ID=$(sudo crictl runp sandbox.json)
}
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# A sample script to validate a running nginx container.
set -ex
{ # Step 1: Inspect the pod
sudo crictl inspectp ${SANDBOX_ID}
}
{ # Step 2: Inspect the container
sudo crictl inspect ${CONTAINER_ID}
}
{ # Step 3: Check dmesg
sudo crictl exec ${CONTAINER_ID} dmesg | grep -i gvisor
}