parent
2faf53b039
commit
6245587dc8
|
@ -37,13 +37,16 @@
|
|||
when:
|
||||
- "calico_vxlan_mode in ['Always', 'CrossSubnet']"
|
||||
|
||||
- name: "Get current version of calico cluster version" # noqa 306
|
||||
shell: "{{ bin_dir }}/calicoctl.sh version | grep 'Cluster Version:' | awk '{ print $3}'"
|
||||
- name: "Get current version of calico cluster version"
|
||||
shell: "set -o pipefail && {{ bin_dir }}/calicoctl.sh version | grep 'Cluster Version:' | awk '{ print $3}'"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: calico_version_on_server
|
||||
async: 10
|
||||
poll: 3
|
||||
run_once: yes
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: "Determine if calico upgrade is needed"
|
||||
block:
|
||||
|
|
|
@ -85,9 +85,12 @@
|
|||
run_once: true
|
||||
when: calico_datastore == "etcd"
|
||||
|
||||
- name: Calico | Check if calico network pool has already been configured # noqa 306
|
||||
- name: Calico | Check if calico network pool has already been configured
|
||||
# noqa 306 - grep will exit 1 if no match found
|
||||
shell: >
|
||||
{{ bin_dir }}/calicoctl.sh get ippool | grep -w "{{ calico_pool_cidr | default(kube_pods_subnet) }}" | wc -l
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: calico_conf
|
||||
retries: 4
|
||||
until: calico_conf.rc == 0
|
||||
|
@ -132,9 +135,10 @@
|
|||
loop_control:
|
||||
label: "{{ item.item.file }}"
|
||||
|
||||
- name: Calico | Configure calico network pool (version < v3.3.0) # noqa 306
|
||||
shell: >
|
||||
echo "
|
||||
- name: Calico | Configure calico network pool (version < v3.3.0)
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{ "kind": "IPPool",
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
"metadata": {
|
||||
|
@ -144,26 +148,27 @@
|
|||
"cidr": "{{ calico_pool_cidr | default(kube_pods_subnet) }}",
|
||||
"ipipMode": "{{ calico_ipip_mode }}",
|
||||
"vxlanMode": "{{ calico_vxlan_mode }}",
|
||||
"natOutgoing": {{ nat_outgoing|default(false) and not peer_with_router|default(false) }} }} " | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
"natOutgoing": {{ nat_outgoing|default(false) and not peer_with_router|default(false) }} }}
|
||||
when:
|
||||
- inventory_hostname == groups['kube-master'][0]
|
||||
- 'calico_conf.stdout == "0"'
|
||||
- calico_version is version("v3.3.0", "<")
|
||||
|
||||
- name: Calico | Configure calico network pool (version >= v3.3.0) # noqa 306
|
||||
shell: >
|
||||
echo "
|
||||
- name: Calico | Configure calico network pool (version >= v3.3.0)
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{ "kind": "IPPool",
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
"metadata": {
|
||||
"name": "{{ calico_pool_name }}",
|
||||
},
|
||||
"spec": {
|
||||
"blockSize": "{{ calico_pool_blocksize | default(kube_network_node_prefix) }}",
|
||||
"blockSize": {{ calico_pool_blocksize | default(kube_network_node_prefix) }},
|
||||
"cidr": "{{ calico_pool_cidr | default(kube_pods_subnet) }}",
|
||||
"ipipMode": "{{ calico_ipip_mode }}",
|
||||
"vxlanMode": "{{ calico_vxlan_mode }}",
|
||||
"natOutgoing": {{ nat_outgoing|default(false) and not peer_with_router|default(false) }} }} " | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
"natOutgoing": {{ nat_outgoing|default(false) and not peer_with_router|default(false) }} }}
|
||||
when:
|
||||
- inventory_hostname == groups['kube-master'][0]
|
||||
- 'calico_conf.stdout == "0"'
|
||||
|
@ -177,9 +182,10 @@
|
|||
- inventory_hostname in groups['k8s-cluster']
|
||||
run_once: yes
|
||||
|
||||
- name: Calico | Set global as_num # noqa 306
|
||||
shell: >
|
||||
echo '
|
||||
- name: Calico | Set global as_num
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{ "kind": "BGPConfiguration",
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
"metadata": {
|
||||
|
@ -188,15 +194,16 @@
|
|||
"spec": {
|
||||
"logSeverityScreen": "Info",
|
||||
"nodeToNodeMeshEnabled": {{ nodeToNodeMeshEnabled|default('true') }} ,
|
||||
"asNumber": {{ global_as_num }} }} ' | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
"asNumber": {{ global_as_num }} }}
|
||||
changed_when: false
|
||||
when:
|
||||
- inventory_hostname == groups['kube-master'][0]
|
||||
|
||||
- name: Calico | Configure peering with router(s) at global scope # noqa 306
|
||||
shell: >
|
||||
echo '{
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
- name: Calico | Configure peering with router(s) at global scope
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{"apiVersion": "projectcalico.org/v3",
|
||||
"kind": "BGPPeer",
|
||||
"metadata": {
|
||||
"name": "global-{{ item.router_id }}"
|
||||
|
@ -204,7 +211,7 @@
|
|||
"spec": {
|
||||
"asNumber": "{{ item.as }}",
|
||||
"peerIP": "{{ item.router_id }}"
|
||||
}}' | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
}}
|
||||
register: output
|
||||
retries: 4
|
||||
until: output.rc == 0
|
||||
|
@ -215,10 +222,11 @@
|
|||
- inventory_hostname == groups['kube-master'][0]
|
||||
- peer_with_router|default(false)
|
||||
|
||||
- name: Calico | Configure peering with route reflectors at global scope # noqa 306
|
||||
shell: |
|
||||
echo '{
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
- name: Calico | Configure peering with route reflectors at global scope
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{"apiVersion": "projectcalico.org/v3",
|
||||
"kind": "BGPPeer",
|
||||
"metadata": {
|
||||
"name": "peer-to-rrs"
|
||||
|
@ -226,7 +234,7 @@
|
|||
"spec": {
|
||||
"nodeSelector": "!has(i-am-a-route-reflector)",
|
||||
"peerSelector": "has(i-am-a-route-reflector)"
|
||||
}}' | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
}}
|
||||
register: output
|
||||
retries: 4
|
||||
until: output.rc == 0
|
||||
|
@ -237,10 +245,11 @@
|
|||
- inventory_hostname == groups['kube-master'][0]
|
||||
- peer_with_calico_rr|default(false)
|
||||
|
||||
- name: Calico | Configure route reflectors to peer with each other # noqa 306
|
||||
shell: >
|
||||
echo '{
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
- name: Calico | Configure route reflectors to peer with each other
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{"apiVersion": "projectcalico.org/v3",
|
||||
"kind": "BGPPeer",
|
||||
"metadata": {
|
||||
"name": "rr-mesh"
|
||||
|
@ -248,7 +257,7 @@
|
|||
"spec": {
|
||||
"nodeSelector": "has(i-am-a-route-reflector)",
|
||||
"peerSelector": "has(i-am-a-route-reflector)"
|
||||
}}' | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
}}
|
||||
register: output
|
||||
retries: 4
|
||||
until: output.rc == 0
|
||||
|
@ -310,10 +319,11 @@
|
|||
- inventory_hostname not in groups['kube-master']
|
||||
- calico_datastore == "kdd"
|
||||
|
||||
- name: Calico | Configure node asNumber for per node peering # noqa 306
|
||||
shell: >
|
||||
echo '{
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
- name: Calico | Configure node asNumber for per node peering
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{"apiVersion": "projectcalico.org/v3",
|
||||
"kind": "Node",
|
||||
"metadata": {
|
||||
"name": "{{ inventory_hostname }}"
|
||||
|
@ -323,7 +333,7 @@
|
|||
"asNumber": "{{ local_as }}"
|
||||
},
|
||||
"orchRefs":[{"nodeName":"{{ inventory_hostname }}","orchestrator":"k8s"}]
|
||||
}}' | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
}}
|
||||
register: output
|
||||
retries: 4
|
||||
until: output.rc == 0
|
||||
|
@ -334,10 +344,11 @@
|
|||
- local_as is defined
|
||||
- groups['calico-rr'] | default([]) | length == 0
|
||||
|
||||
- name: Calico | Configure peering with router(s) at node scope # noqa 306
|
||||
shell: >
|
||||
echo '{
|
||||
"apiVersion": "projectcalico.org/v3",
|
||||
- name: Calico | Configure peering with router(s) at node scope
|
||||
command:
|
||||
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
|
||||
stdin: >
|
||||
{"apiVersion": "projectcalico.org/v3",
|
||||
"kind": "BGPPeer",
|
||||
"metadata": {
|
||||
"name": "{{ inventory_hostname }}-{{ item.router_id }}"
|
||||
|
@ -346,7 +357,7 @@
|
|||
"asNumber": "{{ item.as }}",
|
||||
"node": "{{ inventory_hostname }}",
|
||||
"peerIP": "{{ item.router_id }}"
|
||||
}}' | {{ bin_dir }}/calicoctl.sh apply -f -
|
||||
}}
|
||||
register: output
|
||||
retries: 4
|
||||
until: output.rc == 0
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
---
|
||||
- name: Calico | Get kubelet hostname # noqa 306
|
||||
- name: Calico | Get kubelet hostname
|
||||
shell: >-
|
||||
{{ bin_dir }}/kubectl get node -o custom-columns='NAME:.metadata.name,INTERNAL-IP:.status.addresses[?(@.type=="InternalIP")].address'
|
||||
set -o pipefail && {{ bin_dir }}/kubectl get node -o custom-columns='NAME:.metadata.name,INTERNAL-IP:.status.addresses[?(@.type=="InternalIP")].address'
|
||||
| egrep "{{ ansible_all_ipv4_addresses | join('$|') }}$" | cut -d" " -f1
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: calico_kubelet_name
|
||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||
when:
|
||||
|
|
Loading…
Reference in New Issue