From f59d3fc4a3b266bf9408b64a18ec847469b519e3 Mon Sep 17 00:00:00 2001
From: nic0las <65987283+nico0olas@users.noreply.github.com>
Date: Thu, 27 Aug 2020 11:07:01 +0200
Subject: [PATCH] Deviceroutesourceaddress (#6508)

* add FELIX_DEVICEROUTESOURCEADDRESS calico option

* add calico_use_default_route_src_ipaddr option

add calico_use_default_route_src_ipaddr option to use FELIX_DEVICEROUTESOURCEADDRESS calico option

* Update k8s-net-calico.yml
---
 inventory/sample/group_vars/k8s-cluster/k8s-net-calico.yml | 4 ++++
 roles/network_plugin/calico/templates/calico-node.yml.j2   | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/inventory/sample/group_vars/k8s-cluster/k8s-net-calico.yml b/inventory/sample/group_vars/k8s-cluster/k8s-net-calico.yml
index d81af4ebc..003072ab2 100644
--- a/inventory/sample/group_vars/k8s-cluster/k8s-net-calico.yml
+++ b/inventory/sample/group_vars/k8s-cluster/k8s-net-calico.yml
@@ -72,3 +72,7 @@
 # calico_ip_auto_method: "interface=eth.*"
 # Choose the iptables insert mode for Calico: "Insert" or "Append".
 # calico_felix_chaininsertmode: Insert
+
+# If you want use the default route interface when you use multiple interface with dynamique route (iproute2)
+# see https://docs.projectcalico.org/reference/node/configuration : FELIX_DEVICEROUTESOURCEADDRESS
+# calico_use_default_route_src_ipaddr: false
diff --git a/roles/network_plugin/calico/templates/calico-node.yml.j2 b/roles/network_plugin/calico/templates/calico-node.yml.j2
index cd0ca4b26..b3c9b2757 100644
--- a/roles/network_plugin/calico/templates/calico-node.yml.j2
+++ b/roles/network_plugin/calico/templates/calico-node.yml.j2
@@ -258,6 +258,12 @@ spec:
               valueFrom:
                 fieldRef:
                   fieldPath: status.hostIP
+{% endif %}
+{% if calico_version is version('v3.9.0', '>=') and calico_use_default_route_src_ipaddr|default(false) %}
+            - name: FELIX_DEVICEROUTESOURCEADDRESS
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.hostIP
 {% endif %}
             - name: NODENAME
               valueFrom:
-- 
GitLab