containerd, crictl, ctr

608 views
Skip to first unread message

Justin Hopper

unread,
Dec 10, 2020, 3:11:13 PM12/10/20
to Flatcar Container Linux User
Hello,

I'm sure this will be a question that comes up a lot as Kubernetes uses switch away from Docker and to just containerd.  Most documentation references crictl for interacting with container runtimes, and I had been used to using that after leaving the docker cli.  However, just recently I noticed that ctr was there and ships with containerd. Why use crictl when there's ctr, I thought?

Well, the first problem I see, that must simply be a misconfiguration on my end, is that while crictl properly lists images and pods, ctr gives me nothing.  All while talking to the same containerd socket.

cat /etc/crictl.yaml 
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: true

crictl version
DEBU[0000] VersionRequest: &VersionRequest{Version:v1alpha2,} 
DEBU[0000] VersionResponse: &VersionResponse{Version:0.1.0,RuntimeName:containerd,RuntimeVersion:v1.4.1,RuntimeApiVersion:v1alpha2,} 
Version:  0.1.0
RuntimeName:  containerd
RuntimeVersion:  v1.4.1
RuntimeApiVersion:  v1alpha2

/opt/bin/ctr version
Client:
  Version:  v1.4.1
  Revision: c623d1b36f09f8ef6536a057bd658b3aa8632828
  Go version: go1.13.15

Server:
  Version:  v1.4.1
  Revision: c623d1b36f09f8ef6536a057bd658b3aa8632828
  UUID: 3afdd32d-747d-4ef3-b051-41922ff6afb0

ctr says the default socket location is, correctly: /run/containerd/containerd.sock

But doing a simple image list with ctr returns:
/opt/bin/ctr images ls
REF TYPE DIGEST SIZE PLATFORMS LABELS

But yet with crictl:
crictl images
DEBU[0000] <...snip> 
IMAGE                                TAG                 IMAGE ID            SIZE
k8s.gcr.io/coredns                   1.6.7               67da37a9a360e       13.6MB
k8s.gcr.io/etcd                      3.4.3-0             303ce5db0e90d       101MB
k8s.gcr.io/kube-apiserver            v1.18.9             e9585e7d08492       51.1MB
<...snip>

Having no experience with ctr prior to this, I'm thinking something is misconfigured for it, but I'm not sure what?  Also, interesting that ctr supports listing containers, but crictl only supports listing by pods, so it's of note that they don't seem to provide the same functionality.

Thanks,
Justin

Rodrigo Campos

unread,
Dec 11, 2020, 6:52:40 AM12/11/20
to Justin Hopper, Flatcar Container Linux User
On Thu, Dec 10, 2020 at 9:11 PM Justin Hopper <justin....@gmail.com> wrote:
>
> Well, the first problem I see, that must simply be a misconfiguration on my end, is that while crictl properly lists images and pods, ctr gives me nothing. All while talking to the same containerd socket.

containerd uses namespaces. Images, containers, etc. created via the
CRI are in one namespace (usually it is called k8s.io IIRC).

> But doing a simple image list with ctr returns:
> /opt/bin/ctr images ls
> REF TYPE DIGEST SIZE PLATFORMS LABELS
>

If you list the namespaces with cri, then choose the one about
kubernetes and list the images as you did, but specifying the
namespace, you will see them there :)


Rodrigo Campos
---
Kinvolk GmbH | Adalbertstr.6a, 10999 Berlin | tel: +491755589364
Geschäftsführer/Directors: Alban Crequy, Chris Kühl, Iago López Galeiras
Registergericht/Court of registration: Amtsgericht Charlottenburg
Registernummer/Registration number: HRB 171414 B
Ust-ID-Nummer/VAT ID number: DE302207000
Reply all
Reply to author
Forward
0 new messages