From b7e6dd0dd49cec06ef36d8982eb2ecf42a980b8a Mon Sep 17 00:00:00 2001 From: Sergey Bondarev Date: Fri, 16 Mar 2018 21:44:36 +0300 Subject: [PATCH] Add --iface-regex options to flannel Flannel use interface for inter-host communication setted on --iface options Defaults to the interface for the default route on the machine. flannel config set via daemonset, and flannel config on all nodes is the same. But different nodes can have different interface names for the inter-host communication network The option --iface-regex allows the flannel to find the interface on which the address is set from the inter-host communication network --- roles/network_plugin/flannel/defaults/main.yml | 8 +++++++- roles/network_plugin/flannel/templates/cni-flannel.yml.j2 | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/network_plugin/flannel/defaults/main.yml b/roles/network_plugin/flannel/defaults/main.yml index 08f4ac145..e48a9475a 100644 --- a/roles/network_plugin/flannel/defaults/main.yml +++ b/roles/network_plugin/flannel/defaults/main.yml @@ -5,9 +5,15 @@ # flannel_public_ip: "{{ access_ip|default(ip|default(ansible_default_ipv4.address)) }}" ## interface that should be used for flannel operations -## This is actually an inventory node-level item +## This is actually an inventory cluster-level item # flannel_interface: +## Select interface that should be used for flannel operations by regexp on Name or IP +## This is actually an inventory cluster-level item +## example: select interface with ip from net 10.0.0.0/23 +## single quote and escape backslashes +# flannel_interface_regexp: '10\\.0\\.[0-2]\\.\\d{1,3}' + # You can choose what type of flannel backend to use # please refer to flannel's docs : https://github.com/coreos/flannel/blob/master/README.md flannel_backend_type: "vxlan" diff --git a/roles/network_plugin/flannel/templates/cni-flannel.yml.j2 b/roles/network_plugin/flannel/templates/cni-flannel.yml.j2 index 6c69dcaa8..bb2a6a7f8 100644 --- a/roles/network_plugin/flannel/templates/cni-flannel.yml.j2 +++ b/roles/network_plugin/flannel/templates/cni-flannel.yml.j2 @@ -66,7 +66,7 @@ spec: requests: cpu: {{ flannel_cpu_requests }} memory: {{ flannel_memory_requests }} - command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr"{% if flannel_interface is defined %}, "--iface={{ flannel_interface }}"{% endif %} ] + command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr"{% if flannel_interface is defined %}, "--iface={{ flannel_interface }}"{% endif %}{% if flannel_interface_regexp is defined %}, "--iface-regex={{ flannel_interface_regexp }}"{% endif %} ] securityContext: privileged: true env: