summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/kubernetes/roles/2flannel/tasks/main.yml
blob: e7adeefe58d931f12acafb57434701529f8ab6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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