diff --git a/containers/containerd.md b/containers/containerd.md new file mode 100644 index 0000000..d06820e --- /dev/null +++ b/containers/containerd.md @@ -0,0 +1,62 @@ +# Installing containerd + nerdctl +This guide installs latest versions (RC) of containerd, runc and nerdctl + +https://github.com/containerd/containerd/releases/tag/v2.0.0-rc.4 +https://github.com/containerd/nerdctl/releases/tag/v2.0.0-rc.1 +https://github.com/opencontainers/runc/releases/tag/v1.2.0-rc.3 +https://github.com/containernetworking/plugins/releases/tag/v1.5.1 + +#### Step 1: Installing containerd +Download https://github.com/containerd/containerd/releases/download/v2.0.0-rc.4/containerd-2.0.0-rc.4-linux-amd64.tar.gz +```sh +wget https://github.com/containerd/containerd/releases/download/v2.0.0-rc.4/containerd-2.0.0-rc.4-linux-amd64.tar.gz +``` +Extract it under `/usr/local` +```sh +sudo tar Cxzvf /usr/local containerd-2.0.0-rc.4-linux-amd64.tar.gz +``` +#### Setup systemd +Download the containerd.service unit file from +https://raw.githubusercontent.com/containerd/containerd/main/containerd.service +into /etc/systemd/system/containerd.service + +```shell +wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service +sudo mv containerd.service /etc/systemd/system/containerd.service +sudo systemctl daemon-reload +sudo systemctl enable --now containerd +``` + +#### Step 2: Installing runc + +Download the `runc.amd64` binary from https://github.com/opencontainers/runc/releases/download/v1.2.0-rc.3/runc.amd64 and install it in `/usr/local/sbin`. + +```shell +wget https://github.com/opencontainers/runc/releases/download/v1.2.0-rc.3/runc.amd64 +``` + +```shell +sudo install -m 755 runc.amd64 /usr/local/sbin/runc +``` + +#### Step 3: Installing cni plugins +Download https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz and extract it under `/opt/cni/bin` + +```shell +wget https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz +``` + +```shell +sudo mkdir -p /opt/cni/bin +sudo tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.5.1.tgz +``` + +#### Step 3: Installing nerdctl +Download https://github.com/containerd/nerdctl/releases/download/v2.0.0-rc.1/nerdctl-2.0.0-rc.1-linux-amd64.tar.gz and extract it under `/usr/local/bin` +```shell +wget https://github.com/containerd/nerdctl/releases/download/v2.0.0-rc.1/nerdctl-2.0.0-rc.1-linux-amd64.tar.gz +``` + +```shell +sudo tar Cxzvf /usr/local/bin nerdctl-2.0.0-rc.1-linux-amd64.tar.gz +``` diff --git a/containers/grpc_demo/README.md b/containers/grpc_demo/README.md new file mode 100644 index 0000000..a8bae39 --- /dev/null +++ b/containers/grpc_demo/README.md @@ -0,0 +1,16 @@ +# containerd gRPC example + +This relies on https://github.com/siemens/pycontainerd +```sh +pip3 install containerd +``` + +```shell +sudo env/bin/python apps/pilot/containers/grpc_demo/example.py +``` +You should see something like +```shell +namespace: default +``` + +Note: You'll need sudo here because `/run/containerd/containerd.sock` is accessible to root. rootless containers might solve this problem, but we'll ignore that problem for now. \ No newline at end of file diff --git a/containers/grpc_demo/example.py b/containers/grpc_demo/example.py new file mode 100644 index 0000000..b94440f --- /dev/null +++ b/containers/grpc_demo/example.py @@ -0,0 +1,8 @@ +import grpc +from containerd.services.namespaces.v1 import namespace_pb2, namespace_pb2_grpc + +with grpc.insecure_channel("unix:///run/containerd/containerd.sock") as channel: + namespacev1 = namespace_pb2_grpc.NamespacesStub(channel) + namespaces = namespacev1.List(namespace_pb2.ListNamespacesRequest()).namespaces + for namespace in namespaces: + print("namespace:", namespace.name) diff --git a/pyproject.toml b/pyproject.toml index 4d678c0..7959bb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ dependencies = [ # Terraform CDKTF dependencies "cdktf==0.20.8", "cdktf-cdktf-provider-digitalocean==11.5.2", + "containerd==1.5.3", ] [build-system]