diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 7380f1ab7..a30055367 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -1,5 +1,5 @@ # Valid bootstrap options (required): ubuntu, coreos, centos, none -bootstrap_os: ubuntu +bootstrap_os: none #Directory where etcd data stored etcd_data_dir: /var/lib/etcd diff --git a/inventory/group_vars/k8s-cluster.yml b/inventory/group_vars/k8s-cluster.yml index 8211011a3..9b4da1f9d 100644 --- a/inventory/group_vars/k8s-cluster.yml +++ b/inventory/group_vars/k8s-cluster.yml @@ -69,14 +69,24 @@ kube_users: # Choose network plugin (calico, weave or flannel) # Can also be set to 'cloud', which lets the cloud provider setup appropriate routing -kube_network_plugin: weave +kube_network_plugin: calico # weave's network password for encryption # if null then no network encryption +# you can use --extra-vars to pass the password in command line weave_password: ~t94S:mweJN}32-K -# Set true for use weave's seed mode -weave_mode_seed: true +# Weave uses consensus mode by default +# Enabling seed mode allow to dynamically add or remove hosts +# https://www.weave.works/docs/net/latest/ipam/ +weave_mode_seed: false + +# This two variable are automatically changed by the weave's role, do not manually change these values +# To reset values : +# seed: unset +# peers: unset +weave_seed: unset +weave_peers: unset # Enable kubernetes network policies enable_network_policy: false diff --git a/inventory/group_vars/k8s-fede.yml b/inventory/group_vars/k8s-fede.yml deleted file mode 100644 index 397835678..000000000 --- a/inventory/group_vars/k8s-fede.yml +++ /dev/null @@ -1,7 +0,0 @@ -# This file is use to save seed and peers values for weave's seed mode -# This two variable are automatically changed by the weave's role -# For reset values : -# seed: unset -# peers: unset -seed: fa:16:3e:b5:ea:aa,fa:16:3e:47:29:c6 -peers: 192.168.208.13 192.168.208.9 diff --git a/roles/network_plugin/weave/tasks/seed.yml b/roles/network_plugin/weave/tasks/seed.yml index 43bdde6e1..d81b72436 100644 --- a/roles/network_plugin/weave/tasks/seed.yml +++ b/roles/network_plugin/weave/tasks/seed.yml @@ -1,37 +1,37 @@ -- name: Weave seed | Set seed first time +- name: Weave seed | Set seed if first time set_fact: - weave_seed: '{% for host in groups["k8s-cluster"] %}{{ hostvars[host]["ansible_default_ipv4"]["macaddress"] }}{% if not loop.last %},{% endif %}{% endfor %}' - when: "seed == 'unset'" + seed: '{% for host in groups["k8s-cluster"] %}{{ hostvars[host]["ansible_default_ipv4"]["macaddress"] }}{% if not loop.last %},{% endif %}{% endfor %}' + when: "weave_seed == 'unset'" run_once: true tags: confweave -- name: Weave seed | Set seed +- name: Weave seed | Set seed if not first time set_fact: - weave_seed: '{{ seed }}' - when: "seed != 'unset'" + seed: '{{ weave_seed }}' + when: "weave_seed != 'unset'" run_once: true tags: confweave -- name: Weave seed | Set peers fist time +- name: Weave seed | Set peers if fist time set_fact: - weave_peers: '{{ weave_ip_current_cluster }}' - when: "peers == 'unset'" + peers: '{{ weave_ip_current_cluster }}' + when: "weave_peers == 'unset'" run_once: true tags: confweave -- name: Weave seed | Set peers with existing peers +- name: Weave seed | Set peers if existing peers set_fact: - weave_peers: '{{ peers }}{% if weave_ip_current_cluster not in peers %} {{ weave_ip_current_cluster }}{% endif %}' - when: "peers != 'unset'" + peers: '{{ weave_peers }}{% if weave_ip_current_cluster not in peers %} {{ weave_ip_current_cluster }}{% endif %}' + when: "weave_peers != 'unset'" run_once: true tags: confweave - name: Weave seed | Save seed lineinfile: - dest: "./inventory/group_vars/k8s-fede.yml" + dest: "./inventory/group_vars/k8s-cluster.yml" state: present - regexp: '^seed:' - line: 'seed: {{ weave_seed }}' + regexp: '^weave_seed:' + line: 'weave_seed: {{ seed }}' become_user: $USER delegate_to: 127.0.0.1 run_once: true @@ -39,10 +39,10 @@ - name: Weave seed | Save peers lineinfile: - dest: "./inventory/group_vars/k8s-fede.yml" + dest: "./inventory/group_vars/k8s-cluster.yml" state: present - regexp: '^peers:' - line: 'peers: {{ weave_peers }}' + regexp: '^weave_peers:' + line: 'weave_peers: {{ peers }}' become_user: $USER delegate_to: 127.0.0.1 run_once: true diff --git a/roles/network_plugin/weave/templates/weave-net.yml.j2 b/roles/network_plugin/weave/templates/weave-net.yml.j2 index c488b94b0..6ec3de035 100644 --- a/roles/network_plugin/weave/templates/weave-net.yml.j2 +++ b/roles/network_plugin/weave/templates/weave-net.yml.j2 @@ -82,9 +82,9 @@ items: value: {{ kube_pods_subnet }} {% if weave_mode_seed == true %} - name: KUBE_PEERS - value: {{ weave_peers }} + value: {{ peers }} - name: IPALLOC_INIT - value: seed={{ weave_seed }} + value: seed={{ seed }} {% endif %} - name: WEAVE_PASSWORD value: {{ weave_password }}