Skip to content

Commit

Permalink
Define region so CLI uses correct endpoint for localzones (#1284)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermckinnon authored Apr 26, 2023
1 parent fcfca67 commit a6f7186
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion files/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ else
# then /etc/hostname is not the same as EC2's PrivateDnsName.
# The name of the Node object must be equal to EC2's PrivateDnsName for the aws-iam-authenticator to allow this kubelet to manage it.
INSTANCE_ID=$(imds /latest/meta-data/instance-id)
PRIVATE_DNS_NAME=$(AWS_RETRY_MODE=standard AWS_MAX_ATTEMPTS=10 aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[].Instances[].PrivateDnsName' --output text)
# the AWS CLI currently constructs the wrong endpoint URL on localzones (the availability zone group will be used instead of the parent region)
# more info: https://github.com/aws/aws-cli/issues/7043
REGION=$(imds /latest/meta-data/placement/region)
PRIVATE_DNS_NAME=$(AWS_RETRY_MODE=standard AWS_MAX_ATTEMPTS=10 aws ec2 describe-instances --region $REGION --instance-ids $INSTANCE_ID --query 'Reservations[].Instances[].PrivateDnsName' --output text)
KUBELET_ARGS="$KUBELET_ARGS --hostname-override=$PRIVATE_DNS_NAME"
fi

Expand Down

0 comments on commit a6f7186

Please sign in to comment.