fix deploy karmada-apiserver error by loadBalancer
Signed-off-by: Poor12 <shentiecheng@huawei.com>
This commit is contained in:
parent
00403af749
commit
1dc4c83e16
|
@ -200,7 +200,7 @@ if [ "${HOST_CLUSTER_TYPE}" = "remote" ]; then
|
||||||
KARMADA_APISERVER_IP=$(kubectl --context="${HOST_CLUSTER_NAME}" get pod -l app=karmada-apiserver -n "${KARMADA_SYSTEM_NAMESPACE}" -o=jsonpath='{.items[0].status.podIP}')
|
KARMADA_APISERVER_IP=$(kubectl --context="${HOST_CLUSTER_NAME}" get pod -l app=karmada-apiserver -n "${KARMADA_SYSTEM_NAMESPACE}" -o=jsonpath='{.items[0].status.podIP}')
|
||||||
;;
|
;;
|
||||||
LoadBalancer)
|
LoadBalancer)
|
||||||
if util::wait_service_external_ip "karmada-apiserver" "karmada-apiserver" "${KARMADA_SYSTEM_NAMESPACE}"; then
|
if util::wait_service_external_ip "${HOST_CLUSTER_NAME}" "karmada-apiserver" "${KARMADA_SYSTEM_NAMESPACE}"; then
|
||||||
echo "Get service external IP: ${SERVICE_EXTERNAL_IP}, wait to check network connectivity"
|
echo "Get service external IP: ${SERVICE_EXTERNAL_IP}, wait to check network connectivity"
|
||||||
KARMADA_APISERVER_IP=$(util::get_load_balancer_ip) || KARMADA_APISERVER_IP=''
|
KARMADA_APISERVER_IP=$(util::get_load_balancer_ip) || KARMADA_APISERVER_IP=''
|
||||||
else
|
else
|
||||||
|
|
|
@ -521,13 +521,15 @@ function util::wait_service_external_ip() {
|
||||||
local tmp
|
local tmp
|
||||||
for tmp in {1..30}; do
|
for tmp in {1..30}; do
|
||||||
set +e
|
set +e
|
||||||
|
## if .status.loadBalancer does not have `ingress` field, return "".
|
||||||
|
## if .status.loadBalancer has `ingress` field but one of `ingress` field does not have `hostname` or `ip` field, return "<no value>".
|
||||||
external_host=$(kubectl --context="$context_name" get service "${service_name}" -n "${namespace}" --template="{{range .status.loadBalancer.ingress}}{{.hostname}} {{end}}" | xargs)
|
external_host=$(kubectl --context="$context_name" get service "${service_name}" -n "${namespace}" --template="{{range .status.loadBalancer.ingress}}{{.hostname}} {{end}}" | xargs)
|
||||||
external_ip=$(kubectl --context="$context_name" get service "${service_name}" -n "${namespace}" --template="{{range .status.loadBalancer.ingress}}{{.ip}} {{end}}" | xargs)
|
external_ip=$(kubectl --context="$context_name" get service "${service_name}" -n "${namespace}" --template="{{range .status.loadBalancer.ingress}}{{.ip}} {{end}}" | xargs)
|
||||||
set -e
|
set -e
|
||||||
if [[ ! -z "$external_host" ]]; then # Compatibility with hostname, such as AWS
|
if [[ ! -z "$external_host" && "$external_host" != "<no value>" ]]; then # Compatibility with hostname, such as AWS
|
||||||
external_ip=$external_host
|
external_ip=$external_host
|
||||||
fi
|
fi
|
||||||
if [[ -z "$external_ip" ]]; then
|
if [[ -z "$external_ip" || "$external_ip" = "<no value>" ]]; then
|
||||||
echo "wait the external ip of ${service_name} ready..."
|
echo "wait the external ip of ${service_name} ready..."
|
||||||
sleep 6
|
sleep 6
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue