24 lines
543 B
Bash
24 lines
543 B
Bash
|
#!/bin/bash
|
||
|
set -e
|
||
|
|
||
|
usage () {
|
||
|
echo "usage: $0 ip"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
[[ $# -eq 1 ]] || usage
|
||
|
ip="$1"
|
||
|
|
||
|
cd "$(dirname $(dirname $0))/k8s/"
|
||
|
|
||
|
sed "s!<IP>!${ip}!" ./metallb.yaml.template > ./metallb.yaml
|
||
|
|
||
|
echo "Configuring metallb..."
|
||
|
kubectl apply -f ./metallb.yaml
|
||
|
echo "Configuring services..."
|
||
|
for i in ./svc-*.yaml; do
|
||
|
svc="$(grep -Po "name: \Kpdp-.*$" "$i")"
|
||
|
kubectl patch svc "$svc" -p '{"metadata":{"annotations":{"metallb.universe.tf/allow-shared-ip":"'"$ip"'"}},"spec":{"type": "LoadBalancer","loadBalancerIP":"'"$ip"'"}}'
|
||
|
done
|
||
|
echo "Done!"
|