Browse Source

add retries for calico/canal etcd commands (#2007)

pull/2008/head
Matthew Mosesohn 7 years ago
committed by GitHub
parent
commit
ec54b36e05
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions
  1. 2
      roles/network_plugin/calico/rr/tasks/main.yml
  2. 10
      roles/network_plugin/calico/tasks/main.yml
  3. 2
      roles/network_plugin/canal/tasks/main.yml

2
roles/network_plugin/calico/rr/tasks/main.yml

@ -54,6 +54,8 @@
"ip": "{{ rr_ip }}", "ip": "{{ rr_ip }}",
"cluster_id": "{{ cluster_id }}" "cluster_id": "{{ cluster_id }}"
}' }'
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
delegate_to: "{{groups['etcd'][0]}}" delegate_to: "{{groups['etcd'][0]}}"
- meta: flush_handlers - meta: flush_handlers

10
roles/network_plugin/calico/tasks/main.yml

@ -98,6 +98,8 @@
--key {{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem \ --key {{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem \
https://localhost:2379/v2/keys/calico/v1/ipam/v4/pool https://localhost:2379/v2/keys/calico/v1/ipam/v4/pool
register: calico_conf register: calico_conf
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
delegate_to: "{{groups['etcd'][0]}}" delegate_to: "{{groups['etcd'][0]}}"
run_once: true run_once: true
changed_when: false changed_when: false
@ -125,6 +127,8 @@
--key {{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem \ --key {{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem \
https://localhost:2379/v2/keys/calico/v1/ipam/v4/pool https://localhost:2379/v2/keys/calico/v1/ipam/v4/pool
register: calico_pools_raw register: calico_pools_raw
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
delegate_to: "{{groups['etcd'][0]}}" delegate_to: "{{groups['etcd'][0]}}"
run_once: true run_once: true
@ -146,6 +150,8 @@
- name: Calico | Disable node mesh - name: Calico | Disable node mesh
shell: "{{ bin_dir }}/calicoctl config set nodeToNodeMesh off" shell: "{{ bin_dir }}/calicoctl config set nodeToNodeMesh off"
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
when: ((peer_with_router|default(false) or peer_with_calico_rr|default(false)) when: ((peer_with_router|default(false) or peer_with_calico_rr|default(false))
and inventory_hostname in groups['k8s-cluster']) and inventory_hostname in groups['k8s-cluster'])
run_once: true run_once: true
@ -159,6 +165,8 @@
"metadata": {"node": "{{ inventory_hostname }}", "scope": "node", "peerIP": "{{ item.router_id }}"} "metadata": {"node": "{{ inventory_hostname }}", "scope": "node", "peerIP": "{{ item.router_id }}"}
}' }'
| {{ bin_dir }}/calicoctl create --skip-exists -f - | {{ bin_dir }}/calicoctl create --skip-exists -f -
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ peers|default([]) }}" with_items: "{{ peers|default([]) }}"
when: peer_with_router|default(false) and inventory_hostname in groups['k8s-cluster'] when: peer_with_router|default(false) and inventory_hostname in groups['k8s-cluster']
@ -173,6 +181,8 @@
"peerIP": "{{ hostvars[item]["calico_rr_ip"]|default(hostvars[item]["ip"])|default(hostvars[item]["ansible_default_ipv4"]["address"]) }}"} "peerIP": "{{ hostvars[item]["calico_rr_ip"]|default(hostvars[item]["ip"])|default(hostvars[item]["ansible_default_ipv4"]["address"]) }}"}
}' }'
| {{ bin_dir }}/calicoctl create --skip-exists -f - | {{ bin_dir }}/calicoctl create --skip-exists -f -
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ groups['calico-rr'] | default([]) }}" with_items: "{{ groups['calico-rr'] | default([]) }}"
when: (peer_with_calico_rr|default(false) and inventory_hostname in groups['k8s-cluster'] when: (peer_with_calico_rr|default(false) and inventory_hostname in groups['k8s-cluster']
and hostvars[item]['cluster_id'] == cluster_id) and hostvars[item]['cluster_id'] == cluster_id)

2
roles/network_plugin/canal/tasks/main.yml

@ -29,6 +29,8 @@
{{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} \ {{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} \
set /{{ cluster_name }}/network/config \ set /{{ cluster_name }}/network/config \
'{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } }' '{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } }'
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
delegate_to: "{{groups['etcd'][0]}}" delegate_to: "{{groups['etcd'][0]}}"
changed_when: false changed_when: false
run_once: true run_once: true

Loading…
Cancel
Save