Calico: Ability to define the default IPPool CIDR (instead of kube_pods_subnet) (#4131)

* Calico: Ability to define the default IPPool CIDR (instead of kube_pods_subnet)

* Documentation for calico_pool_cidr (and calico_advertise_cluster_ips which has been forgotten...)
This commit is contained in:
Erwan Miran
2019-01-31 22:39:13 +01:00
committed by Kubernetes Prow Robot
parent 40f1c51ec3
commit f6d60a7e89
4 changed files with 32 additions and 4 deletions

View File

@@ -75,13 +75,23 @@
- name: Calico | Check if calico network pool has already been configured
shell: >
{{ bin_dir }}/calicoctl get ippool | grep -w "{{ kube_pods_subnet }}" | wc -l
{{ bin_dir }}/calicoctl get ippool | grep -w "{{ calico_pool_cidr | default(kube_pods_subnet) }}" | wc -l
register: calico_conf
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
delegate_to: "{{ groups['kube-master'][0] }}"
run_once: true
- name: Calico | Ensure that calico_pool_cidr is within kube_pods_subnet when defined
assert:
that: "[calico_pool_cidr] | ipaddr(kube_pods_subnet) | length == 1"
msg: "{{ calico_pool_cidr }} is not within or equal to {{ kube_pods_subnet }}"
delegate_to: localhost
run_once: true
when:
- 'calico_conf.stdout == "0"'
- calico_pool_cidr is defined
- name: Calico | Configure calico network pool
shell: >
echo "
@@ -91,7 +101,7 @@
"name": "{{ calico_pool_name }}",
},
"spec": {
"cidr": "{{ kube_pods_subnet }}",
"cidr": "{{ calico_pool_cidr | default(kube_pods_subnet) }}",
"ipipMode": "{{ ipip_mode }}",
"natOutgoing": {{ nat_outgoing|default(false) and not peer_with_router|default(false) }} }} " | {{ bin_dir }}/calicoctl create -f -
run_once: true
@@ -107,7 +117,7 @@
"spec": {"disabled": false, "ipip": {"enabled": {{ ipip }}, "mode": "{{ ipip_mode|lower }}"},
"nat-outgoing": {{ nat_outgoing|default(false) and not peer_with_router|default(false) }}},
"apiVersion": "v1",
"metadata": {"cidr": "{{ kube_pods_subnet }}"}
"metadata": {"cidr": "{{ calico_pool_cidr | default(kube_pods_subnet) }}"}
}' | {{ bin_dir }}/calicoctl apply -f -
environment:
NO_DEFAULT_POOLS: true

View File

@@ -17,7 +17,7 @@
"ipam": {
"type": "calico-ipam",
"assign_ipv4": "true",
"ipv4_pools": ["{{ kube_pods_subnet }}"]
"ipv4_pools": ["{{ calico_pool_cidr | default(kube_pods_subnet) }}"]
},
{% if enable_network_policy %}
"policy": {