Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

containerd #427

Merged
merged 54 commits into from
Jun 16, 2021
Merged

containerd #427

merged 54 commits into from
Jun 16, 2021

Conversation

steiler
Copy link
Collaborator

@steiler steiler commented May 25, 2021

start implementing containerd runtime for containerlab.
Work in progress.

@steiler
Copy link
Collaborator Author

steiler commented May 28, 2021

Status:

  • Containers
    • containerd Namespaces
      containerd uses "namespaces" read "views",
      to allow for multi tenancy, containerlab utilizes the "clab" namespace.
  • Containerlab Operations
    • ContainerCreate
      • Feature:
        • sysctl
        • labels
        • container user
        • cmd
        • Environment variables
        • hostname
        • elevated priviledges
        • mounts
        • networking
          • host mode
          • specify MAC-address for mgmt
          • port bindings
          • MTU
    • ContainerStart
    • ContainerDelete
    • ContainerStop
    • ContainerList
    • ContainerInspect
      • Not required right now. So far returned GenericContainer with just PID populated. Refactored also docker runtime such that PID is populated in container list on container create.
    • Exec
    • ExecNotWait
    • PullImageIfRequired
  • Network
    • DeleteNet
    • CreateNet
    • SetMgmtNet

Quickstart

The cli tool for containerd is ctl. To get started you need to import the SRLinux image into the clab namespace into containerd.

Import SRLinux image

# create namespace
#   might be omitted if you've started containerlab already
ctr namespace create clab
# decompress the SRLinux image
xzcat 21.3.2-129.tar.xz > 21.3.2-129.tar
# import it into containerd clab namespace
ctr -n clab images import /tmp/21.3.2-129.tar
# retag the imported image, since it is imported as "docker.io/library/srlinux:21.3.2-129"
ctr -n clab images tag docker.io/library/srlinux:21.3.2-129 srlinux:21.3.2-129 srlinux:latest
# remove the "docker.io/library"-based tag
ctr -n clab images rm docker.io/library/srlinux:21.3.2-129

Now you're good to use clab with the -r containerd knob.

Usefull commands

List Containers

ctr -n clab containers ls

show OCI spec of container

ctr -n clab containers info <CONTAINERNAME>

show tasks (running container init processes)

ctr -n clab tasks ls

show snapshots

ctr -n clab snapshot ls

@steiler
Copy link
Collaborator Author

steiler commented Jun 11, 2021

@hellt
We should check for entrypoint and cmd in the multitool image.

If I'm using the nginx image all works fine:
docker.io/library/nginx:latest

If using the ghcr.io/hellt/network-multitool:latest image, the oci.WithImageConfig(img), yields /docker-entrypoint bash as the cmd to execute in the container ....
adjusting the cmd in the topology file works fine.

    linux:
      image: ghcr.io/hellt/network-multitool:latest
      cmd: /docker-entrypoint.sh nginx -g 'daemon off;'`

Not sure yet if this is about the image or what it is, since the official nginx image works fine.

clab/srl.go Outdated Show resolved Hide resolved
cmd/inspect.go Show resolved Hide resolved
cmd/destroy.go Outdated Show resolved Hide resolved
@hellt hellt marked this pull request as ready for review June 15, 2021 15:23
@hellt
Copy link
Member

hellt commented Jun 15, 2021

@steiler let's add one check for CNI binaries to be present at /opt/cni/bin
after that it is ok to let @karimra maybe have a look at it =)

@steiler
Copy link
Collaborator Author

steiler commented Jun 16, 2021

@karimra happy for you to take over and review now.

@steiler
Copy link
Collaborator Author

steiler commented Jun 16, 2021

pulled GetCNIBinaryPath() into utils package, such that it can be used by other runtimes as well.

clab/clab.go Outdated Show resolved Hide resolved
clab/config.go Outdated Show resolved Hide resolved
clab/clab.go Outdated Show resolved Hide resolved
cmd/exec.go Outdated Show resolved Hide resolved
runtime/containerd/containerd.go Outdated Show resolved Hide resolved
runtime/containerd/containerd.go Outdated Show resolved Hide resolved
runtime/containerd/containerd.go Outdated Show resolved Hide resolved
runtime/containerd/containerd.go Outdated Show resolved Hide resolved
runtime/containerd/containerd.go Outdated Show resolved Hide resolved
runtime/containerd/containerd.go Outdated Show resolved Hide resolved
clab/clab.go Outdated Show resolved Hide resolved
@hellt
Copy link
Member

hellt commented Jun 16, 2021

thanks @steiler for the initial work and @karimra for a review!

let's merge it and test the regular docker runtime from the master build to check if those touches to a non containerd code didn't break in some edge cases

@hellt hellt merged commit 417a7b9 into srl-labs:master Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants