Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: updated llb-url script for eks pod identity #849

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading