Skip to content

Commit

Permalink
Deploy FFR-k8s in kind
Browse files Browse the repository at this point in the history
Signed-off-by: Jaime Caamaño Ruiz <jcaamano@redhat.com>
  • Loading branch information
jcaamano committed Aug 14, 2024
1 parent 00a0af3 commit e316437
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
31 changes: 31 additions & 0 deletions contrib/kind-common
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,34 @@ kubectl_wait_dnsnameresolver_pods() {
echo "Waiting for pods in dnsnameresolver-operator namespace to become ready (timeout ${timeout})..."
kubectl wait -n dnsnameresolver-operator --for=condition=ready pods --all --timeout=${timeout}s
}

install_ffr_k8s() {
echo "Installing frr-k8s ..."
local tmpdir=$(mktemp -d)
pushd $tmpdir
git clone --depth 1 --branch v0.0.14 https://github.com/metallb/frr-k8s
popd

# apply the demo which will deploy an external FRR container that the cluster
# can peer with
pushd ${tmpdir}/frr-k8s/hack/demo
./demo.sh
popd

# apply frr-k8s
kubectl apply -f ${tmpdir}/frr-k8s/config/all-in-one/frr-k8s.yaml
kubectl wait -n frr-k8s-system deployment frr-k8s-webhook-server --for condition=Available --timeout 2m
kubectl rollout status -n frr-k8s-system daemonset frr-k8s-daemon --timeout 2m

# apply a receive all configuration for a full cluster peering mesh as well as
# the external FRR
kubectl apply -f ${tmpdir}/frr-k8s/hack/demo/configs/receive_all.yaml
for node in $(kubectl get nodes -o jsonpath='{.items[*].metadata.name}' ); do
peers=$(kubectl get nodes -o jsonpath="{.items[?(@.metadata.name!='$node')].status.addresses[?(@.type=='InternalIP')].address}")
export node=$node
export peers=$peers
jinjanate --quiet ../dist/templates/ffr-k8s-config.yaml.j2 | kubectl apply -f -
done

rm -rf ${tmpdir}
}
3 changes: 3 additions & 0 deletions contrib/kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1173,3 +1173,6 @@ if [ "$KIND_INSTALL_KUBEVIRT" == true ]; then
install_kubevirt
install_kubevirt_ipam_controller
fi
if [ "$ENABLE_ROUTE_ADVERTISEMENTS" == true ]; then
install_ffr_k8s
fi
21 changes: 21 additions & 0 deletions dist/templates/ffr-k8s-config.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: frrk8s.metallb.io/v1beta1
kind: FRRConfiguration
metadata:
name: {{ node }}-receive-all
namespace: frr-k8s-system
spec:
bgp:
routers:
- asn: 64512
neighbors:
{%- set x = peers|string %}
{%- for peer in x.split(' ') %}
- address: {{ peer }}
asn: 64512
toReceive:
allowed:
mode: all
{%- endfor %}
nodeSelector:
matchLabels:
kubernetes.io/hostname: {{ node }}

0 comments on commit e316437

Please sign in to comment.