Start Container with Multiple Network Interfaces
My tests require having two network interfaces. I previously accomplished this with podman running on Linux by creating podman networks to connect to containers. With kubedock, the podman network command appears to run using the local podman instead of the kubedock api socket.
How can I start a container with multiple network interfaces: eth0, eth1?
Environment:
- OpenShift Dev Spaces
This is not yet supported, kubedock flattens all networks into one at the moment.
I ended up finding a way I could do it.
First I made a NetworkAttachmentDefinition to make another network.
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: eth1-network
namespace: user-devspaces
spec:
config: '{
"cniVersion": "0.3.1",
"name": "bridge-net",
"type": "bridge",
"isGateway": true,
"vlan": 2,
"ipam": {
"type": "static",
"addresses": [
{
"address": "192.168.1.100/24",
"gateway": "192.168.1.1"
}
]
}
}'
Then I used the annotation config option to attach the network to the pods that kubedock creates.
--annotation k8s.v1.cni.cncf.io/networks=eth1-network
Sources: https://docs.openshift.com/container-platform/4.16/networking/multiple_networks/configuring-additional-network.html#nw-multus-bridge-object_configuring-additional-network https://docs.openshift.com/container-platform/4.16/networking/multiple_networks/attaching-pod.html