From a045105f5b1fa4d0e11ee283eb44d02d39766d66 Mon Sep 17 00:00:00 2001 From: wutianwei Date: Sun, 8 Apr 2018 15:46:03 +0800 Subject: xci: Add k8-nosdn-nofeature role Move default k8s-cluster.yml from kubespray/files/ to role/k8-nosdn-nofeature/files/k8s-cluster.yml since it's scenario specific. Moreover, we set 'cloud' as kube_network_plugin, which would use kubnet as network plugin. The kubenet network plugin requires routing between to be setup by the administrator so we need to add static routes on every host since they are connected using a bridge instead of a router. installer-type:kubespray deploy-scenario:k8-nosdn-nofeature Change-Id: I6ab7288c966d7f17e9d61279056f7673be37bebe Signed-off-by: wutianwei Signed-off-by: Markos Chandras --- .../kubespray/playbooks/configure-kubenet.yml | 50 ++++++++++++++++++++++ .../kubespray/playbooks/configure-opnfvhost.yml | 5 --- 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 xci/installer/kubespray/playbooks/configure-kubenet.yml (limited to 'xci/installer/kubespray/playbooks') diff --git a/xci/installer/kubespray/playbooks/configure-kubenet.yml b/xci/installer/kubespray/playbooks/configure-kubenet.yml new file mode 100644 index 00000000..1c3740b2 --- /dev/null +++ b/xci/installer/kubespray/playbooks/configure-kubenet.yml @@ -0,0 +1,50 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2018 SUSE LINUX GmbH and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# NOTE(hwoarang) Kubenet expects networking to be prepared by the administrator so it's necessary +# to do that as part of the node configuration. All we need is to add static routes on every node +# so cbr0 interfaces can talk to each other. +- name: Prepare networking for kubenet + hosts: k8s-cluster + gather_facts: True + become: yes + vars_files: + - "{{ xci_path }}/xci/var/opnfv.yml" + tasks: + - name: Configure static routes + block: + - name: Collect cbr0 information from the nodes + set_fact: + kubenet_xci_static_routes: |- + {% set static_routes = [] %} + {% for host in groups['k8s-cluster']|select("ne", inventory_hostname) %} + {%- set _ = static_routes.append( + {'network': (hostvars[host]['ansible_cbr0']['ipv4']['network']+'/'+ + hostvars[host]['ansible_cbr0']['ipv4']['netmask'])|ipaddr('net'), + 'gateway': hostvars[host]['ansible_default_ipv4']['address']}) -%} + {% endfor %} + {{ static_routes }} + + - name: Add static routes on each node + shell: "ip route show | grep -q {{ item.network }} || ip route add {{ item.network }} via {{ item.gateway }}" + with_items: "{{ kubenet_xci_static_routes }}" + loop_control: + label: "{{ item.network }}" + when: deploy_scenario == 'k8-nosdn-nofeature' + + - name: Ensure rp_filter is disabled on localhost + sysctl: + name: net.ipv4.conf.all.rp_filter + sysctl_set: yes + state: present + value: "{{ deploy_scenario == 'k8-nosdn-nofeature' | ternary(0, 1) }}" + reload: yes + delegate_to: localhost + run_once: True diff --git a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml index 0ac18b50..697d44c2 100644 --- a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml +++ b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml @@ -43,11 +43,6 @@ file: path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars" state: directory - - name: copy k8s_cluster.yml - command: "cp -rf {{ remote_xci_path }}/xci/installer/kubespray/files/k8s-cluster.yml \ - {{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars" - args: - creates: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars/k8s-cluster.yml" - include: "{{ xci_path }}/xci/playbooks/bootstrap-scenarios.yml" - name: Install required packages package: -- cgit