Skip to content

Commit 3bd4f87

Browse files
committed
update llb-url script
1 parent c8acecc commit 3bd4f87

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tools/k8s/mkllb-url

+13-4
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,30 @@ do
3535
esac
3636
done
3737

38-
url="http://${addr}:11111"
39-
4038
laddr=${addr}
39+
4140
if [[ ${cloud} == "aws" ]]; then
4241
if [[ ! -f /usr/local/bin/aws ]]; then
4342
apt install -y unzip
4443
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
4544
unzip awscliv2.zip && ./aws/install
4645
fi
47-
token=`curl -m 10 -X PUT http://169.254.169.254/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && \
48-
addr=`curl -m 10 -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/public-ipv4`
46+
token=`curl -s -m 10 -X PUT http://169.254.169.254/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && \
47+
if [[ "x$addr" == "x0.0.0.0" ]]; then
48+
laddr=`curl -s -m 10 -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/local-ipv4`
49+
fi
50+
addr=`curl -s -m 10 -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/public-ipv4`
51+
else
52+
if [[ "x$addr" == "x0.0.0.0" ]]; then
53+
laddr=`ip route get 8.8.8.8 | head -1 | cut -d' ' -f3`
54+
addr=`ip route get 8.8.8.8 | head -1 | cut -d' ' -f3`
55+
fi
4956
fi
5057

5158
if [[ ${utype} == "hostcidr" ]]; then
5259
url=${addr}
60+
else
61+
url="http://${addr}:11111"
5362
fi
5463

5564
echo "============"

0 commit comments

Comments
 (0)