SlideShare a Scribd company logo
Container Network Interface:
Network plugins for Kubernetes
and beyond
Eugene Yakubovich
@eyakubovich
Kubernetes networking model
- IP per pod
- Pods in the cluster can be addressed by their IP
How to network containers together?
- Cloud provider integration
- AWS
- GCE
How to network containers together?
linux-bridge
macvlan
ipvlan
Open vSwitch
Weave
Project Calico
flannel
How to allocate IP addresses?
- From a fixed block on a host
- DHCP
- IPAM system backed by SQL database
- SDN assigned: e.g. Weave
How do you mix and match?
(macvlan | ipvlan) + (DHCP | host-local)
Order matters!
- macvlan + DHCP
○ Create macvlan device
○ Use the device to DHCP
○ Configure device with allocated IP
- Routed + IPAM
○ Ask IPAM for an IP
○ Create veth and routes on host and/or fabric
○ Configure device with allocated IP
Container Runtime (e.g. k8s)
veth macvlan ipvlan OVS
Container Networking Interface (CNI)
CNI
- Container can join multiple networks
- Network described by JSON config
- Plugin supports two commands
- Add container to the network
- Remove container from the network
User configures a network
$ cat /etc/cni/net.d/10-mynet.conf
{
"name": "mynet",
"type": "bridge",
"ipam": {
"type": "host-local",
"subnet": "10.10.0.0/16"
}
}
CNI: Step 1
Container runtime creates network namespace
and gives it a named handle
$ cd /var/lib/cni
$ touch myns
$ unshare -n mount --bind /proc/self/ns/net myns
CNI: Step 2
Container runtime invokes the CNI plugin
$ export CNI_COMMAND=ADD
$ export CNI_NETNS=/var/lib/cni/myns
$ export CNI_CONTAINERID=5248e9f8-3c91-11e5-...
$ export CNI_IFNAME=eth0
$ $CNI_PATH/bridge </etc/cni/net.d/10-mynet.conf
CNI: Step 3
Inside the bridge plugin (1):
$ brctl addbr mynet
$ ip link add veth123 type veth peer name $CNI_IFNAME
$ brctl addif mynet veth123
$ ip link set $CNI_IFNAME netns $CNI_IFNAME
$ ip link set veth123 up
CNI: Step 3
Inside the bridge plugin (2):
$ IPAM_PLUGIN=host-local # from network conf
$ echo $IPAM_PLUGIN
{
"ip4": {
"ip": "10.10.5.9/16",
"gateway": "10.10.0.1"
}
}
CNI: Step 3
Inside the bridge plugin (3):
# switch to container namespace
$ ip addr add 10.0.5.9/16 dev $CNI_IFNAME
# Finally, print IPAM result JSON to stdout
Kubernetes + CNI + Docker
- Kubernetes has its own network plugins
- CNI "driver" is a k8s network plugin
- Future: make CNI native plugin system
Kubernetes + CNI + Docker
- k8s starts "pause" container to create netns
- k8s invokes its plugin (CNI driver)
- k8s CNI driver executes a CNI plugin
- CNI plugin joins "pause" container to network
- Pod containers use "pause" container netns
Kubernetes + rkt
- rkt natively supports CNI
- Kubernetes delegates to rkt to invoke CNI
plugins
Get involved!
https://github.com/appc/cni
Want to work on upstream Kubernetes or
distributed systems infrastructure?
CoreOS San Francisco is hiring.
Work at CoreOS
coreos.com/careers

More Related Content

PDF
Overview of kubernetes network functions
PPTX
Docker introduction
PDF
NGINX Ingress Controller for Kubernetes
PPTX
Introduction to CNI (Container Network Interface)
PPTX
Kubernetes Workshop
PDF
Kubernetes Networking
PDF
DevJam 2019 - Introduction to Kubernetes
Overview of kubernetes network functions
Docker introduction
NGINX Ingress Controller for Kubernetes
Introduction to CNI (Container Network Interface)
Kubernetes Workshop
Kubernetes Networking
DevJam 2019 - Introduction to Kubernetes

What's hot (20)

PDF
Getting Started with Kubernetes
PDF
Kubernetes
PDF
Docker Introduction
ODP
Kubernetes Architecture
PDF
An Introduction to Kubernetes
PDF
cLoki: Like Loki but for ClickHouse
PPTX
Introduction to kubernetes
PDF
Kubernetes Networking with Cilium - Deep Dive
PDF
Ansible
PDF
[KubeCon EU 2022] Running containerd and k3s on macOS
PPTX
Introduction to ansible
PDF
Containerization is more than the new Virtualization: enabling separation of ...
PDF
Rancher 2.0 Technical Deep Dive
PPTX
Docker Container Security
PDF
Monitoring kubernetes with prometheus
PPTX
01. Kubernetes-PPT.pptx
PDF
A la découverte de kubernetes
PPTX
Why Docker
PPTX
Docker, LinuX Container
PPTX
Docker Ecosystem on Azure
Getting Started with Kubernetes
Kubernetes
Docker Introduction
Kubernetes Architecture
An Introduction to Kubernetes
cLoki: Like Loki but for ClickHouse
Introduction to kubernetes
Kubernetes Networking with Cilium - Deep Dive
Ansible
[KubeCon EU 2022] Running containerd and k3s on macOS
Introduction to ansible
Containerization is more than the new Virtualization: enabling separation of ...
Rancher 2.0 Technical Deep Dive
Docker Container Security
Monitoring kubernetes with prometheus
01. Kubernetes-PPT.pptx
A la découverte de kubernetes
Why Docker
Docker, LinuX Container
Docker Ecosystem on Azure
Ad

Viewers also liked (8)

PPTX
RancherのWindowsサポートと事始め
PDF
Load Balancing in the Cloud using Nginx & Kubernetes
PDF
Kubernetes Day 2017 - Build, Ship and Run Your APP, Production !!
PDF
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
PDF
Rancher による社内向けテナントサービス基盤
PDF
Beyond Ingresses - Better Traffic Management in Kubernetes
PDF
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
PDF
클라우드 네트워킹과 SDN 그리고 OpenStack
RancherのWindowsサポートと事始め
Load Balancing in the Cloud using Nginx & Kubernetes
Kubernetes Day 2017 - Build, Ship and Run Your APP, Production !!
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
Rancher による社内向けテナントサービス基盤
Beyond Ingresses - Better Traffic Management in Kubernetes
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
클라우드 네트워킹과 SDN 그리고 OpenStack
Ad

Similar to Container Network Interface: Network Plugins for Kubernetes and beyond (20)

PPTX
Docker SDN (software-defined-networking) JUG
PPTX
Docker Networking with New Ipvlan and Macvlan Drivers
PDF
Chris Swan ONUG Academy - Container Networks Tutorial
PDF
Docker Meetup: Docker Networking 1.11 with Madhu Venugopal
PDF
Docker 1.11 Meetup: Networking Showcase
PDF
Docker Meetup: Docker Networking 1.11, by Madhu Venugopal
PDF
PDF
OpenStack Tokyo 2015: Connecting the Dots with Neutron
PDF
Demystfying container-networking
PDF
OpenNebulaConf 2016 - Networking, NFVs and SDNs Hands-on Workshop by Rubén S....
PPTX
Docker networking Tutorial 101
PPTX
Managing multicast stream on Docker.pptx
PDF
OSS Japan 2019 service mesh bridging Kubernetes and legacy
PPTX
VyOS Users Meeting #2, VyOSのVXLANの話
PDF
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...
PPTX
Nynog-K8s-networking-101.pptx
PDF
Network plugins for kubernetes
PPTX
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
PDF
Docker-OVS
PPTX
Deep Dive in Docker Overlay Networks
Docker SDN (software-defined-networking) JUG
Docker Networking with New Ipvlan and Macvlan Drivers
Chris Swan ONUG Academy - Container Networks Tutorial
Docker Meetup: Docker Networking 1.11 with Madhu Venugopal
Docker 1.11 Meetup: Networking Showcase
Docker Meetup: Docker Networking 1.11, by Madhu Venugopal
OpenStack Tokyo 2015: Connecting the Dots with Neutron
Demystfying container-networking
OpenNebulaConf 2016 - Networking, NFVs and SDNs Hands-on Workshop by Rubén S....
Docker networking Tutorial 101
Managing multicast stream on Docker.pptx
OSS Japan 2019 service mesh bridging Kubernetes and legacy
VyOS Users Meeting #2, VyOSのVXLANの話
Collabnix Online Webinar - Demystifying Docker & Kubernetes Networking by Bal...
Nynog-K8s-networking-101.pptx
Network plugins for kubernetes
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Docker-OVS
Deep Dive in Docker Overlay Networks

More from KubeAcademy (20)

PDF
KubeCon EU 2016: Distributed containers in the physical world
PDF
KubeCon EU 2016:
PDF
KubeCon EU 2016: ChatOps and Automatic Deployment on Kubernetes
PDF
KubeCon EU 2016: A Practical Guide to Container Scheduling
PDF
KubeCon EU 2016: Trading in the Kube
ODP
KubeCon EU 2016: Integrated trusted computing in Kubernetes
PDF
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
PPTX
KubeCon EU 2016: Secure, Cloud-Native Networking with Project Calico
PDF
KubeCon EU 2016: Heroku to Kubernetes
PPTX
KubeCon EU 2016: Transforming the Government
PDF
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
PDF
KubeCon EU 2016: Kubernetes Storage 101
PDF
KubeCon EU 2016: Using Traffic Control to Test Apps in Kubernetes
PDF
KubeCon EU 2016: Kubernetes in Production in The New York Times newsroom
PDF
KubeCon EU 2016: ITNW (If This Now What): Orchestrating an Enterprise
PDF
KubeCon EU 2016: SmartCity IoT on Kubernetes
PDF
KubeCon EU 2016: Templatized Application Configuration on OpenShift and Kuber...
PDF
KubeCon EU 2016 Keynote: Pushing Kubernetes Forward
PDF
KubeCon EU 2016: Killing containers to make weather beautiful
PPTX
KubeCon EU 2016: Multi-Tenant Kubernetes
KubeCon EU 2016: Distributed containers in the physical world
KubeCon EU 2016:
KubeCon EU 2016: ChatOps and Automatic Deployment on Kubernetes
KubeCon EU 2016: A Practical Guide to Container Scheduling
KubeCon EU 2016: Trading in the Kube
KubeCon EU 2016: Integrated trusted computing in Kubernetes
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Secure, Cloud-Native Networking with Project Calico
KubeCon EU 2016: Heroku to Kubernetes
KubeCon EU 2016: Transforming the Government
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Using Traffic Control to Test Apps in Kubernetes
KubeCon EU 2016: Kubernetes in Production in The New York Times newsroom
KubeCon EU 2016: ITNW (If This Now What): Orchestrating an Enterprise
KubeCon EU 2016: SmartCity IoT on Kubernetes
KubeCon EU 2016: Templatized Application Configuration on OpenShift and Kuber...
KubeCon EU 2016 Keynote: Pushing Kubernetes Forward
KubeCon EU 2016: Killing containers to make weather beautiful
KubeCon EU 2016: Multi-Tenant Kubernetes

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Machine learning based COVID-19 study performance prediction
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
Teaching material agriculture food technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Modernizing your data center with Dell and AMD
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
Machine learning based COVID-19 study performance prediction
MYSQL Presentation for SQL database connectivity
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Teaching material agriculture food technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Container Network Interface: Network Plugins for Kubernetes and beyond

  • 1. Container Network Interface: Network plugins for Kubernetes and beyond Eugene Yakubovich @eyakubovich
  • 2. Kubernetes networking model - IP per pod - Pods in the cluster can be addressed by their IP
  • 3. How to network containers together? - Cloud provider integration - AWS - GCE
  • 4. How to network containers together? linux-bridge macvlan ipvlan Open vSwitch Weave Project Calico flannel
  • 5. How to allocate IP addresses? - From a fixed block on a host - DHCP - IPAM system backed by SQL database - SDN assigned: e.g. Weave
  • 6. How do you mix and match? (macvlan | ipvlan) + (DHCP | host-local)
  • 7. Order matters! - macvlan + DHCP ○ Create macvlan device ○ Use the device to DHCP ○ Configure device with allocated IP - Routed + IPAM ○ Ask IPAM for an IP ○ Create veth and routes on host and/or fabric ○ Configure device with allocated IP
  • 8. Container Runtime (e.g. k8s) veth macvlan ipvlan OVS Container Networking Interface (CNI)
  • 9. CNI - Container can join multiple networks - Network described by JSON config - Plugin supports two commands - Add container to the network - Remove container from the network
  • 10. User configures a network $ cat /etc/cni/net.d/10-mynet.conf { "name": "mynet", "type": "bridge", "ipam": { "type": "host-local", "subnet": "10.10.0.0/16" } }
  • 11. CNI: Step 1 Container runtime creates network namespace and gives it a named handle $ cd /var/lib/cni $ touch myns $ unshare -n mount --bind /proc/self/ns/net myns
  • 12. CNI: Step 2 Container runtime invokes the CNI plugin $ export CNI_COMMAND=ADD $ export CNI_NETNS=/var/lib/cni/myns $ export CNI_CONTAINERID=5248e9f8-3c91-11e5-... $ export CNI_IFNAME=eth0 $ $CNI_PATH/bridge </etc/cni/net.d/10-mynet.conf
  • 13. CNI: Step 3 Inside the bridge plugin (1): $ brctl addbr mynet $ ip link add veth123 type veth peer name $CNI_IFNAME $ brctl addif mynet veth123 $ ip link set $CNI_IFNAME netns $CNI_IFNAME $ ip link set veth123 up
  • 14. CNI: Step 3 Inside the bridge plugin (2): $ IPAM_PLUGIN=host-local # from network conf $ echo $IPAM_PLUGIN { "ip4": { "ip": "10.10.5.9/16", "gateway": "10.10.0.1" } }
  • 15. CNI: Step 3 Inside the bridge plugin (3): # switch to container namespace $ ip addr add 10.0.5.9/16 dev $CNI_IFNAME # Finally, print IPAM result JSON to stdout
  • 16. Kubernetes + CNI + Docker - Kubernetes has its own network plugins - CNI "driver" is a k8s network plugin - Future: make CNI native plugin system
  • 17. Kubernetes + CNI + Docker - k8s starts "pause" container to create netns - k8s invokes its plugin (CNI driver) - k8s CNI driver executes a CNI plugin - CNI plugin joins "pause" container to network - Pod containers use "pause" container netns
  • 18. Kubernetes + rkt - rkt natively supports CNI - Kubernetes delegates to rkt to invoke CNI plugins
  • 20. Want to work on upstream Kubernetes or distributed systems infrastructure? CoreOS San Francisco is hiring. Work at CoreOS coreos.com/careers