104 lines
2.6 KiB
Text
104 lines
2.6 KiB
Text
|
#jinja2: trim_blocks: True, lstrip_blocks: True
|
||
|
# yamllint disable-file
|
||
|
---
|
||
|
|
||
|
# Create layer3 configuration
|
||
|
{% for community_name, community in metallb_config.layer3.communities.items() %}
|
||
|
---
|
||
|
apiVersion: metallb.io/v1beta1
|
||
|
kind: Community
|
||
|
metadata:
|
||
|
name: "{{ community_name }}"
|
||
|
namespace: "{{ namespace_name }}"
|
||
|
spec:
|
||
|
community:
|
||
|
- name: "{{ community_name }}"
|
||
|
value: "{{ community }}"
|
||
|
{% endfor %}
|
||
|
|
||
|
{% for peer_name, peer in metallb_config.layer3.metallb_peers.items() %}
|
||
|
|
||
|
# BGPAdvertisement is used to advertise the specified address pool to the BGP peer.
|
||
|
# Local BGP Advertisement specifies that the IP specified in the address pool will be used as source address for traffic entering your cluster from the remote peer.
|
||
|
---
|
||
|
apiVersion: metallb.io/v1beta1
|
||
|
kind: BGPAdvertisement
|
||
|
metadata:
|
||
|
name: "{{ peer_name }}-local"
|
||
|
namespace: "{{ namespace_name }}"
|
||
|
spec:
|
||
|
ipAddressPools:
|
||
|
{% for address_pool in peer.address_pool %}
|
||
|
- "{{ address_pool }}"
|
||
|
{% endfor %}
|
||
|
{% if peer.advanced | length > 0 %}
|
||
|
aggregationLength: 32
|
||
|
localpref: "{{ peer.localpref | default ("100") }}"
|
||
|
communities:
|
||
|
{% for community in peer.communities %}
|
||
|
- "{{ community }}"
|
||
|
{% endfor %}
|
||
|
{% endif %}
|
||
|
|
||
|
|
||
|
# External GBP Advertisement. The IP range specied in the address pool is advertized to the BGP peer.
|
||
|
---
|
||
|
apiVersion: metallb.io/v1beta1
|
||
|
kind: BGPAdvertisement
|
||
|
metadata:
|
||
|
name: "{{ peer_name }}-external"
|
||
|
namespace: "{{ namespace_name }}"
|
||
|
spec:
|
||
|
ipAddressPools:
|
||
|
{% for address_pool in peer.address_pool %}
|
||
|
- "{{ address_pool }}"
|
||
|
{% endfor %}
|
||
|
{% if peer.advanced | length > 0 %}
|
||
|
aggregationLength: "{{ peer.aggregation_length }}"
|
||
|
{% endif %}
|
||
|
|
||
|
|
||
|
# Configuration for the GBP peer.
|
||
|
---
|
||
|
apiVersion: metallb.io/v1beta2
|
||
|
kind: BGPPeer
|
||
|
metadata:
|
||
|
name: "{{ peer_name }}"
|
||
|
namespace: "{{ namespace_name }}"
|
||
|
spec:
|
||
|
myASN: {{ peer.my_asn }}
|
||
|
peerASN: {{ peer.peer_asn }}
|
||
|
peerAddress: {{ peer.peer_address }}
|
||
|
|
||
|
{% if peer.peer_port is defined %}
|
||
|
peerPort: {{ peer.peer_port }}
|
||
|
{% else %}
|
||
|
peerPort: {{ metallb_config.layer3.defaults.peer_port }}
|
||
|
{% endif %}
|
||
|
|
||
|
{% if peer.password is defined %}
|
||
|
password: "{{ peer.password }}"
|
||
|
{% endif %}
|
||
|
|
||
|
{% if peer.router_id is defined %}
|
||
|
routerID: "{{ peer.router_id }}"
|
||
|
{% endif %}
|
||
|
|
||
|
{% if peer.hold_time is defined %}
|
||
|
holdTime: {{ peer.hold_time }}
|
||
|
{% else %}
|
||
|
holdTime: {{ metallb_config.layer3.defaults.hold_time }}
|
||
|
{% endif %}
|
||
|
|
||
|
{% if peer.keepalive_time is defined %}
|
||
|
keepaliveTime: {{ peer.keepalive_time }}
|
||
|
{% else %}
|
||
|
keepaliveTime: {{ metallb_config.layer3.defaults.keepalive_time }}
|
||
|
{% endif %}
|
||
|
|
||
|
{% if peer.multihop is defined %}
|
||
|
elayer3MultiHop: "{{ peer.multihop }}"
|
||
|
{% endif %}
|
||
|
|
||
|
{% endfor %}
|