@@ -180,12 +180,14 @@ function create_lb_svc_for_admin_server_default_channel() {
180180
181181 adminServerEndpoint=$( kubectl get svc ${adminServerLBSVCName} -n ${wlsDomainNS} \
182182 -o=jsonpath=' {.status.loadBalancer.ingress[0].ip}:{.spec.ports[0].port}' )
183- adminConsoleEndpoint=" ${adminServerEndpoint} /console"
184183
185184 if [ " ${enableCustomDNSAlias,,} " == " true" ]; then
186185 create_dns_A_record " ${adminServerEndpoint%%:* } " ${dnsAdminLabel} ${dnsRGName} ${dnsZoneName}
187- adminConsoleEndpoint =" ${dnsAdminLabel} .${dnsZoneName} :${adminServerEndpoint#*: } /console "
186+ adminServerEndpoint =" ${dnsAdminLabel} .${dnsZoneName} :${adminServerEndpoint#*: } "
188187 fi
188+
189+ adminConsoleEndpoint=" ${adminServerEndpoint} /console"
190+ adminRemoteEndpoint=${adminServerEndpoint}
189191}
190192
191193function create_lb_svc_for_admin_t3_channel() {
@@ -360,19 +362,48 @@ EOF
360362 fi
361363}
362364
365+ function validate_admin_console_url() {
366+ local podName=$( kubectl -n ${wlsDomainNS} get pod -l weblogic.serverName=${constAdminServerName} -o json |
367+ jq ' .items[0] | .metadata.name' |
368+ tr -d " \" " )
369+
370+ if [[ " ${podName} " == " null" ]]; then
371+ echo " Ensure your domain has at least one admin server."
372+ exit 1
373+ fi
374+
375+ adminTargetPort=$( kubectl get svc ${svcAdminServer} -n ${wlsDomainNS} -o json |
376+ jq ' .spec.ports[] | select(.name=="default") | .port' )
377+ local adminConsoleUrl=" http://${svcAdminServer} .${wlsDomainNS} :${adminTargetPort} /console/"
378+
379+ kubectl exec -it ${podName} -n ${wlsDomainNS} -c ${wlsContainerName} \
380+ -- bash -c ' curl --write-out "%{http_code}\n" --silent --output /dev/null "' ${adminConsoleUrl} ' " | grep "302"'
381+
382+ if [ $? == 1 ]; then
383+ echo " admin console is not accessible."
384+ # reset admin console endpoint
385+ adminConsoleEndpoint=" null"
386+ fi
387+ }
388+
363389# Output value to deployment scripts
364390function output_result() {
365391 echo ${adminConsoleEndpoint}
366392 echo ${clusterEndpoint}
367393 echo ${adminServerT3Endpoint}
368394 echo ${clusterT3Endpoint}
395+ echo ${adminRemoteEndpoint}
396+
397+ # check if the admin console is accessible, do not output it
398+ validate_admin_console_url
369399
370400 result=$( jq -n -c \
371401 --arg adminEndpoint $adminConsoleEndpoint \
372402 --arg clusterEndpoint $clusterEndpoint \
373403 --arg adminT3Endpoint $adminServerT3Endpoint \
374404 --arg clusterT3Endpoint $clusterT3Endpoint \
375- ' {adminConsoleEndpoint: $adminEndpoint, clusterEndpoint: $clusterEndpoint, adminServerT3Endpoint: $adminT3Endpoint, clusterT3Endpoint: $clusterT3Endpoint}' )
405+ --arg adminRemoteEndpoint ${adminRemoteEndpoint} \
406+ ' {adminConsoleEndpoint: $adminEndpoint, clusterEndpoint: $clusterEndpoint, adminServerT3Endpoint: $adminT3Endpoint, clusterT3Endpoint: $clusterT3Endpoint, adminRemoteEndpoint: $adminRemoteEndpoint}' )
376407 echo " result is: $result "
377408 echo $result > $AZ_SCRIPTS_OUTPUT_PATH
378409}
@@ -461,6 +492,7 @@ wlsDomainUID=${11}
461492adminConsoleEndpoint=" null"
462493adminServerName=${constAdminServerName} # define in common.sh
463494adminServerT3Endpoint=" null"
495+ adminRemoteEndpoint=" null"
464496clusterEndpoint=" null"
465497clusterName=${constClusterName}
466498clusterT3Endpoint=" null"
0 commit comments