aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks
diff options
context:
space:
mode:
authorYifei Xue <xueyifei@huawei.com>2018-02-22 00:38:54 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-02-22 00:38:54 +0000
commitcfafdfa4bad20b380e542e6b2d4e240b2a931097 (patch)
tree6db62ef1ea06d06dd90927f482615b636bd5d004 /deploy/adapters/ansible/kubernetes/roles/2flannel/tasks
parentc8d1b105be71eb831a7068c2b7d5e1530d590a11 (diff)
parent098208121bba3ef6d576976c2e975c56f89ae901 (diff)
Merge "add a multus with 2 fannel interfaces installation"
Diffstat (limited to 'deploy/adapters/ansible/kubernetes/roles/2flannel/tasks')
-rw-r--r--deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/main.yml73
-rw-r--r--deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/pre-upgrade.yml14
2 files changed, 87 insertions, 0 deletions
diff --git a/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/main.yml b/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/main.yml
new file mode 100644
index 00000000..e7adeefe
--- /dev/null
+++ b/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/main.yml
@@ -0,0 +1,73 @@
+---
+- include: pre-upgrade.yml
+
+- name: 2Flannel | Verify if br_netfilter module exists
+ shell: "modinfo br_netfilter"
+ register: modinfo_br_netfilter
+ failed_when: modinfo_br_netfilter.rc not in [0, 1]
+ changed_when: false
+
+- name: 2Flannel | Enable br_netfilter module
+ modprobe:
+ name: br_netfilter
+ state: present
+ when: modinfo_br_netfilter.rc == 0
+
+# kube-proxy needs net.bridge.bridge-nf-call-iptables enabled when found
+# if br_netfilter is not a module
+- name: 2Flannel | Check if bridge-nf-call-iptables key exists
+ command: "sysctl net.bridge.bridge-nf-call-iptables"
+ failed_when: false
+ changed_when: false
+ register: sysctl_bridge_nf_call_iptables
+
+- name: 2Flannel | Enable bridge-nf-call tables
+ sysctl:
+ name: "{{ item }}"
+ state: present
+ value: 1
+ reload: "yes"
+ when: modinfo_br_netfilter.rc == 1 and sysctl_bridge_nf_call_iptables.rc == 0
+ with_items:
+ - net.bridge.bridge-nf-call-iptables
+ - net.bridge.bridge-nf-call-arptables
+ - net.bridge.bridge-nf-call-ip6tables
+
+- name: 2Flannel | Install Multus CNI
+ shell: |-
+ /usr/bin/docker run --rm --network=host -v /opt/cni/bin/:/opt/cni/bin/ golang:1.9 \
+ bash -c \
+ "git clone https://github.com/Intel-Corp/multus-cni && \
+ cd multus-cni && ./build && cp bin/multus /opt/cni/bin"
+
+- name: 2Flannel | Create cni-flannel-rbac manifest
+ template:
+ src: cni-2flannel-rbac.yml.j2
+ dest: "{{ kube_config_dir }}/cni-2flannel-rbac.yml"
+ register: two_flannel_rbac_manifest
+ when: inventory_hostname == groups['kube-master'][0] and rbac_enabled
+
+- name: 2Flannel | Create cni-flannel manifest
+ template:
+ src: cni-2flannel.yml.j2
+ dest: "{{ kube_config_dir }}/cni-2flannel.yml"
+ register: two_flannel_manifest
+ when: inventory_hostname == groups['kube-master'][0]
+
+- name: 2Flannel | Set 2Flannel etcd configuration
+ shell: |-
+ ETCDCTL_CA_FILE=/etc/ssl/etcd/ssl/ca.pem \
+ ETCDCTL_CERT_FILE=/etc/ssl/etcd/ssl/node-{{ ansible_hostname }}.pem \
+ ETCDCTL_KEY_FILE=/etc/ssl/etcd/ssl/node-{{ ansible_hostname }}-key.pem \
+ {{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} \
+ set /{{ cluster_name }}/{{ item.config }}/network/config \
+ '{ "Network": "{{ item.network }}", "Backend": {"Type":"udp", "Port":{{ item.port}} }}'
+ with_items:
+ - {config: "2flannel.1",
+ network: "{{ two_flannel_network1 }}",
+ port: 8285}
+ - {config: "2flannel.2",
+ network: "{{ two_flannel_network2 }}",
+ port: 8286}
+ delegate_to: "{{groups['etcd'][0]}}"
+ run_once: true
diff --git a/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/pre-upgrade.yml b/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/pre-upgrade.yml
new file mode 100644
index 00000000..a49002fe
--- /dev/null
+++ b/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/pre-upgrade.yml
@@ -0,0 +1,14 @@
+---
+- name: 2Flannel pre-upgrade | Purge legacy flannel systemd unit file
+ file:
+ path: "/etc/systemd/system/docker.service.d/flannel-options.conf"
+ state: absent
+ notify:
+ - 2Flannel | delete default docker bridge
+
+- name: 2Flannel pre-upgrade | Purge legacy Flannel static pod manifest
+ file:
+ path: "{{ kube_manifest_dir }}/flannel-pod.manifest"
+ state: absent
+ notify:
+ - 2Flannel | delete flannel interface