Skip to content

Commit

Permalink
Add serviceExternalIPs option for calico installation (kubernetes-sig…
Browse files Browse the repository at this point in the history
  • Loading branch information
anjkl authored and MathildeLeroi committed Feb 26, 2021
1 parent 75d648c commit f685845
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/calico.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ This can be enabled by setting the following variable as follow in group_vars (k
calico_advertise_cluster_ips: true
```

Since calico 3.10, Calico supports advertising Kubernetes service ExternalIPs over BGP in addition to cluster IPs advertising.
This can be enabled by setting the following variable in group_vars (k8s-cluster/k8s-net-calico.yml)

```yml
calico_advertise_service_external_ips:
- x.x.x.x/24
- y.y.y.y/32
```

### Optional : Define global AS number

Optional parameter `global_as_num` defines Calico global AS number (`/calico/bgp/v1/global/as_num` etcd key).
Expand Down
5 changes: 5 additions & 0 deletions inventory/sample/group_vars/k8s-cluster/k8s-net-calico.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
# Advertise Cluster IPs
# calico_advertise_cluster_ips: true

# Advertise Service External IPs
# calico_advertise_service_external_ips:
# - x.x.x.x/24
# - y.y.y.y/32

# Choose data store type for calico: "etcd" or "kdd" (kubernetes datastore)
# calico_datastore: "etcd"

Expand Down
3 changes: 3 additions & 0 deletions roles/network_plugin/calico/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ global_as_num: "64512"
# defaults. The value should be a number, not a string.
# calico_mtu: 1500

# Advertise Service External IPs
calico_advertise_service_external_ips: []

# Limits for apps
calico_node_memory_limit: 500M
calico_node_cpu_limit: 300m
Expand Down
7 changes: 7 additions & 0 deletions roles/network_plugin/calico/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@
- 'calico_conf.stdout == "0"'
- calico_version is version("v3.3.0", ">=")

- name: Populate Service External IPs
set_fact:
_service_external_ips: "{{ _service_external_ips|default([]) + [ {'cidr': item} ] }}"
with_items: "{{ calico_advertise_service_external_ips }}"
run_once: yes

- name: "Determine nodeToNodeMesh needed state"
set_fact:
nodeToNodeMeshEnabled: "false"
Expand All @@ -194,6 +200,7 @@
"spec": {
"logSeverityScreen": "Info",
"nodeToNodeMeshEnabled": {{ nodeToNodeMeshEnabled|default('true') }} ,
"serviceExternalIPs": {{ _service_external_ips|default([]) }},
"asNumber": {{ global_as_num }} }}
changed_when: false
when:
Expand Down

0 comments on commit f685845

Please sign in to comment.