@@ -188,10 +188,12 @@ function validateLoadBalancer {
188188 ;;
189189 " APACHE" )
190190 ;;
191+ " VOYAGER" )
192+ ;;
191193 " NONE" )
192194 ;;
193195 * )
194- validationError " Invalid value for loadBalancer: ${loadBalancer} . Valid values are TRAEFIK, APACHE and NONE."
196+ validationError " Invalid value for loadBalancer: ${loadBalancer} . Valid values are APACHE, TRAEFIK, VOYAGER and NONE."
195197 ;;
196198 esac
197199 fi
@@ -353,6 +355,11 @@ function initialize {
353355 if [ ! -f ${apacheInput} ]; then
354356 validationError " The template file ${apacheInput} for generating the apache-webtier deployment was not found"
355357 fi
358+
359+ voyagerInput=" ${scriptDir} /voyager-ingress-template.yaml"
360+ if [ ! -f ${voyagerInput} ]; then
361+ validationError " The template file ${voyagerInput} for generating the Voyager Ingress was not found"
362+ fi
356363
357364 failIfValidationErrors
358365
@@ -424,7 +431,7 @@ function createYamlFiles {
424431 traefikOutput=" ${domainOutputDir} /weblogic-domain-traefik-${clusterNameLC} .yaml"
425432 apacheOutput=" ${domainOutputDir} /weblogic-domain-apache.yaml"
426433 apacheSecurityOutput=" ${domainOutputDir} /weblogic-domain-apache-security.yaml"
427-
434+ voyagerOutput= " ${domainOutputDir} /voyager-ingress.yaml "
428435
429436 enabledPrefix=" " # uncomment the feature
430437 disabledPrefix=" # " # comment out the feature
@@ -531,8 +538,9 @@ function createYamlFiles {
531538 sed -i -e " s:%DOMAIN_NAME%:${domainName} :g" ${traefikSecurityOutput}
532539 sed -i -e " s:%CLUSTER_NAME%:${clusterName} :g" ${traefikSecurityOutput}
533540 sed -i -e " s:%CLUSTER_NAME_LC%:${clusterNameLC} :g" ${traefikSecurityOutput}
541+ fi
534542
535- elif [ " ${loadBalancer} " = " APACHE" ]; then
543+ if [ " ${loadBalancer} " = " APACHE" ]; then
536544 # Apache file
537545 cp ${apacheInput} ${apacheOutput}
538546 echo Generating ${apacheOutput}
@@ -565,6 +573,19 @@ function createYamlFiles {
565573 sed -i -e " s:%DOMAIN_NAME%:${domainName} :g" ${apacheSecurityOutput}
566574 fi
567575
576+ if [ " ${loadBalancer} " = " VOYAGER" ]; then
577+ # Voyager Ingress file
578+ cp ${voyagerInput} ${voyagerOutput}
579+ echo Generating ${voyagerOutput}
580+ sed -i -e " s:%NAMESPACE%:$namespace :g" ${voyagerOutput}
581+ sed -i -e " s:%DOMAIN_UID%:${domainUID} :g" ${voyagerOutput}
582+ sed -i -e " s:%DOMAIN_NAME%:${domainName} :g" ${voyagerOutput}
583+ sed -i -e " s:%CLUSTER_NAME%:${clusterName} :g" ${voyagerOutput}
584+ sed -i -e " s:%MANAGED_SERVER_PORT%:${managedServerPort} :g" ${voyagerOutput}
585+ sed -i -e " s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort :g" ${voyagerOutput}
586+ sed -i -e " s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort :g" ${voyagerOutput}
587+ fi
588+
568589 # Remove any "...yaml-e" files left over from running sed
569590 rm -f ${domainOutputDir} /* .yaml-e
570591}
@@ -656,6 +677,59 @@ function createDomain {
656677
657678}
658679
680+ #
681+ # Deploy Voyager/HAProxy load balancer
682+ #
683+ function setupVoyagerLoadBalancer {
684+ # only deploy Voyager Ingress Controller the first time
685+ local vpod=` kubectl get pod -n voyager | grep voyager | wc -l`
686+ if [ " $vpod " == " 0" ]; then
687+ kubectl create namespace voyager
688+ curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0/hack/deploy/voyager.sh \
689+ | bash -s -- --provider=baremetal --namespace=voyager
690+ fi
691+
692+ # verify Voyager controller pod is ready
693+ local ready=` kubectl -n voyager get pod | grep voyager-operator | awk ' { print $2; } ' `
694+ if [ " ${ready} " != " 1/1" ] ; then
695+ fail " Voyager Ingress Controller is not ready"
696+ fi
697+
698+ # deploy Voyager Ingress resource
699+ kubectl apply -f ${voyagerOutput}
700+
701+ echo Checking Voyager Ingress resource
702+ local maxwaitsecs=100
703+ local mstart=` date +%s`
704+ while : ; do
705+ local mnow=` date +%s`
706+ local vdep=` kubectl get ingresses.voyager.appscode.com -n ${namespace} | grep ${domainUID} -voyager | wc | awk ' { print $1; } ' `
707+ if [ " $vdep " = " 1" ]; then
708+ echo ' The Voyager Ingress resource ${domainUID}-voyager is created successfully.'
709+ break
710+ fi
711+ if [ $(( mnow - mstart)) -gt $(( maxwaitsecs)) ]; then
712+ fail " The Voyager Ingress resource ${domainUID} -voyager was not created."
713+ fi
714+ sleep 5
715+ done
716+
717+ echo Checking Voyager service
718+ local maxwaitsecs=100
719+ local mstart=` date +%s`
720+ while : ; do
721+ local mnow=` date +%s`
722+ local vscv=` kubectl get service ${domainUID} -voyager-stats -n ${namespace} | grep ${domainUID} -voyager-stats | wc | awk ' { print $1; } ' `
723+ if [ " $vscv " = " 1" ]; then
724+ echo ' The service ${domainUID}-voyager-stats is created successfully.'
725+ break
726+ fi
727+ if [ $(( mnow - mstart)) -gt $(( maxwaitsecs)) ]; then
728+ fail " The service ${domainUID} -voyager-stats was not created."
729+ fi
730+ sleep 5
731+ done
732+ }
659733#
660734# Deploy traefik load balancer
661735#
@@ -707,6 +781,21 @@ function setupApacheLoadBalancer {
707781
708782 apacheName=" ${domainUID} -apache-webtier"
709783
784+ echo Setting up apache security
785+ kubectl apply -f ${apacheSecurityOutput}
786+
787+ echo Checking the cluster role ${apacheName} was created
788+ CLUSTERROLE=` kubectl get clusterroles | grep ${apacheName} | wc | awk ' { print $1; } ' `
789+ if [ " $CLUSTERROLE " != " 1" ]; then
790+ fail " The cluster role ${apacheName} was not created"
791+ fi
792+
793+ echo Checking the cluster role binding ${apacheName} was created
794+ CLUSTERROLEBINDING=` kubectl get clusterrolebindings | grep ${apacheName} | wc | awk ' { print $1; } ' `
795+ if [ " $CLUSTERROLEBINDING " != " 1" ]; then
796+ fail " The cluster role binding ${apacheName} was not created"
797+ fi
798+
710799 echo Deploying apache
711800 kubectl apply -f ${apacheOutput}
712801
@@ -783,7 +872,7 @@ function outputJobSummary {
783872 if [ " ${exposeAdminT3Channel} " = true ]; then
784873 echo " T3 access is available at t3:${K8S_IP} :${t3ChannelPort} "
785874 fi
786- if [ " ${loadBalancer} " = " TRAEFIK" ]; then
875+ if [ " ${loadBalancer} " = " TRAEFIK" ] || [ " ${loadBalancer} " = " VOYAGER " ] ; then
787876 echo " The load balancer for cluster '${clusterName} ' is available at http:${K8S_IP} :${loadBalancerWebPort} / (add the application path to the URL)"
788877 echo " The load balancer dashboard for cluster '${clusterName} ' is available at http:${K8S_IP} :${loadBalancerDashboardPort} "
789878 echo " "
@@ -803,7 +892,8 @@ function outputJobSummary {
803892 elif [ " ${loadBalancer} " = " APACHE" ]; then
804893 echo " ${apacheSecurityOutput} "
805894 echo " ${apacheOutput} "
806-
895+ elif [ " ${loadBalancer} " = " VOYAGER" ]; then
896+ echo " ${voyagerOutput} "
807897 fi
808898}
809899
@@ -836,7 +926,8 @@ if [ "${generateOnly}" = false ]; then
836926 setupTraefikLoadBalancer
837927 elif [ " ${loadBalancer} " = " APACHE" ]; then
838928 setupApacheLoadBalancer
839-
929+ elif [ " ${loadBalancer} " = " VOYAGER" ]; then
930+ setupVoyagerLoadBalancer
840931 fi
841932
842933 # Create the domain custom resource
0 commit comments