mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-03-05 02:31:07 -03:30
Support new version of 'calicoctl' (>=v1.0.0)
Since version 'v1.0.0-beta' calicoctl is written in Go and its API differs from old Python based utility. Added support of both old and new version of the utility.
This commit is contained in:
@@ -78,30 +78,54 @@
|
||||
delegate_to: "{{groups['etcd'][0]}}"
|
||||
run_once: true
|
||||
|
||||
- name: Calico | Define ipip pool argument
|
||||
- name: Calico | Check calicoctl version
|
||||
run_once: true
|
||||
set_fact:
|
||||
legacy_calicoctl: "{{ calicoctl_image_tag | version_compare('v1.0.0', '<') }}"
|
||||
|
||||
- name: Calico | Configure calico network pool
|
||||
shell: >
|
||||
echo '{
|
||||
"kind": "ipPool",
|
||||
"spec": {"disabled": false, "ipip": {"enabled": {{ cloud_provider is defined or ipip }}},
|
||||
"nat-outgoing": {{ nat_outgoing|default(false) and not peer_with_router|default(false) }}},
|
||||
"apiVersion": "v1",
|
||||
"metadata": {"cidr": "{{ kube_pods_subnet }}"}
|
||||
}'
|
||||
| {{ bin_dir }}/calicoctl create -f -
|
||||
environment:
|
||||
NO_DEFAULT_POOLS: true
|
||||
run_once: true
|
||||
when: (not legacy_calicoctl and
|
||||
"Key not found" in calico_conf.stdout or "nodes" not in calico_conf.stdout)
|
||||
|
||||
- name: Calico (old) | Define ipip pool argument
|
||||
run_once: true
|
||||
set_fact:
|
||||
ipip_arg: "--ipip"
|
||||
when: cloud_provider is defined or ipip|default(false)
|
||||
when: (legacy_calicoctl and
|
||||
cloud_provider is defined or ipip)
|
||||
|
||||
- name: Calico | Define nat-outgoing pool argument
|
||||
- name: Calico (old) | Define nat-outgoing pool argument
|
||||
run_once: true
|
||||
set_fact:
|
||||
nat_arg: "--nat-outgoing"
|
||||
when: nat_outgoing|default(false) and not peer_with_router|default(false)
|
||||
when: (legacy_calicoctl and
|
||||
nat_outgoing|default(false) and not peer_with_router|default(false))
|
||||
|
||||
- name: Calico | Define calico pool task name
|
||||
- name: Calico (old) | Define calico pool task name
|
||||
run_once: true
|
||||
set_fact:
|
||||
pool_task_name: "with options {{ ipip_arg|default('') }} {{ nat_arg|default('') }}"
|
||||
when: ipip_arg|default(false) or nat_arg|default(false)
|
||||
when: (legacy_calicoctl and ipip_arg|default(false) or nat_arg|default(false))
|
||||
|
||||
- name: Calico | Configure calico network pool {{ pool_task_name|default('') }}
|
||||
- name: Calico (old) | Configure calico network pool {{ pool_task_name|default('') }}
|
||||
command: "{{ bin_dir}}/calicoctl pool add {{ kube_pods_subnet }} {{ ipip_arg|default('') }} {{ nat_arg|default('') }}"
|
||||
environment:
|
||||
NO_DEFAULT_POOLS: true
|
||||
run_once: true
|
||||
when: '"Key not found" in calico_conf.stdout or "nodes" not in calico_conf.stdout'
|
||||
when: (legacy_calicoctl and
|
||||
"Key not found" in calico_conf.stdout or "nodes" not in calico_conf.stdout)
|
||||
|
||||
- name: Calico | Get calico configuration from etcd
|
||||
command: |-
|
||||
@@ -154,10 +178,30 @@
|
||||
enabled: yes
|
||||
|
||||
- name: Calico | Disable node mesh
|
||||
shell: "{{ bin_dir }}/calicoctl bgp node-mesh off"
|
||||
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
|
||||
shell: "{{ bin_dir }}/calicoctl config set nodeToNodeMesh off"
|
||||
when: (not legacy_calicoctl and
|
||||
peer_with_router|default(false) and inventory_hostname in groups['kube-node'])
|
||||
|
||||
- name: Calico | Configure peering with router(s)
|
||||
shell: >
|
||||
echo '{
|
||||
"kind": "bgppeer",
|
||||
"spec": {"asNumber": {{ item.as }}},
|
||||
"apiVersion": "v1",
|
||||
"metadata": {"node": "rack1-host1", "scope": "node", "peerIP": "{{ item.router_id }}"}
|
||||
}'
|
||||
| {{ bin_dir }}/calicoctl create -f -
|
||||
with_items: peers
|
||||
when: (not legacy_calicoctl and
|
||||
peer_with_router|default(false) and inventory_hostname in groups['kube-node'])
|
||||
|
||||
- name: Calico (old) | Disable node mesh
|
||||
shell: "{{ bin_dir }}/calicoctl bgp node-mesh off"
|
||||
when: (legacy_calicoctl and
|
||||
peer_with_router|default(false) and inventory_hostname in groups['kube-node'])
|
||||
|
||||
- name: Calico (old) | Configure peering with router(s)
|
||||
shell: "{{ bin_dir }}/calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }}"
|
||||
with_items: peers
|
||||
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
|
||||
when: (legacy_calicoctl and
|
||||
peer_with_router|default(false) and inventory_hostname in groups['kube-node'])
|
||||
|
||||
Reference in New Issue
Block a user