---

# This is default bgp configuration for calico bird

apiVersion: crd.projectcalico.org/v1
kind: BGPConfiguration
metadata:
  name: default
spec:
  nodeToNodeMeshEnabled: {{ plugins['calico']['fullmesh'] }}
  {%- if plugins['calico']['announceServices'] %}
  serviceClusterIPs:
  - cidr: {{ services['kubeadm']['networking']['serviceSubnet'] }}
  {%- endif %}
  asNumber: {{ plugins['calico']['defaultAsNumber'] }}


{% if not plugins['calico']['fullmesh'] %}
---
# This is for peering with route-reflectors

apiVersion: crd.projectcalico.org/v1
kind: BGPPeer
metadata:
  name: peer-with-route-reflectors
spec:
  nodeSelector: all()
  peerSelector: route-reflector == 'True'

{% endif %}


{%- for peer in plugins['calico']['globalBgpPeers'] -%}
---
apiVersion: crd.projectcalico.org/v1
kind: BGPPeer
metadata:
  name: peer-with-route-reflectors-{{ peer['as'] }}-{{ peer['ip'] }}
spec:
  asNumber: {{ peer['as'] }}
  peerIP: {{ peer['ip'] }}
{%- endfor %}
