From: Krisztian Lengyel Date: Tue, 1 Oct 2019 12:29:58 +0000 (+0200) Subject: Configure `caas_oam` as flannel interface X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Fcaas-danm.git;a=commitdiff_plain;h=d6e2ccbb58435154df04b91c9810ade8df929b3b Configure `caas_oam` as flannel interface Configure `caas_oam` as flannel interface, and fall back to `infra_internal` if `caas_oam` unspecified. Change-Id: Id9bdf23cae1510383652aac618c28797426dfed1 Signed-off-by: Krisztian Lengyel --- diff --git a/SPECS/caas-flannel.spec b/SPECS/caas-flannel.spec index 9dc688f..10c86e9 100644 --- a/SPECS/caas-flannel.spec +++ b/SPECS/caas-flannel.spec @@ -15,7 +15,7 @@ %define COMPONENT flannel %define RPM_NAME caas-%{COMPONENT} %define RPM_MAJOR_VERSION 0.11.0 -%define RPM_MINOR_VERSION 10 +%define RPM_MINOR_VERSION 11 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION} Name: %{RPM_NAME} diff --git a/ansible/roles/flannel/defaults/main.yaml b/ansible/roles/flannel/defaults/main.yaml new file mode 100644 index 0000000..61a737d --- /dev/null +++ b/ansible/roles/flannel/defaults/main.yaml @@ -0,0 +1,26 @@ +--- +# Copyright 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +attached_network_profile: "{{ hosts[ansible_hostname]['network_profiles'][0] }}" +attached_network_profile_data: "{{ hostvars[ansible_hostname]['network_profiles'][attached_network_profile] }}" +interface_net_mapping: "{{ attached_network_profile_data['interface_net_mapping'] }}" + +caas_oam_network: | + {% set bound_host_networks = [] %} + {% for host_networks in (interface_net_mapping.keys() | map('extract', interface_net_mapping)| list) %} + {% set _ = bound_host_networks.extend(host_networks) %} + {% endfor %} + {% if 'caas_oam' not in bound_host_networks %}infra_internal{% else %}caas_oam{% endif %} +interface_query: "[*].networking.{{ caas_oam_network | trim }}.interface" diff --git a/ansible/roles/flannel/tasks/main.yaml b/ansible/roles/flannel/tasks/main.yaml index 19f10d2..03c5775 100644 --- a/ansible/roles/flannel/tasks/main.yaml +++ b/ansible/roles/flannel/tasks/main.yaml @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: collect flannel interfaces + set_fact: + flannel_interfaces: "{{ hostvars.values() | json_query(interface_query) | unique | list }}" + - name: template Flannel DaemonSet file template: src: flannel-ds.yaml diff --git a/ansible/roles/flannel/templates/flannel-ds.yaml b/ansible/roles/flannel/templates/flannel-ds.yaml index 901679c..73881e6 100644 --- a/ansible/roles/flannel/templates/flannel-ds.yaml +++ b/ansible/roles/flannel/templates/flannel-ds.yaml @@ -1,3 +1,4 @@ +#jinja2: lstrip_blocks: True {# Copyright 2019 Nokia @@ -50,7 +51,9 @@ spec: args: - --ip-masq - --kube-subnet-mgr - - --iface={{ networking.infra_internal.interface }} + {% for interface in flannel_interfaces | default([]) %} + - --iface={{ interface }} + {% endfor %} securityContext: privileged: true env: