Table of Contents
- Ubuntu 14.04 LTS (Trusty Tahr)
/var/lib/lxc/<container name>/config
for newly created container looks like following
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.hwaddr = 00:16:3e:aa:cc:9c
Because LXC not supports OVS add-port, so we have to remove following line
lxc.network.link = lxcbr0
And add following lines
lxc.network.script.up = /etc/network/if-up.d/lxc-ifup
lxc.network.script.down = /etc/network/if-down.d/lxc-ifdown
lxc.network.veth.pair = <ovs port name>
In the end, /var/lib/lxc/<container name>/config
should look like the following
lxc.network.type = veth
lxc.network.flags = up
lxc.network.script.up = /etc/network/if-up.d/lxc-ifup
lxc.network.script.down = /etc/network/if-down.d/lxc-ifdown
lxc.network.veth.pair = <ovs port name>
lxc.network.hwaddr = 00:16:3e:aa:cc:9c
Now, we have to create “lxc-ifup” and “lxc-ifdown” for adding/removing port on OVS when container is launch/shutdown.
Add /etc/network/if-up.d/lxc-ifup
with following lines
#!/bin/bash
ovsBr='lxcbr'
ovs-vsctl --may-exist add-br ${ovsBr}
ovs-vsctl --may-exist add-port ${ovsBr} $5
Add /etc/network/if-down.d/lxc-ifdown
with following lines
#!/bin/bash
ovsBr='lxcbr'
ovs-vsctl --if-exists del-port ${ovsBr} $5
See Also
- LXC with Multiple Network Interfaces
- Kubernetes - Two Steps Installation
- Adopting Container and Kubernetes in Production
- Check Containers Status with Ctop
- Building Minimal Docker Image for Go Applications
To reproduce, republish or re-use the content,
please attach with link: https://tachingchen.com/
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email