Merge pull request #3254 from mattymo/calico_upgrade_tweaks

Fix backward compatibility with calico 2.6
This commit is contained in:
k8s-ci-robot 2018-09-06 06:20:52 -07:00 committed by GitHub
commit 2faa8f1e37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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" shell: "{{ bin_dir }}/calico-upgrade complete --no-prompts --apiconfigv1 /etc/calico/etcdv2.yml --apiconfigv3 /etc/calico/etcdv3.yml"
when: when:
- inventory_hostname == groups['kube-master'][0] - inventory_hostname == groups['kube-master'][0]
- calico_upgrade_enabled|default(True)
- calico_upgrade_needed|default(False) - calico_upgrade_needed|default(False)

View file

@ -100,6 +100,9 @@ kube_network_plugin: calico
# Determines if calico-rr group exists # Determines if calico-rr group exists
peer_with_calico_rr: "{{ 'calico-rr' in groups and groups['calico-rr']|length > 0 }}" 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. # Kubernetes internal network for services, unused block of space.
kube_service_addresses: 10.233.0.0/18 kube_service_addresses: 10.233.0.0/18

View file

@ -41,6 +41,7 @@ calico_felix_prometheusgometricsenabled: "true"
calico_felix_prometheusprocessmetricsenabled: "true" calico_felix_prometheusprocessmetricsenabled: "true"
### check latest version https://github.com/projectcalico/calico-upgrade/releases ### check latest version https://github.com/projectcalico/calico-upgrade/releases
calico_upgrade_enabled: true
calico_upgrade_version: v1.0.5 calico_upgrade_version: v1.0.5
# Should calico ignore kernel's RPF check setting, # Should calico ignore kernel's RPF check setting,
@ -56,4 +57,4 @@ calico_node_ignorelooserpf: false
calico_baremetal_nodename: "{{ inventory_hostname }}" calico_baremetal_nodename: "{{ inventory_hostname }}"
### do not enable this, this is detected in scope of tasks, this is just a default value ### do not enable this, this is detected in scope of tasks, this is just a default value
calico_upgrade_needed: false calico_upgrade_needed: false

View file

@ -147,9 +147,28 @@
with_items: with_items:
- "{{ peers|default([]) }}" - "{{ peers|default([]) }}"
when: when:
- calico_version_on_server.stdout|version_compare('v3.0.0', '>') or calico_upgrade_enabled
- peer_with_router|default(false) - peer_with_router|default(false)
- inventory_hostname in groups['k8s-cluster'] - 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 - name: Calico | Configure peering with route reflectors
shell: > shell: >
echo '{ echo '{
@ -169,9 +188,31 @@
with_items: with_items:
- "{{ groups['calico-rr'] | default([]) }}" - "{{ groups['calico-rr'] | default([]) }}"
when: 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'] - 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 - name: Calico | Create calico manifests
template: template:

View file

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