This means IPAddressPool
s, L2Advertisement
s, and BGPAdvertisement
s.
This does NOT install or configure metallb
.
- A functional k8s cluster.
- metallb must already be installed. There are a lot of
configuration knobs and dials to turn with an installation. This project isn't
for deploying and configuring
metallb
, but rather the IP pools and advertisements.
NOTE: Do not change the namespace from metallb-system
. I believe this
is a requirement for metallb
itself.
- The base
IPAddressPool
name ispool
. To have more than one pool, you will need to rename it. You will probably want to do so anyway. Choose the new name in the/metadata/name
rename
op
. - The IP address pool itself is a single line from an array in the
base
definition. You can add more here if you like, but the default is to replace just the one entry. Feel free to use CIDR notation, as theAvoidBuggyIPs
flag is set to true (which will avoid.0
and.255
addresses). Replace/spec/addresses/0
value
with your IP range.
- Edit
patches/advertisement.yaml
and put in whatever changes you need. The existing example sets an ethernet interface and 3 nodes. There are many more configuration options available to you. Do not change the/metadata/name
in this patch! The renames will take place later inkustomization.yaml
as the patch file must match the name. Yes, we could settarget
and get around that. It's problematic to troubleshoot this sometimes as folks don't know what they've done, so we keep it fairly pure here. - Edit the
value
for/metadata/name
. This is therename
op
for the thisL2Advertisement
. - Edit the
value
for/spec/ipAddressPools/0
. This value should match what you renamed/metadata/name
to in theIPAddressPool
section.
This one requires replacing the L2Advertisement
section with the commented out
BGPAdvertisement
section. Everything else should remain similar to the previous
instructions.
NOTE: This also requires commenting out the l2
line and uncommenting the
bgp
one:
# - base/advertisements/l2/advertisement.yaml
- base/advertisements/bgp/advertisement.yaml
- Edit
patches/advertisement.yaml
and put in whatever changes you need. The existing example sets an ethernet interface and 3 nodes. There are many more configuration options available to you. Do not change the/metadata/name
in this patch! The renames will take place later inkustomization.yaml
as the patch file must match the name. Yes, we could settarget
and get around that. It's problematic to troubleshoot this sometimes as folks don't know what they've done, so we keep it fairly pure here. - Edit the
value
for/metadata/name
. This is therename
op
for the thisBGPAdvertisement
. - Edit the
value
for/spec/ipAddressPools/0
. This value should match what you renamed/metadata/name
to in theIPAddressPool
section.
As metallb
themselves tell you, you can use both advertisement types at once,
for the same IPAddressPool
. To do so requires both lines will need to be
uncommented:
- base/advertisements/l2/advertisement.yaml
- base/advertisements/bgp/advertisement.yaml
You will also need to copy patches/advertisement.yaml
to another file, e.g.
patches/bgp_advertisement.yaml
. So long as you can distinguish between the two,
that's all that matters.
You would then need to uncomment both sections in kustomization.yaml
, and ensure
that the correct patches/FILENAME.yaml
patches the correct advertisement type.
- (Optional) To preview generated configuration before deploying:
kubectl kustomize .
- Run the following command to build and deploy:
kubectl apply -k .
- Copy
kustomization.yaml
, and the variouspatches/*
files tooverlays/NAME
, or whatever directory structure you prefer. - For complex deployments, this could look like
overlays/GROUP/SUBGROUP
, whereGROUP
could beteamname
, andSUBGROUP
could beprod
,qa
, ordev
. This allows fine granular control over which blocks of IPs are allocated to which teams and environments. - Each
NAME
orSUBGROUP
should have its ownkustomization.yaml
andpatches
subdirectory. - Be sure to update the
resources
section ofkustomization.yaml
to be able to reach thebase
directory.
For NAME
(one level)
resources:
- ../../base
- ../../base/advertisements/l2
For GROUP/SUBGROUP
(two levels)
resources:
- ../../../base
- ../../../base/advertisements/l2
Apply the same configuration steps as above for each overlay
path you create.
- (Optional) To preview generated configuration before deploying:
kubectl kustomize overlays/NAME
or
kubectl kustomize overlays/GROUP/SUBGROUP
- Run the following command to build and deploy:
kubectl apply -k overlays/NAME
or
kubectl apply -k overlays/GROUP/SUBGROUP