Skip to content

Commit

Permalink
Merge pull request #849 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR: updated llb-url script for eks pod identity
  • Loading branch information
UltraInstinct14 authored Oct 23, 2024
2 parents e945f22 + 89d3a07 commit c8acecc
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tools/k8s/mkllb-url
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

usage() {
echo "Usage: $0 -a <ip-addr> -z <zone> -t <type>"
echo " $0 -a <ip-addr> -z <zone> -t <type> -x"
echo "Usage: $0 -a <ip-addr> -z <zone> -t <type> -c <cloud>"
echo " $0 -a <ip-addr> -z <zone> -t <type> -c <cloud> -x"
}

if [[ $# -gt 7 ]] || [[ $# -lt 6 ]]; then
if [[ $# -gt 9 ]] || [[ $# -lt 6 ]]; then
usage
exit
fi
Expand All @@ -18,30 +18,44 @@ if [[ ! -f /usr/local/sbin/kubectl ]]; then
fi

addr=""
cloud="bm"
zone="llb"
utype="default"
cmd="apply"

while getopts a:z:t:x opt
while getopts a:z:t:c:x opt
do
case "${opt}" in
a) addr=${OPTARG};;
z) zone=${OPTARG};;
t) utype=${OPTARG};;
x) cmd="delete";;
c) cloud=${OPTARG};;
?) usage;exit;;
esac
done

url="http://${addr}:11111"

laddr=${addr}
if [[ ${cloud} == "aws" ]]; then
if [[ ! -f /usr/local/bin/aws ]]; then
apt install -y unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip && ./aws/install
fi
token=`curl -m 10 -X PUT http://169.254.169.254/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && \
addr=`curl -m 10 -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/public-ipv4`
fi

if [[ ${utype} == "hostcidr" ]]; then
url=${addr}
fi

echo "============"
echo "Applying CRD"
echo "============"
echo name llb-${laddr}
echo url $url
echo zone $zone
echo utype $utype
Expand All @@ -52,7 +66,7 @@ cat <<EOF | kubectl ${cmd} -f -
apiVersion: "loxiurl.loxilb.io/v1"
kind: LoxiURL
metadata:
name: llb-${addr}
name: llb-${laddr}
spec:
loxiURL: $url
zone: llb
Expand Down

0 comments on commit c8acecc

Please sign in to comment.