-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path003_configure_address_pool.sh
executable file
·54 lines (44 loc) · 1.15 KB
/
003_configure_address_pool.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
source .env
echo
echo Check Docker networking for kind subnet
if [ "$(type podman)" ]
then
echo Using Podman
subnet=$(docker network inspect -f '{{ json . }}' kind| jq -r .[0].subnets[1].subnet | cut -f 1 -d /)
else
echo Using Docker
subnet=$(docker network inspect -f '{{json .IPAM.Config}}' kind | jq -r '.[].Subnet' | head -1 | cut -f 1 -d /)
fi
echo Subnet is $subnet
first_ip=$(echo $subnet | cut -f 1-3 -d . | awk '{print $1 ".100"}')
last_ip=$(echo $subnet | cut -f 1-3 -d . | awk '{print $1 ".200"}')
echo Range is $first_ip - $last_ip
echo
echo Creating IPAddressPool and L2Advertisement ...
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: first-pool
namespace: $METALLB_NS
spec:
addresses:
- $first_ip-$last_ip
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: pool
namespace: $METALLB_NS
spec:
ipAddressPools:
- first-pool
EOF
# List it (not using first-pool
echo
echo Get all pools:
kubectl get ipaddresspools.metallb.io -A
echo
echo Get l2advertisements
kubectl get l2advertisements.metallb.io --namespace=$METALLB_NS