Fix backward compatibility with calico 2.6

This commit is contained in:
Matthew Mosesohn 2018-09-06 15:49:06 +03:00
parent a3caeba242
commit dc3e317d20
5 changed files with 50 additions and 3 deletions

View file

@ -16,4 +16,5 @@
shell: "{{ bin_dir }}/calico-upgrade complete --no-prompts --apiconfigv1 /etc/calico/etcdv2.yml --apiconfigv3 /etc/calico/etcdv3.yml"
when:
- inventory_hostname == groups['kube-master'][0]
- calico_upgrade_enabled|default(True)
- calico_upgrade_needed|default(False)

View file

@ -95,6 +95,9 @@ kube_network_plugin: calico
# Determines if calico-rr group exists
peer_with_calico_rr: "{{ 'calico-rr' in groups and groups['calico-rr']|length > 0 }}"
# Set to false to disable calico-upgrade
calico_upgrade_enabled: true
# Kubernetes internal network for services, unused block of space.
kube_service_addresses: 10.233.0.0/18

View file

@ -41,6 +41,7 @@ calico_felix_prometheusgometricsenabled: "true"
calico_felix_prometheusprocessmetricsenabled: "true"
### check latest version https://github.com/projectcalico/calico-upgrade/releases
calico_upgrade_enabled: true
calico_upgrade_version: v1.0.5
# Should calico ignore kernel's RPF check setting,

View file

@ -147,9 +147,28 @@
with_items:
- "{{ peers|default([]) }}"
when:
- calico_version_on_server.stdout|version_compare('v3.0.0', '>') or calico_upgrade_enabled
- peer_with_router|default(false)
- inventory_hostname in groups['k8s-cluster']
- name: Calico | Configure peering with router(s) (legacy)
shell: >
echo '{
"kind": "bgpPeer",
"spec": {"asNumber": "{{ item.as }}"},
"apiVersion": "v1",
"metadata": {"node": "{{ inventory_hostname }}", "scope": "node", "peerIP": "{{ item.router_id }}"}
}'
| {{ bin_dir }}/calicoctl create --skip-exists -f -
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ peers|default([]) }}"
when:
- calico_version_on_server.stdout|version_compare('v3.0.0', '<')
- not calico_upgrade_enabled
- peer_with_router|default(false)
- inventory_hostname in groups['k8s-cluster']
- name: Calico | Configure peering with route reflectors
shell: >
echo '{
@ -169,9 +188,31 @@
with_items:
- "{{ groups['calico-rr'] | default([]) }}"
when:
- (peer_with_calico_rr|default(false)
- calico_version_on_server.stdout|version_compare('v3.0.0', '>') or calico_upgrade_enabled
- peer_with_calico_rr|default(false)
- inventory_hostname in groups['k8s-cluster']
- hostvars[item]['cluster_id'] == cluster_id)
- hostvars[item]['cluster_id'] == cluster_id
- name: Calico | Configure peering with route reflectors (legacy)
shell: >
echo '{
"kind": "bgpPeer",
"spec": {"asNumber": "{{ local_as | default(global_as_num)}}"},
"apiVersion": "v1",
"metadata": {"node": "{{ inventory_hostname }}",
"scope": "node",
"peerIP": "{{ hostvars[item]["calico_rr_ip"]|default(hostvars[item]["ip"])|default(hostvars[item]["ansible_default_ipv4"]["address"]) }}"}
}'
| {{ bin_dir }}/calicoctl create --skip-exists -f -
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
with_items: "{{ groups['calico-rr'] | default([]) }}"
when:
- calico_version_on_server.stdout|version_compare('v3.0.0', '<')
- not calico_upgrade_enabled
- peer_with_calico_rr|default(false)
- hostvars[item]['cluster_id'] == cluster_id
- name: Calico | Create calico manifests
template:

View file

@ -5,6 +5,7 @@
- include_tasks: upgrade.yml
when:
- calico_upgrade_enabled
- calico_upgrade_needed
run_once: yes
delegate_to: "{{ groups['kube-master'][0] }}"