Post

CKS Kubernetes CNI

CKS Kubernetes CNI

CKS Kubernetes CNI

Container infor passed by kubelet to stdin of CNI bash plugin

1
2
3
4
CNI_CONTAINERID=b552f9...
CNI_IFNAME=eth0
CNI_COMMAND=ADD
CNI_NETNS=/proc/6137/ns/net
1
2
# interesting fact
ls -sfT $CNI_NETNS /var/run/netns/$CNI_CONTAINERID

Image Image Image Image Image Image Image Image Image Image

How to create client/server namespace and run python webserver

https://www.redhat.com/sysadmin/net-namespaces

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
export namespace1=client
export namespace2=server
export command='python3 -m http.server'
export ip_address1="10.10.10.10/24"
export ip_address2='10.10.10.20/24'
export interface1=veth-client
export interface2=veth-server

ip netns add $namespace1
ip netns add $namespace2
ip link add ptp-$interface1 type veth peer name ptp-$interface2
ip link set ptp-$interface1 netns $namespace1
ip link set ptp-$interface2 netns $namespace2
ip netns exec $namespace1 ip addr add $ip_address1 dev ptp-$interface1
ip netns exec $namespace2 ip addr add $ip_address2 dev ptp-$interface2
ip netns exec $namespace1 ip link set dev ptp-$interface1 up
ip netns exec $namespace2 ip link set dev ptp-$interface2 up
ip netns exec $namespace2 $command &
ip netns pids $namespace2
ip netns ls
ls -ltr /proc/*/ns/net | grep 15035

root@tf-srv-gallant-shaw:~# ip netns exec $namespace1 curl 10.10.10.20:8000

This post is licensed under CC BY 4.0 by the author.