Browse Source
Update MetalLB and switch to CRD notation. (#9120)
Update MetalLB and switch to CRD notation. (#9120)
Signed-off-by: Jeroen Rijken <jeroen.rijken@xs4all.nl>pull/9986/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 2171 additions and 327 deletions
Unified View
Diff Options
-
2README.md
-
200docs/metallb.md
-
62inventory/sample/group_vars/k8s_cluster/addons.yml
-
2roles/download/defaults/main.yml
-
31roles/kubernetes-apps/metallb/tasks/main.yml
-
19roles/kubernetes-apps/metallb/templates/layer2.yaml.j2
-
125roles/kubernetes-apps/metallb/templates/layer3.yaml.j2
-
54roles/kubernetes-apps/metallb/templates/metallb-config.yml.j2
-
1981roles/kubernetes-apps/metallb/templates/metallb.yml.j2
-
22roles/kubernetes-apps/metallb/templates/pools.yaml.j2
@ -0,0 +1,19 @@ |
|||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True |
||||
|
# yamllint disable-file |
||||
|
--- |
||||
|
|
||||
|
# Create layer2 configuration |
||||
|
{% for entry in metallb_config.layer2 %} |
||||
|
|
||||
|
--- |
||||
|
# L2 Configuration |
||||
|
apiVersion: metallb.io/v1beta1 |
||||
|
kind: L2Advertisement |
||||
|
metadata: |
||||
|
name: "{{ entry }}" |
||||
|
namespace: metallb-system |
||||
|
spec: |
||||
|
ipAddressPools: |
||||
|
- "{{ entry }}" |
||||
|
|
||||
|
{% endfor %} |
@ -0,0 +1,125 @@ |
|||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True |
||||
|
# yamllint disable-file |
||||
|
--- |
||||
|
# Create layer3 configuration |
||||
|
{% if metallb_config.layer3.communities is defined %} |
||||
|
{% for community_name, community in metallb_config.layer3.communities.items() %} |
||||
|
--- |
||||
|
apiVersion: metallb.io/v1beta1 |
||||
|
kind: Community |
||||
|
metadata: |
||||
|
name: "{{ community_name }}" |
||||
|
namespace: metallb-system |
||||
|
spec: |
||||
|
communities: |
||||
|
- name: "{{ community_name }}" |
||||
|
value: "{{ community }}" |
||||
|
{% endfor %} |
||||
|
{% endif %} |
||||
|
--- |
||||
|
apiVersion: metallb.io/v1beta1 |
||||
|
kind: Community |
||||
|
metadata: |
||||
|
name: well-known |
||||
|
namespace: metallb-system |
||||
|
spec: |
||||
|
communities: |
||||
|
- name: no-export |
||||
|
value: 65535:65281 |
||||
|
- name: no-advertise |
||||
|
value: 65535:65282 |
||||
|
- name: local-as |
||||
|
value: 65535:65283 |
||||
|
- name: nopeer |
||||
|
value: 65535:65284 |
||||
|
|
||||
|
# BGPAdvertisement is used to advertise address pools to the BGP peer. Specific pools can be listed to be advertised. |
||||
|
# Local BGP Advertisement specifies that the IP specified in the address pool will be used as remote source address for traffic entering your cluster from the remote peer. |
||||
|
# When using this option, be sure to use a subnet and routable IP for your address pool. |
||||
|
# This is good: 10.0.0.10/24. This is also good: 10.0.0.129/25. This is bad: 10.0.0.0/24. This is also bad: 10.0.0.128/25. |
||||
|
# In this example, 10.0.0.10 will be used as the remote source address. |
||||
|
# This is also bad: 10.0.0.10-10.0.0.25. Remember: you are working with aggregationLength, which specifies a subnet, not an IP range! |
||||
|
# The no-advertise community is set on the local advertisement to prevent this route from being published to the BGP peer. |
||||
|
# Your aggregationLength ideally is the same size as your address pool. |
||||
|
|
||||
|
{% for peer_name, peer in metallb_config.layer3.metallb_peers.items() %} |
||||
|
|
||||
|
{% if peer.aggregation_length is defined and peer.aggregation_length <= 30 %} |
||||
|
|
||||
|
--- |
||||
|
apiVersion: metallb.io/v1beta1 |
||||
|
kind: BGPAdvertisement |
||||
|
metadata: |
||||
|
name: "{{ peer_name }}-local" |
||||
|
namespace: metallb-system |
||||
|
spec: |
||||
|
aggregationLength: 32 |
||||
|
aggregationLengthV6: 128 |
||||
|
communities: |
||||
|
- no-advertise |
||||
|
localpref: "{{ peer.localpref | default ("100") }}" |
||||
|
ipAddressPools: |
||||
|
{% for address_pool in peer.address_pool %} |
||||
|
- "{{ address_pool }}" |
||||
|
{% endfor %} |
||||
|
{% endif %} |
||||
|
|
||||
|
# External BGP Advertisement. The IP range specied in the address pool is advertised to the BGP peer. |
||||
|
--- |
||||
|
apiVersion: metallb.io/v1beta1 |
||||
|
kind: BGPAdvertisement |
||||
|
metadata: |
||||
|
name: "{{ peer_name }}-external" |
||||
|
namespace: metallb-system |
||||
|
spec: |
||||
|
{% if peer.aggregation_length is defined and peer.aggregation_length <= 30 %} |
||||
|
aggregationLength: {{ peer.aggregation_length }} |
||||
|
{% endif %} |
||||
|
ipAddressPools: |
||||
|
{% for address_pool in peer.address_pool %} |
||||
|
- "{{ address_pool }}" |
||||
|
{% endfor %} |
||||
|
{% if peer.communities is defined %} |
||||
|
{% for community in peer.communities %} |
||||
|
communities: |
||||
|
- "{{ community }}" |
||||
|
{% endfor %} |
||||
|
{% endif %} |
||||
|
|
||||
|
|
||||
|
# Configuration for the BGP peer. |
||||
|
--- |
||||
|
apiVersion: metallb.io/v1beta2 |
||||
|
kind: BGPPeer |
||||
|
metadata: |
||||
|
name: "{{ peer_name }}" |
||||
|
namespace: metallb-system |
||||
|
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 }} |
||||
|
{% elif metallb_config.layer3.defaults.hold_time is defined %} |
||||
|
holdTime: {{ metallb_config.layer3.defaults.hold_time }} |
||||
|
{% endif -%} |
||||
|
|
||||
|
{% if peer.multihop is defined %} |
||||
|
ebgpMultiHop: {{ peer.multihop }} |
||||
|
{% endif -%} |
||||
|
|
||||
|
{% endfor %} |
@ -1,54 +0,0 @@ |
|||||
--- |
|
||||
apiVersion: v1 |
|
||||
kind: ConfigMap |
|
||||
metadata: |
|
||||
namespace: metallb-system |
|
||||
name: config |
|
||||
data: |
|
||||
config: | |
|
||||
{% if metallb_peers | length > 0 %} |
|
||||
peers: |
|
||||
{% for peer in metallb_peers %} |
|
||||
- peer-address: {{ peer.peer_address }} |
|
||||
peer-asn: {{ peer.peer_asn }} |
|
||||
my-asn: {{ peer.my_asn }} |
|
||||
{% if peer.password is defined %} |
|
||||
password: "{{ peer.password }}" |
|
||||
{% endif %} |
|
||||
{% if peer.source_address is defined %} |
|
||||
source-address: {{ peer.source_address }} |
|
||||
{% endif %} |
|
||||
{% if peer.node_selectors is defined %} |
|
||||
node-selectors: |
|
||||
{{ peer.node_selectors | to_yaml(indent=2, width=1337) | indent(8) }} |
|
||||
{% endif %} |
|
||||
{% endfor %} |
|
||||
{% endif %} |
|
||||
address-pools: |
|
||||
- name: {{ metallb_pool_name }} |
|
||||
protocol: {{ metallb_protocol }} |
|
||||
addresses: |
|
||||
{% for ip_range in metallb_ip_range %} |
|
||||
- {{ ip_range }} |
|
||||
{% endfor %} |
|
||||
{% if metallb_auto_assign == false %} |
|
||||
auto-assign: false |
|
||||
{% endif %} |
|
||||
{% if metallb_avoid_buggy_ips == true %} |
|
||||
avoid-buggy-ips: true |
|
||||
{% endif %} |
|
||||
{% if metallb_additional_address_pools is defined %}{% for pool in metallb_additional_address_pools %} |
|
||||
- name: {{ pool }} |
|
||||
protocol: {{ metallb_additional_address_pools[pool].protocol }} |
|
||||
addresses: |
|
||||
{% for ip_range in metallb_additional_address_pools[pool].ip_range %} |
|
||||
- {{ ip_range }} |
|
||||
{% endfor %} |
|
||||
{% if metallb_additional_address_pools[pool].auto_assign is defined %} |
|
||||
auto-assign: {{ metallb_additional_address_pools[pool].auto_assign }} |
|
||||
{% endif %} |
|
||||
{% if metallb_additional_address_pools[pool].avoid_buggy_ips is defined %} |
|
||||
avoid-buggy-ips: {{ metallb_additional_address_pools[pool].avoid_buggy_ips }} |
|
||||
{% endif %} |
|
||||
{% endfor %} |
|
||||
{% endif %} |
|
1981
roles/kubernetes-apps/metallb/templates/metallb.yml.j2
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,22 @@ |
|||||
|
#jinja2: trim_blocks: True, lstrip_blocks: True |
||||
|
# yamllint disable-file |
||||
|
--- |
||||
|
|
||||
|
# Create all pools |
||||
|
{% for pool_name, pool in metallb_config.address_pools.items() %} |
||||
|
|
||||
|
--- |
||||
|
apiVersion: metallb.io/v1beta1 |
||||
|
kind: IPAddressPool |
||||
|
metadata: |
||||
|
namespace: metallb-system |
||||
|
name: "{{ pool_name }}" |
||||
|
spec: |
||||
|
addresses: |
||||
|
{% for ip_range in pool.ip_range %} |
||||
|
- "{{ ip_range }}" |
||||
|
{% endfor %} |
||||
|
autoAssign: {{ pool.auto_assign }} |
||||
|
avoidBuggyIPs: true |
||||
|
|
||||
|
{% endfor %} |
Write
Preview
Loading…
Cancel
Save