ambikanair
ambikanair

Reputation: 4590

How to create sandbox using crictl

I am following Run a pod sandbox link to create a sandbox using crictl. I am getting below error

root@cri-master:~# crictl runs sandbox-config.json
FATA[0000] run pod sandbox failed: rpc error: code = Unknown desc =failed to setup network for sandbox     "3ad790c715c817d22e6f6df95bf612dbc0ceaf05d2d94f94e62aa4b57234ea57": pods "nginx-sandbox" not found 

Please could someone tell me what is being done wrong here

Upvotes: 3

Views: 5961

Answers (1)

ambikanair
ambikanair

Reputation: 4590

So I posted same question in the cri-containerd github issue and I got this answer. This explains everything

Unable to create sandbox

IIRC, calico daemonset watch apiserver to get a list of pods, and apply network configuration based on the pod spec. I think this is the problem.

If you use crictl create a sandbox yourself, there won't be corresponding pod on apiserver, thus calico reports that error.

In fact, we don't recommend user to run crictl runs and crictl create on a Kubernetes node , those commands are there just for some special debug case. And that's also why we make the command so hard to use (user need to prepare for a configuration file to create a sandbox/container).

In fact, even if you are able to create the sandbox, kubelet will eventually stop and delete it because it doesn't see the corresponding pod on apiserver.

If you just want to try crictl, the error is caused by the reason above.
If you just want to try create a pod, use kubectl instead. :)

Upvotes: 5

Related Questions