9292#
9393function initAndValidateOutputDir {
9494 domainOutputDir=" ${outputDir} /weblogic-domains/${domainUID} "
95+
9596 validateOutputDir \
9697 ${domainOutputDir} \
9798 ${valuesInputFile} \
@@ -100,6 +101,8 @@ function initAndValidateOutputDir {
100101 weblogic-domain-pvc.yaml \
101102 weblogic-domain-traefik-${clusterNameLC} .yaml \
102103 weblogic-domain-traefik-security-${clusterNameLC} .yaml \
104+ weblogic-domain-apache.yaml \
105+ weblogic-domain-apache-security.yaml \
103106 create-weblogic-domain-job.yaml \
104107 domain-custom-resource.yaml
105108}
@@ -183,12 +186,14 @@ function validateLoadBalancer {
183186 case ${loadBalancer} in
184187 " TRAEFIK" )
185188 ;;
189+ " APACHE" )
190+ ;;
186191 " VOYAGER" )
187192 ;;
188193 " NONE" )
189194 ;;
190195 * )
191- validationError " Invalid value for loadBalancer: ${loadBalancer} . Valid values are TRAEFIK, VOYAGER and NONE."
196+ validationError " Invalid value for loadBalancer: ${loadBalancer} . Valid values are APACHE, TRAEFIK, VOYAGER and NONE."
192197 ;;
193198 esac
194199 fi
@@ -341,6 +346,15 @@ function initialize {
341346 validationError " The template file ${traefikInput} for generating the traefik deployment was not found"
342347 fi
343348
349+ apacheSecurityInput=" ${scriptDir} /weblogic-domain-apache-security-template.yaml"
350+ if [ ! -f ${apacheSecurityInput} ]; then
351+ validationError " The file ${apacheSecurityInput} for generating the apache-webtier RBAC was not found"
352+ fi
353+
354+ apacheInput=" ${scriptDir} /weblogic-domain-apache-template.yaml"
355+ if [ ! -f ${apacheInput} ]; then
356+ validationError " The template file ${apacheInput} for generating the apache-webtier deployment was not found"
357+
344358 voyagerInput=" ${scriptDir} /voyager-ingress-template.yaml"
345359 if [ ! -f ${voyagerInput} ]; then
346360 validationError " The template file ${voyagerInput} for generating the Voyager Ingress was not found"
@@ -414,6 +428,8 @@ function createYamlFiles {
414428 dcrOutput=" ${domainOutputDir} /domain-custom-resource.yaml"
415429 traefikSecurityOutput=" ${domainOutputDir} /weblogic-domain-traefik-security-${clusterNameLC} .yaml"
416430 traefikOutput=" ${domainOutputDir} /weblogic-domain-traefik-${clusterNameLC} .yaml"
431+ apacheOutput=" ${domainOutputDir} /weblogic-domain-apache.yaml"
432+ apacheSecurityOutput=" ${domainOutputDir} /weblogic-domain-apache-security.yaml"
417433 voyagerOutput=" ${domainOutputDir} /voyager-ingress.yaml"
418434
419435 enabledPrefix=" " # uncomment the feature
@@ -523,6 +539,39 @@ function createYamlFiles {
523539 sed -i -e " s:%CLUSTER_NAME_LC%:${clusterNameLC} :g" ${traefikSecurityOutput}
524540 fi
525541
542+ if [ " ${loadBalancer} " = " APACHE" ]; then
543+ # Apache file
544+ cp ${apacheInput} ${apacheOutput}
545+ echo Generating ${apacheOutput}
546+ sed -i -e " s:%NAMESPACE%:$namespace :g" ${apacheOutput}
547+ sed -i -e " s:%DOMAIN_UID%:${domainUID} :g" ${apacheOutput}
548+ sed -i -e " s:%DOMAIN_NAME%:${domainName} :g" ${apacheOutput}
549+ sed -i -e " s:%CLUSTER_NAME_LC%:${clusterNameLC} :g" ${apacheOutput}
550+ sed -i -e " s:%ADMIN_SERVER_NAME%:${adminServerName} :g" ${apacheOutput}
551+ sed -i -e " s:%ADMIN_PORT%:${adminPort} :g" ${apacheOutput}
552+ sed -i -e " s:%MANAGED_SERVER_PORT%:${managedServerPort} :g" ${apacheOutput}
553+ sed -i -e " s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort :g" ${apacheOutput}
554+ sed -i -e " s:%WEB_APP_PREPATH%:$loadBalancerAppPrepath :g" ${apacheOutput}
555+
556+ if [ ! -z " ${loadBalancerVolumePath} " ]; then
557+ sed -i -e " s:%LOAD_BALANCER_VOLUME_PATH%:${loadBalancerVolumePath} :g" ${apacheOutput}
558+ sed -i -e " s:# volumes:volumes:g" ${apacheOutput}
559+ sed -i -e " s:# - name:- name:g" ${apacheOutput}
560+ sed -i -e " s:# hostPath: hostPath:g" ${apacheOutput}
561+ sed -i -e " s:# path: path:g" ${apacheOutput}
562+ sed -i -e " s:# volumeMounts:volumeMounts:g" ${apacheOutput}
563+ sed -i -e " s:# - name:- name:g" ${apacheOutput}
564+ sed -i -e " s:# mountPath: mountPath:g" ${apacheOutput}
565+ fi
566+
567+ # Apache security file
568+ cp ${apacheSecurityInput} ${apacheSecurityOutput}
569+ echo Generating ${apacheSecurityOutput}
570+ sed -i -e " s:%NAMESPACE%:$namespace :g" ${apacheSecurityOutput}
571+ sed -i -e " s:%DOMAIN_UID%:${domainUID} :g" ${apacheSecurityOutput}
572+ sed -i -e " s:%DOMAIN_NAME%:${domainName} :g" ${apacheSecurityOutput}
573+ fi
574+
526575 if [ " ${loadBalancer} " = " VOYAGER" ]; then
527576 # Voyager Ingress file
528577 cp ${voyagerInput} ${voyagerOutput}
@@ -724,6 +773,50 @@ function setupTraefikLoadBalancer {
724773 fi
725774}
726775
776+ #
777+ # Deploy Apache load balancer
778+ #
779+ function setupApacheLoadBalancer {
780+
781+ apacheName=" ${domainUID} -apache-webtier"
782+
783+ echo Setting up apache security
784+ kubectl apply -f ${apacheSecurityOutput}
785+
786+ echo Checking the cluster role ${apacheName} was created
787+ CLUSTERROLE=` kubectl get clusterroles | grep ${apacheName} | wc | awk ' { print $1; } ' `
788+ if [ " $CLUSTERROLE " != " 1" ]; then
789+ fail " The cluster role ${apacheName} was not created"
790+ fi
791+
792+ echo Checking the cluster role binding ${apacheName} was created
793+ CLUSTERROLEBINDING=` kubectl get clusterrolebindings | grep ${apacheName} | wc | awk ' { print $1; } ' `
794+ if [ " $CLUSTERROLEBINDING " != " 1" ]; then
795+ fail " The cluster role binding ${apacheName} was not created"
796+ fi
797+
798+ echo Deploying apache
799+ kubectl apply -f ${apacheOutput}
800+
801+ echo Checking apache deployment
802+ SS=` kubectl get deployment -n ${namespace} | grep ${apacheName} | wc | awk ' { print $1; } ' `
803+ if [ " $SS " != " 1" ]; then
804+ fail " The deployment ${apacheName} was not created"
805+ fi
806+
807+ echo Checking the apache service account
808+ SA=` kubectl get serviceaccount ${apacheName} -n ${namespace} | grep ${apacheName} | wc | awk ' { print $1; } ' `
809+ if [ " $SA " != " 1" ]; then
810+ fail " The service account ${apacheName} was not created"
811+ fi
812+
813+ echo Checking apache service
814+ TSVC=` kubectl get services -n ${namespace} | grep ${apacheName} | wc | awk ' { print $1; } ' `
815+ if [ " $TSVC " != " 1" ]; then
816+ fail " The service ${apacheServiceName} was not created"
817+ fi
818+ }
819+
727820#
728821# Function to create the domain custom resource
729822#
@@ -782,6 +875,9 @@ function outputJobSummary {
782875 echo " The load balancer for cluster '${clusterName} ' is available at http:${K8S_IP} :${loadBalancerWebPort} / (add the application path to the URL)"
783876 echo " The load balancer dashboard for cluster '${clusterName} ' is available at http:${K8S_IP} :${loadBalancerDashboardPort} "
784877 echo " "
878+ elif [ " ${loadBalancer} " = " APACHE" ]; then
879+ echo " The apache load balancer for '${domainUID} ' is available at http:${K8S_IP} :${loadBalancerWebPort} / (add the application path to the URL)"
880+
785881 fi
786882 echo " The following files were generated:"
787883 echo " ${domainOutputDir} /create-weblogic-domain-inputs.yaml"
@@ -792,6 +888,9 @@ function outputJobSummary {
792888 if [ " ${loadBalancer} " = " TRAEFIK" ]; then
793889 echo " ${traefikSecurityOutput} "
794890 echo " ${traefikOutput} "
891+ elif [ " ${loadBalancer} " = " APACHE" ]; then
892+ echo " ${apacheSecurityOutput} "
893+ echo " ${apacheOutput} "
795894 elif [ " ${loadBalancer} " = " VOYAGER" ]; then
796895 echo " ${voyagerOutput} "
797896 fi
@@ -824,6 +923,8 @@ if [ "${generateOnly}" = false ]; then
824923 # Setup load balancer
825924 if [ " ${loadBalancer} " = " TRAEFIK" ]; then
826925 setupTraefikLoadBalancer
926+ elif [ " ${loadBalancer} " = " APACHE" ]; then
927+ setupApacheLoadBalancer
827928 elif [ " ${loadBalancer} " = " VOYAGER" ]; then
828929 setupVoyagerLoadBalancer
829930 fi
0 commit comments