Skip to content

Instantly share code, notes, and snippets.

@Filirom1
Created December 5, 2017 13:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Filirom1/df6bc4ad205c1ea9473817e014686913 to your computer and use it in GitHub Desktop.
Save Filirom1/df6bc4ad205c1ea9473817e014686913 to your computer and use it in GitHub Desktop.
CRI-O and CRI-Containerd

Install Golang

On a fresh CentOS 7.4, as root:

yum install -y golang git wget

Install crictl

export GOPATH=~/go
export PATH=$PATH:/usr/local/bin/
go get github.com/kubernetes-incubator/cri-tools/cmd/crictl
cp $GOPATH/bin/crictl /usr/local/bin/

Install CNI

go get -d github.com/containernetworking/plugins
cd $GOPATH/src/github.com/containernetworking/plugins
./build.sh
mkdir -p /opt/cni/bin
cp bin/* /opt/cni/bin/
mkdir -p /etc/cni/net.d
sh -c 'cat >/etc/cni/net.d/10-mynet.conf <<-EOF
{
    "cniVersion": "0.2.0",
    "name": "mynet",
    "type": "bridge",
    "bridge": "cni0",
    "isGateway": true,
    "ipMasq": true,
    "ipam": {
        "type": "host-local",
        "subnet": "10.88.0.0/16",
        "routes": [
            { "dst": "0.0.0.0/0"  }
        ]
    }
}
EOF'
sh -c 'cat >/etc/cni/net.d/99-loopback.conf <<-EOF
{
    "cniVersion": "0.2.0",
    "type": "loopback"
}
EOF'

Install cri-o

yum install -y   btrfs-progs-devel   device-mapper-devel   git   glib2-devel   glibc-devel   glibc-static   go   golang-github-cpuguy83-go-md2man   gpgme-devel   libassuan-devel   libgpg-error-devel   libseccomp-devel   libselinux-devel   ostree-devel   pkgconfig   runc   skopeo-containers
go get -d github.com/kubernetes-incubator/cri-o
cd $GOPATH/src/github.com/kubernetes-incubator/cri-o
make install.tools
make
make install
make install.config
sed -i 's/registries = \[/registries = \["docker.io"/g' /etc/crio/crio.conf

Install containerd

cd /tmp
wget https://github.com/containerd/containerd/releases/download/v1.0.0-rc.0/containerd-1.0.0-rc.0.linux-amd64.tar.gz
tar xvzf containerd-1.0.0-rc.0.linux-amd64.tar.gz
cp bin/* /usr/local/bin/

Install cri-containerd

go get -d github.com/kubernetes-incubator/cri-containerd
cd $GOPATH/src/github.com/kubernetes-incubator/cri-containerd
make install.deps
make BUILD_TAGS='seccomp selinux'
make install

Start CRI-O

echo "runtime-endpoint: /var/run/crio/crio.sock" > /etc/crictl.yaml
crio &
WARN[2017-12-04 23:21:31.938501250Z] devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev`.
WARN[2017-12-04 23:21:31.955877965Z] devmapper: Base device already exists and has filesystem xfs on it. User specified filesystem  will be ignored.
INFO[2017-12-04 23:21:31.970102575Z] [graphdriver] using prior storage driver: devicemapper
WARN[2017-12-04 23:21:31.970312653Z] hooks path: "/usr/share/containers/oci/hooks.d" does not exist
WARN[2017-12-04 23:21:31.970327775Z] hooks path: "/etc/containers/oci/hooks.d" does not exist
INFO[2017-12-04 23:21:31.970533006Z] CNI network mynet (type=bridge) is used from /etc/cni/net.d/10-mynet.conf
INFO[2017-12-04 23:21:31.970701986Z] CNI network mynet (type=bridge) is used from /etc/cni/net.d/10-mynet.conf

Run containers with crictl on CRI-O

crictl pull redis:alpine
Image is update to date for docker.io/library/redis:alpine

crictl images
IMAGE                     TAG                 IMAGE ID            SIZE
docker.io/library/redis   alpine              3c04ff817393e       26.9MB

cd $GOPATH/src/github.com/kubernetes-incubator/cri-o
POD_ID=$(crictl runs test/testdata/sandbox_config.json)
CONTAINER_ID=$(crictl create $POD_ID test/testdata/container_redis.json test/testdata/sandbox_config.json)
crictl start $CONTAINER_ID
fb82734f8eb6bd6ef3a2ac56deb076160db2be122e9aaaa94b1e1f20b764a1e9
crictl ps $CONTAINER_ID
CONTAINER ID        IMAGE                            CREATED             STATE               NAME                ATTEMPT
fb82734f8eb6b       docker.io/library/redis:alpine   11 seconds ago      CONTAINER_RUNNING   podsandbox1-redis   0

Start Containerd and CRI-Containerd

containerd &
echo "runtime-endpoint: /var/run/cri-containerd.sock" > /etc/crictl.yaml
cri-containerd &

Run containers with crictl on CRI-Containerd

crictl pull redis:alpine
Image is update to date for sha256:ba3df185d5ea4cae3b5da690301605ac96199732bab4edf46f7bafec43dbcb1f
crictl images
IMAGE                     TAG                 IMAGE ID            SIZE
docker.io/library/redis   alpine              ba3df185d5ea4       10.1MB

cd $GOPATH/src/github.com/kubernetes-incubator/cri-o
POD_ID=$(crictl runs test/testdata/sandbox_config.json)
CONTAINER_ID=$(crictl create $POD_ID test/testdata/container_redis.json test/testdata/sandbox_config.json)
crictl start $CONTAINER_ID
d94bf519cf7ffcacf6c689250592d0718b98d7a030d73329349d29dc560e4998
crictl ps $CONTAINER_ID
CONTAINER ID        IMAGE               CREATED             STATE               NAME                ATTEMPT
d94bf519cf7ff       redis:alpine        5 seconds ago       CONTAINER_RUNNING   podsandbox1-redis   0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment