Finish multus tests

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2022-10-05 13:07:42 +02:00
parent 6d77c4c868
commit 79c78161bd
3 changed files with 98 additions and 0 deletions

View file

@ -28,6 +28,57 @@ Before adding:
9: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
```
## Inside the pod
Starting with
```
kubectl apply -f pod-eth1.yaml
```
Checking:
```
[21:20] bridge:multus% kubectl exec -ti samplepod -- ash
/ # ip l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether d2:85:1f:11:d4:d8 brd ff:ff:ff:ff:ff:ff
4: net1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 3c:ec:ef:cb:d8:1b brd ff:ff:ff:ff:ff:ff
/ #
```
On the host it has been removed:
```
[21:21] server123.place10:/etc/cni/net.d# ip l | grep eth1
[21:22] server123.place10:/etc/cni/net.d#
```
IPAM works correctly as well:
```
4: net1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 3c:ec:ef:cb:d8:1b brd ff:ff:ff:ff:ff:ff
inet 10.1.2.2/24 brd 10.1.2.255 scope global net1
valid_lft forever preferred_lft forever
inet6 2a0a:e5c0:10:20::2/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::3eec:efff:fecb:d81b/64 scope link
valid_lft forever preferred_lft forever
/ #
```
After the pod is destroyed, eth1 is back:
```
[21:22] server123.place10:/etc/cni/net.d# ip l | grep eth1
19: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
alias eth1
```
## SEE ALSO
* https://github.com/containernetworking/plugins

View file

@ -33,3 +33,39 @@ spec:
}
]
}
---
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: eth2
namespace: default
spec:
config: |
{
"cniVersion": "0.4.0",
"name": "eth2",
"plugins": [
{
"type": "host-device",
"device": "eth2",
"ipam": {
"type": "host-local",
"ranges": [
[
{ "subnet": "10.1.2.0/24",
"rangeStart:": "10.1.2.10",
"rangeEnd:": "10.1.2.20"
}
],
[
{ "subnet": "2a0a:e5c0:10:20::/64",
"rangeStart:": "2a0a:e5c0:10:20::10",
"rangeEnd:": "2a0a:e5c0:10:20::20"
}
]
]
}
}
]
}

11
cni/multus/pod-eth1.yaml Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Pod
metadata:
name: samplepod
annotations:
k8s.v1.cni.cncf.io/networks: eth1
spec:
containers:
- name: samplepod
command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
image: alpine