Merge pull request #1137 from lfbear/remote-install4aws

Adapt for hostname in LoadBalancer
This commit is contained in:
karmada-bot 2021-12-28 14:00:37 +08:00 committed by GitHub
commit 24f586062e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -460,8 +460,12 @@ function util::wait_service_external_ip() {
local tmp
for tmp in {1..30}; do
set +e
external_host=$(kubectl get service "${service_name}" -n "${namespace}" --template="{{range .status.loadBalancer.ingress}}{{.hostname}} {{end}}" | xargs)
external_ip=$(kubectl get service "${service_name}" -n "${namespace}" --template="{{range .status.loadBalancer.ingress}}{{.ip}} {{end}}" | xargs)
set -e
if [[ ! -z "$external_host" ]]; then # Compatibility with hostname, such as AWS
external_ip=$external_host
fi
if [[ -z "$external_ip" ]]; then
echo "wait the external ip of ${service_name} ready..."
sleep 6
@ -482,6 +486,13 @@ function util::get_load_balancer_ip() {
if [[ -n "${SERVICE_EXTERNAL_IP}" ]]; then
first_ip=$(echo "${SERVICE_EXTERNAL_IP}" | awk '{print $1}') #temporarily choose the first one
for tmp in {1..10}; do
#if it is a host, check dns first
if [[ ! "${first_ip}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if ! nslookup ${first_ip} > /dev/null; then # host dns lookup failed
sleep 30
continue
fi
fi
set +e
connect_test=$(curl -s -k -m 5 https://"${first_ip}":5443/readyz)
set -e