Browse Source
[calico] calico rr supports multiple groups (#9134)
[calico] calico rr supports multiple groups (#9134)
* update calico rr * fix bgppeer conf * fix yamllint * fix ansible lint * fix calico deploy * fix yamllint * fix some typopull/9191/head
Samuel Liu
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 182 additions and 132 deletions
Split View
Diff Options
-
2docs/calico.md
-
9roles/network_plugin/calico/rr/tasks/update-node.yml
-
140roles/network_plugin/calico/tasks/install.yml
-
86roles/network_plugin/calico/tasks/peer_with_calico_rr.yml
-
77roles/network_plugin/calico/tasks/peer_with_router.yml
@ -0,0 +1,86 @@ |
|||
--- |
|||
- name: Calico | Set lable for groups nodes # noqa 301 305 |
|||
shell: "{{ bin_dir }}/calicoctl.sh label node {{ inventory_hostname }} calico-group-id={{ calico_group_id }} --overwrite" |
|||
changed_when: false |
|||
register: calico_group_id_label |
|||
until: calico_group_id_label is succeeded |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
retries: 10 |
|||
when: |
|||
- calico_group_id is defined |
|||
|
|||
- name: Calico | Configure peering with route reflectors at global scope |
|||
command: |
|||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -" |
|||
# revert when it's already a string |
|||
stdin: "{{ stdin is string | ternary(stdin, stdin|to_json) }}" |
|||
vars: |
|||
stdin: > |
|||
{"apiVersion": "projectcalico.org/v3", |
|||
"kind": "BGPPeer", |
|||
"metadata": { |
|||
"name": "{{ calcio_rr_id }}-to-node" |
|||
}, |
|||
"spec": { |
|||
"peerSelector": "calico-rr-id == '{{ calcio_rr_id }}'", |
|||
"nodeSelector": "calico-group-id == '{{ calico_group_id }}'" |
|||
}} |
|||
register: output |
|||
retries: 4 |
|||
until: output.rc == 0 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
when: |
|||
- calcio_rr_id is defined |
|||
- calico_group_id is defined |
|||
- inventory_hostname in groups['calico_rr'] |
|||
|
|||
- name: Calico | Configure peering with route reflectors at global scope |
|||
command: |
|||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -" |
|||
# revert when it's already a string |
|||
stdin: "{{ stdin is string | ternary(stdin, stdin|to_json) }}" |
|||
vars: |
|||
stdin: > |
|||
{"apiVersion": "projectcalico.org/v3", |
|||
"kind": "BGPPeer", |
|||
"metadata": { |
|||
"name": "peer-to-rrs" |
|||
}, |
|||
"spec": { |
|||
"nodeSelector": "!has(i-am-a-route-reflector)", |
|||
"peerSelector": "has(i-am-a-route-reflector)" |
|||
}} |
|||
register: output |
|||
retries: 4 |
|||
until: output.rc == 0 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
with_items: |
|||
- "{{ groups['calico_rr'] | default([]) }}" |
|||
when: |
|||
- inventory_hostname == groups['kube_control_plane'][0] |
|||
- calcio_rr_id is not defined or calico_group_id is not defined |
|||
|
|||
- name: Calico | Configure route reflectors to peer with each other |
|||
command: |
|||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -" |
|||
# revert when it's already a string |
|||
stdin: "{{ stdin is string | ternary(stdin, stdin|to_json) }}" |
|||
vars: |
|||
stdin: > |
|||
{"apiVersion": "projectcalico.org/v3", |
|||
"kind": "BGPPeer", |
|||
"metadata": { |
|||
"name": "rr-mesh" |
|||
}, |
|||
"spec": { |
|||
"nodeSelector": "has(i-am-a-route-reflector)", |
|||
"peerSelector": "has(i-am-a-route-reflector)" |
|||
}} |
|||
register: output |
|||
retries: 4 |
|||
until: output.rc == 0 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
with_items: |
|||
- "{{ groups['calico_rr'] | default([]) }}" |
|||
when: |
|||
- inventory_hostname == groups['kube_control_plane'][0] |
@ -0,0 +1,77 @@ |
|||
--- |
|||
- name: Calico | Configure peering with router(s) at global scope |
|||
command: |
|||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -" |
|||
stdin: "{{ stdin is string | ternary(stdin, stdin|to_json) }}" |
|||
vars: |
|||
stdin: > |
|||
{"apiVersion": "projectcalico.org/v3", |
|||
"kind": "BGPPeer", |
|||
"metadata": { |
|||
"name": "global-{{ item.name | default(item.router_id|replace(':','-')) }}" |
|||
}, |
|||
"spec": { |
|||
"asNumber": "{{ item.as }}", |
|||
"peerIP": "{{ item.router_id }}" |
|||
}} |
|||
register: output |
|||
retries: 4 |
|||
until: output.rc == 0 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
with_items: |
|||
- "{{ peers|selectattr('scope','defined')|selectattr('scope','equalto', 'global')|list|default([]) }}" |
|||
when: |
|||
- inventory_hostname == groups['kube_control_plane'][0] |
|||
|
|||
- name: Calico | Configure node asNumber for per node peering |
|||
command: |
|||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -" |
|||
stdin: "{{ stdin is string | ternary(stdin, stdin|to_json) }}" |
|||
vars: |
|||
stdin: > |
|||
{"apiVersion": "projectcalico.org/v3", |
|||
"kind": "Node", |
|||
"metadata": { |
|||
"name": "{{ inventory_hostname }}" |
|||
}, |
|||
"spec": { |
|||
"bgp": { |
|||
"asNumber": "{{ local_as }}" |
|||
}, |
|||
"orchRefs":[{"nodeName":"{{ inventory_hostname }}","orchestrator":"k8s"}] |
|||
}} |
|||
register: output |
|||
retries: 4 |
|||
until: output.rc == 0 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
when: |
|||
- inventory_hostname in groups['k8s_cluster'] |
|||
- local_as is defined |
|||
- groups['calico_rr'] | default([]) | length == 0 |
|||
|
|||
- name: Calico | Configure peering with router(s) at node scope |
|||
command: |
|||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -" |
|||
stdin: "{{ stdin is string | ternary(stdin, stdin|to_json) }}" |
|||
vars: |
|||
stdin: > |
|||
{"apiVersion": "projectcalico.org/v3", |
|||
"kind": "BGPPeer", |
|||
"metadata": { |
|||
"name": "{{ inventory_hostname }}-{{ item.name | default(item.router_id|replace(':','-')) }}" |
|||
}, |
|||
"spec": { |
|||
"asNumber": "{{ item.as }}", |
|||
"node": "{{ inventory_hostname }}", |
|||
"peerIP": "{{ item.router_id }}", |
|||
"sourceAddress": "{{ item.sourceaddress|default('UseNodeIP') }}" |
|||
}} |
|||
register: output |
|||
retries: 4 |
|||
until: output.rc == 0 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
with_items: |
|||
- "{{ peers|selectattr('scope','undefined')|list|default([]) | union(peers|selectattr('scope','defined')|selectattr('scope','equalto', 'node')|list|default([])) }}" |
|||
delegate_to: "{{ groups['kube_control_plane'][0] }}" |
|||
when: |
|||
- inventory_hostname in groups['k8s_cluster'] |
Write
Preview
Loading…
Cancel
Save