Understanding CNI (Container Network Interface) - laying out the essential bits

Understanding CNI (Container Network Interface) - laying out the essential bits

Is CNI, a piece of software or just a set of standard rules?

It's both. But to some, it may not be very straight forward from the way that is put in the readme here.

So if CNI is also a piece of software, how does the Container Runtime Engine use it to communicate with a CNI Plugin?

No alt text provided for this image
credits: https://www.youtube.com/watch?v=YWXucnygGmY

That's where the library called libcni comes into picture. This is the library that allows the container runtime engine to interact with the CNI plugin through a set standard set of verbs namely ADD, DEL, CHECK and VERSION.

While it has been abundantly mentioned that both the container engine and the CNI plugin communicate through a JSON specification file (as illustrated above), we've never had the convenience of directly being told that:

it (libcni) is typically bundled into runtime providers (i.e. containerd or cri-o would use this before calling runc or hcsshim).?It is also bundled into CNI providers (CNI plugins) as well, for example, to add an IP to a container, to parse the configuration of the CNI and so on.

unless, of course, one had the fortitude to go all the way into repository files and unlock the wisdom preserved within the comments.

Yet, none of the above information can explain one thing - How does the containe engine know where to access the CNI plugin?

Going through some documentations, eventually, I could figure that there are generally two main paths where the Container Engine finds its plugins by default, namely:

/opt/cni/bin and /etc/cni/net.d        

Take the case of the EKS Cluster which uses containerd (as the container engine) and vpc-cni (as the CNI plugin). In the readme for vpc-cni, it's instructed to ensure the above mentioned default paths are set against certain kubelet parameters concerning CNI.

Similarly, going through the amazon-eks-ami files, it does look like containerd is directed to look into the same paths for operations concerning the CNI plugin.

Here're some screenshots, for a quick peak or incase, the links are broken:

No alt text provided for this image
from the vpc-cni- repo


No alt text provided for this image
from Amazon EKS AMI repo

So, I believe it's possibly accurate to assume that the container engine simply makes calls to the plugin executables present in directories within the set path (/opt/cni/bin) without concerning itself with the exact choice of the plugin.

And similarly, the CNI plugins perform the various network operations based on the specified configurations within the configured path (/etc/cni/net.d) regardless of the runtime engine.

Thanks for reading so far any corrections anywhere in this article if needed are welcome.



要查看或添加评论,请登录

Vishak Arudhra的更多文章

  • Understanding CNI Part 2 (Container Network Interface)

    Understanding CNI Part 2 (Container Network Interface)

    This time, we pick up from where the last article concludes in Part 1 which should be enough to understand, on a…

  • Service Discovery With Consul

    Service Discovery With Consul

    There are several challenges faced with a traditional load balancer setup and Service Discovery and Mesh can solve them…

  • Euclid to RSA - Asymmetric Encryption

    Euclid to RSA - Asymmetric Encryption

    At the foundation of RSA are discoveries of popular mathematicians whose formulas shall be discussed with practical…

    2 条评论
  • Golang Aesthetic Notes #7

    Golang Aesthetic Notes #7

    How Methods differ from Functions Methods defined for pointer receivers also work for 'value' type variables Say…

  • Golang Aesthetic Notes #6

    Golang Aesthetic Notes #6

    Passing Functions as Values Concept of functions as values is really as simple as passing values into function. For e.

  • Golang Aesthetic Notes #5

    Golang Aesthetic Notes #5

    When a variable already representing a memory location is assigned with a new value what happens to that memory…

  • Golang Aesthetic Notes #4

    Golang Aesthetic Notes #4

    Deferring (and Loops) Exploring the part of the tutorial on 'Deferring'. I also got to understand a little better about…

    3 条评论
  • Golang Aesthetic Notes #3

    Golang Aesthetic Notes #3

    while loop is just 'hacked' for - loop Reference For e.g.

  • Golang Aesthetic Notes #2

    Golang Aesthetic Notes #2

    Links to Basics: https://go.dev/doc/tutorial/getting-started Format Verbs: Symbols used in print commands such as %v or…

  • Golang Aesthetic Notes #1

    Golang Aesthetic Notes #1

    Golang for the beginner. So I just started learning.

社区洞察

其他会员也浏览了