fix for calico with kdd datastore (#4922)

* fix for calico with kdd datastore

* remove AS number from daemonset

* revert changes to canal

* additionnal fixes for kdd datastore in calico
This commit is contained in:
Julian Tabel 2019-07-08 11:20:03 +02:00 committed by Matthew Mosesohn
parent 53032a6695
commit dc16ab92f4
5 changed files with 40 additions and 26 deletions

View file

@ -10,16 +10,10 @@
run_once: yes run_once: yes
- name: "Get current version of calico cluster version" - name: "Get current version of calico cluster version"
shell: "{{ bin_dir }}/calicoctl version | grep 'Cluster Version:' | awk '{ print $3}'" shell: "{{ bin_dir }}/calicoctl.sh version | grep 'Cluster Version:' | awk '{ print $3}'"
register: calico_version_on_server register: calico_version_on_server
run_once: yes run_once: yes
changed_when: false changed_when: false
environment:
ETCD_ENDPOINTS: "{{ etcd_access_addresses }}"
ETCD_CA_CERT_FILE: "{{ calico_cert_dir }}/ca_cert.crt"
ETCD_CERT_FILE: "{{ calico_cert_dir }}/cert.crt"
ETCD_KEY_FILE: "{{ calico_cert_dir }}/key.pem"
- name: "Determine if calico upgrade is needed" - name: "Determine if calico upgrade is needed"
block: block:

View file

@ -35,7 +35,7 @@
- name: Calico | Install calicoctl wrapper script - name: Calico | Install calicoctl wrapper script
template: template:
src: calicoctl.sh.j2 src: "calicoctl.{{ calico_datastore }}.sh.j2"
dest: "{{ bin_dir }}/calicoctl.sh" dest: "{{ bin_dir }}/calicoctl.sh"
mode: 0755 mode: 0755
owner: root owner: root
@ -73,6 +73,32 @@
- 'calico_conf.stdout == "0"' - 'calico_conf.stdout == "0"'
- calico_pool_cidr is defined - calico_pool_cidr is defined
- name: Calico | Create calico manifests for kdd
template:
src: "{{ item.file }}.j2"
dest: "{{ kube_config_dir }}/{{ item.file }}"
with_items:
- {name: calico, file: kdd-crds.yml, type: kdd}
register: calico_node_kdd_manifest
when:
- inventory_hostname in groups['kube-master']
- calico_datastore == "kdd"
- name: Start Calico resources
kube:
name: "{{ item.item.name }}"
namespace: "kube-system"
kubectl: "{{ bin_dir }}/kubectl"
resource: "{{ item.item.type }}"
filename: "{{ kube_config_dir }}/{{ item.item.file }}"
state: "latest"
with_items:
- "{{ calico_node_kdd_manifest.results }}"
when:
- inventory_hostname == groups['kube-master'][0] and not item is skipped
loop_control:
label: "{{ item.item.file }}"
- name: Calico | Configure calico network pool (v3.0.0 <= version < v3.3.0) - name: Calico | Configure calico network pool (v3.0.0 <= version < v3.3.0)
shell: > shell: >
echo " echo "
@ -180,9 +206,10 @@
"asNumber": "{{ local_as }}" "asNumber": "{{ local_as }}"
}, },
"orchRefs":[{"nodeName":"{{ inventory_hostname }}","orchestrator":"k8s"}] "orchRefs":[{"nodeName":"{{ inventory_hostname }}","orchestrator":"k8s"}]
}}' | {{ bin_dir }}/calicoctl.sh create --skip-exists -f - }}' | {{ bin_dir }}/calicoctl.sh {{ 'apply -f -' if calico_datastore == "kdd" else 'create --skip-exists -f -' }}
retries: 4 retries: 4
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
delegate_to: "{{ groups['kube-master'][0] }}"
when: when:
- calico_version is version('v3.0.0', '>=') - calico_version is version('v3.0.0', '>=')
- peer_with_router|default(false) - peer_with_router|default(false)
@ -230,6 +257,7 @@
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
with_items: with_items:
- "{{ peers|selectattr('scope','undefined')|list|default([]) | union(peers|selectattr('scope','defined')|selectattr('scope','equalto', 'node')|list|default([])) }}" - "{{ peers|selectattr('scope','undefined')|list|default([]) | union(peers|selectattr('scope','defined')|selectattr('scope','equalto', 'node')|list|default([])) }}"
delegate_to: "{{ groups['kube-master'][0] }}"
when: when:
- calico_version is version('v3.0.0', '>=') - calico_version is version('v3.0.0', '>=')
- peer_with_router|default(false) - peer_with_router|default(false)
@ -269,6 +297,7 @@
with_items: with_items:
- "{{ peers|selectattr('scope','defined')|selectattr('scope','equalto', 'global')|list|default([]) }}" - "{{ peers|selectattr('scope','defined')|selectattr('scope','equalto', 'global')|list|default([]) }}"
run_once: true run_once: true
delegate_to: "{{ groups['kube-master'][0] }}"
when: when:
- calico_version | version_compare('v3.0.0', '>=') - calico_version | version_compare('v3.0.0', '>=')
- peer_with_router|default(false) - peer_with_router|default(false)
@ -309,6 +338,7 @@
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
with_items: with_items:
- "{{ groups['calico-rr'] | default([]) }}" - "{{ groups['calico-rr'] | default([]) }}"
delegate_to: "{{ groups['kube-master'][0] }}"
when: when:
- calico_version is version('v3.0.0', '>=') - calico_version is version('v3.0.0', '>=')
- peer_with_calico_rr|default(false) - peer_with_calico_rr|default(false)
@ -351,17 +381,6 @@
- inventory_hostname in groups['kube-master'] - inventory_hostname in groups['kube-master']
- rbac_enabled or item.type not in rbac_resources - rbac_enabled or item.type not in rbac_resources
- name: Calico | Create calico manifests for kdd
template:
src: "{{ item.file }}.j2"
dest: "{{ kube_config_dir }}/{{ item.file }}"
with_items:
- {name: calico, file: kdd-crds.yml, type: kdd}
register: calico_node_kdd_manifest
when:
- inventory_hostname in groups['kube-master']
- calico_datastore == "kdd"
- name: Calico | Create calico manifests for typha - name: Calico | Create calico manifests for typha
template: template:
src: "{{ item.file }}.j2" src: "{{ item.file }}.j2"

View file

@ -145,11 +145,6 @@ spec:
# Wait for the datastore. # Wait for the datastore.
- name: WAIT_FOR_DATASTORE - name: WAIT_FOR_DATASTORE
value: "true" value: "true"
# Set based on the k8s node name.
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{% endif %} {% endif %}
# Choose the backend to use. # Choose the backend to use.
- name: CALICO_NETWORKING_BACKEND - name: CALICO_NETWORKING_BACKEND
@ -189,7 +184,7 @@ spec:
# should be set in etcd before deployment # should be set in etcd before deployment
# # Configure the IP Pool from which Pod IPs will be chosen. # # Configure the IP Pool from which Pod IPs will be chosen.
# - name: CALICO_IPV4POOL_CIDR # - name: CALICO_IPV4POOL_CIDR
# value: "192.168.0.0/16" # value: "{{ calico_pool_cidr | default(kube_pods_subnet) }}"
- name: CALICO_IPV4POOL_IPIP - name: CALICO_IPV4POOL_IPIP
value: "{{ calico_ipv4pool_ipip }}" value: "{{ calico_ipv4pool_ipip }}"
# Disable IPv6 on Kubernetes. # Disable IPv6 on Kubernetes.

View file

@ -0,0 +1,6 @@
#!/bin/bash
DATASTORE_TYPE=kubernetes \
{% if inventory_hostname in groups['kube-master'] %}
KUBECONFIG={{ kube_config_dir }}/admin.conf \
{% endif %}
{{ bin_dir }}/calicoctl "$@"