Flannel and multi-networks

925 views
Skip to first unread message

Sreenivas Makam

unread,
Oct 3, 2015, 2:50:29 AM10/3/15
to CoreOS User
Hi
I was trying to setup Flannel with multi-networks following the procedure here(https://github.com/coreos/flannel/blob/master/README.md)

In the original flannel single network case, /run/flannel/subnet.env and /run/flannel_docker_opts.env gets created from flanneld.service and docker uses flannel_docker_opts.env to use flannel created network. For multi-network case, as i understand, we create different subnets in /run/flannel/networks/*. What other changes are needed in flanneld.service? I assume we need to create flannel_docker_opts.env per network? Its not clear how we tell container that its part of a particular network when starting using this approach?

Thanks
Sreenivas

eugene.y...@coreos.com

unread,
Oct 5, 2015, 2:04:05 PM10/5/15
to CoreOS User
Hi Sreenivas,

The short answer is that we haven't yet made out of the box CoreOS image work with multiple networks. You can certainly try to write the service files yourself. Here are some things to keep in mind:

1. In the multi-network case, flanneld will no longer signal systemd about its readiness ("READY=1") so you will not be using "Type=notify" anymore (this b/c there's no longer one single READY event).
2. Instead, of /run/flannel/subnet.env file, it'll create /run/flannel/networks/{network-name}.env file. You can use systemd path activation (http://www.freedesktop.org/software/systemd/man/systemd.path.html) to trigger downstream units, including having a unit to convert that .env file into /run/flannel_docker_opts.env.
3. If you're using Docker, you will either need to pick a single network for it or run multiple Docker daemons. Then, use DOCKER_HOST or "docker -H ..." to pick the daemon when running a container.
4. With rkt, you can just create multiple network conf files in /etc/rkt/net.d and use subnetFile parameter (https://github.com/appc/cni/blob/master/Documentation/flannel.md). Then use "rkt run --private-net={network-name}" to select the network.

-Eugene

f zh

unread,
Feb 24, 2017, 3:34:54 AM2/24/17
to CoreOS User, eugene.y...@coreos.com
Hi,

What's the status now? Is that possible to have one container attach to two different networks provided by flannel, in Kubernetes or Docker? 

Thank you.
Zhang Fan

Alex Polvi

unread,
Feb 24, 2017, 12:06:47 PM2/24/17
to f zh, CoreOS User, Eugene Yakubovich
Wanted to offer an example of how to do this on k8s:


It uses a CNI plugin to change networks based on the namespace in kubernetes.

-Alex

--
You received this message because you are subscribed to the Google Groups "CoreOS User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coreos-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages