Demystfying Container Networking2 190915040315
Demystfying Container Networking2 190915040315
Networking
Who am I?
Allows users to build container The container engine is OCI compliant runtimes can OCI compliant runtimes can
images with any tool they choose. responsible for creating the consume the config.json and consume the config.json and
Different tools are good for config.json file and unpacking root filesystem, and tell the root filesystem, and tell the
different use cases. images into a root file system. kernel to create a container. kernel to create a container.
Container in comparison with OSI
Container Building Blocks
Namespace
• Linux provides seven different namespaces
(Cgroup, IPC, Network, Mount, PID, User and UTS).
• Network namespaces (CLONE_NEWNET) determine the network resources that are
available to a process,
• Each network namespace has its own network devices, IP addresses, IP routing
tables, /proc/net directory, port numbers, and so on.
cgroups:
• blkio, cpu, cpuacct, cpuset, devices, hugetlb, memory,
• net_cls,net_prio, pids, Freezer,Perf_events,ns
• xt_cgroup(cgroupv2)
Container Building Blocks
In cgroups v1, you could assign threads of the same process to different cgroups.But in Cgroup v2, this is not
possible. Rhel8 by default comes up with cgroupv2.
Note: Kernel version has to be 4.5 and above
Container Networking
High Level Abstractions
CTR 1 CTR2
Container Network Model
CNM VS CNI
Note: https://kubernetes.io/blog/2016/01/why-kubernetes-doesnt-use-libnetwork/
Containers and the CNM
Endpoint Sandbox Network Container
Network A Network B
CNM Driver Interfaces
Docker Default Network Drivers
Null/None Network
Default Bridge Network(docker0)
Docker host 1
Host port Container port
Cntnr1
10.0.0.8 :80
$ docker container run -p 8080:80 ...
Bridge
172.14.3.55 :8080
task1.myservice 10.0.1.19
task2.myservice 10.0.1.20
task3.myservice 10.0.1.21
myservice 10.0.1.18
Swarm DNS (service discovery)
Service Virtual IP (VIP) Load Balancing
• Every service gets a VIP when it’s created
• This stays with the service for its entire life
• Lookups against the VIP get load-balanced across all healthy
tasks in the service
• Behind the scenes it uses Linux kernel IPVS to perform transport
layer load balancing
• docker service inspect <service> (shows the service VIP)
NAME HEALTHY IP
Service myservice 10.0.1.18
VIP task1.myservice Y 10.0.1.19
task2.myservice Y 10.0.1.20
Load balance task3.myservice Y 10.0.1.21
group task4.myservice Y 10.0.1.22
task5.myservice Y 10.0.1.23
32
What is the Routing Mesh
Native load balancing of requests coming from an external source
33
Routing Mesh Example
LB
Swarm Topology
Node
Node Node
Node
Node
Node Node
Node
Manager
Worker
Swarm Topology: High Availability
Swarm Topology: High Availability
Reconcile Schedule
Engines check to see what is running Managers break down service into
and compared to what was declared tasks, schedules them and
to “true up” the environment workers execute tasks
Services
Engine
Engine
Engine
mynet
Engine
Engine Engine
Engine
Engine
Engine
mynet
Engine
Engine Engine
Engine
Engine
Engine
mynet
Engine
Engine Engine
Engine
Engine
Engine
mynet
Engine
Engine
Engine
Engine
Engine
Engine
Engine
Alternatives to Kube-proxy
Kubernetes Networking Model
• https://github.com/collabnix/dockerlabs
• https://docs.docker.com
• http://www.collabnix.com
• https://kubernetes.io/docs/concepts/cluster-administration/networking/
• https://sookocheff.com/post/kubernetes/understanding-kubernetes-networking-model/
• https://www.digitalocean.com/community/tutorials/how-to-inspect-kubernetes-networking
• https://success.docker.com/article/docker-ee-best-practices#astandarddeploymentarchitecture
• https://success.docker.com/article/networking
• https://kubernetes.io/blog/2016/12/container-runtime-interface-cri-in-kubernetes/
• https://medium.com/@reuvenharrison/an-introduction-to-kubernetes-network-policies-for-
security-people-ba92dd4c809d
• https://sreeninet.wordpress.com/2016/05/29/docker-macvlan-and-ipvlan-network-plugins/
Thank You