Skip to content

Nick-Triller/toycni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toycni

A minimal CNI implemented for a meetup presentation. The slides are available here.

Build

Compile toycni for linux:

make build

Demo setup

make demo-setup creates two Ubuntu VMs using multipass and initializes a two node cluster with kubeadm. cloud-init is used to prepare the VMs (install packages etc.).

A kubeconfig for the cluster within the VMs is placed at demo/kubeconfig. Execute the following command to point kubectl at the kubeconfig file:

export KUBECONFIG="$(pwd)/demo/kubeconfig"

Important filesystem locations within the VMs:

  • toycni logs are written to /var/log/toycni.
  • CNI plugin binaries are stored in /opt/cni/bin/.
  • Allocated IP addresses are stored as files in /var/lib/cni/networks/toycni/.
  • CNI config is stored at /etc/cni/net.d/10-toycni.conf.

The VMs can be deleted with make demo-cleanup.

Invoking toycni manually

# Get a shell in the VM
multipass shell node01

# Create network namespace
ip netns add testing

# CNI ADD command
cat /etc/cni/net.d/10-toycni.conf | CNI_COMMAND=ADD CNI_CONTAINERID=testing123 CNI_NETNS=/var/run/netns/testing \
    CNI_IFNAME=eth0 CNI_PATH=/opt/cni/bin /opt/cni/bin/toycni /var/ns/testing

# CNI DEL command
cat /etc/cni/net.d/10-toycni.conf | CNI_COMMAND=DEL CNI_CONTAINERID=testing123 CNI_NETNS=/var/run/netns/testing \
    CNI_IFNAME=eth0 CNI_PATH=/opt/cni/bin /opt/cni/bin/toycni /var/ns/testing

# Delete network namespace
ip netns del testing

About

Demo CNI implementation for a meetup talk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published