To load balance Oracle WebCenter Portal domain clusters, you can install Apache webtier and configure it for non-SSL and SSL termination access of the application URL. Follow these steps to set up Apache webtier as a load balancer for an Oracle WebCenter Portal domain in a Kubernetes cluster:
To build the Apache webtier Docker image, refer to the sample.
custom_mod_wl_apache.conf should have all the URL routing rules for the Oracle WebCenter Portal applications deployed in the domain that needs to be accessible externally. Update this file with values based on your environment. The file content is similar to below.$ cat ${WORKDIR}/charts/apache-samples/custom-sample/custom_mod_wl_apache.conf
#Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
#
  
<IfModule mod_weblogic.c>
WebLogicHost <WEBLOGIC_HOST>
WebLogicPort 7001
</IfModule>
  
# Directive for weblogic admin Console deployed on Weblogic Admin Server
<Location /console>
SetHandler weblogic-handler
WebLogicHost wcp-domain-adminserver
WebLogicPort 7001
</Location>
  
<Location /em>
SetHandler weblogic-handler
WebLogicHost wcp-domain-adminserver
WebLogicPort 7001
</Location>
 
 <Location /webcenter>
WLSRequest On
WebLogicCluster wcp-domain-cluster-wcp-cluster:8888
PathTrim /weblogic1
</Location>
 
<Location /rsscrawl>
WLSRequest On
WebLogicCluster wcp-domain-cluster-wcp-cluster:8888
PathTrim /weblogic1
</Location>  
<Location /rest>
WLSRequest On
WebLogicCluster wcp-domain-cluster-wcp-cluster:8888
PathTrim /weblogic1
</Location>
<Location /webcenterhelp>
WLSRequest On
WebLogicCluster wcp-domain-cluster-wcp-cluster:8888
PathTrim /weblogic1
</Location> 
<Location /wsrp-tools>
WLSRequest On
WebLogicCluster wcp-domain-cluster-wcportlet-cluster:8889
PathTrim /weblogic1
</Location> 
<Location /portalTools>
WLSRequest On
WebLogicCluster wcp-domain-cluster-wcportlet-cluster:8889
PathTrim /weblogic1
</Location> 
persistentVolumeClaimName in ${WORKDIR}/charts/apache-samples/custom-sample/input.yamlwith Persistence Volume which contains your own custom_mod_wl_apache.conf file. Use the PV/PVC created at the time of preparing environment, Copy the custom_mod_wl_apache.conf file to existing PersistantVolume.(For the SSL termination configuration only) Run the following commands to generate your own certificate and private key using openssl.
 $ cd ${WORKDIR}/charts/apache-samples/custom-sample
 $ export VIRTUAL_HOST_NAME=WEBLOGIC_HOST
 $ export SSL_CERT_FILE=WEBLOGIC_HOST.crt
 $ export SSL_CERT_KEY_FILE=WEBLOGIC_HOST.key
 $ sh certgen.sh
NOTE: Replace WEBLOGIC_HOST with the name of the host on which Apache webtier is to be installed.
 $ls
 certgen.sh  custom_mod_wl_apache.conf  custom_mod_wl_apache.conf_orig  input.yaml  README.md
 $ sh certgen.sh
 Generating certs for WEBLOGIC_HOST
 Generating a 2048 bit RSA private key
 ........................+++
 .......................................................................+++
 unable to write 'random state'
 writing new private key to 'apache-sample.key'
 -----
 $ ls
 certgen.sh                 custom_mod_wl_apache.conf_orig                             WEBLOGIC_HOST.info
 config.txt                 input.yaml                                                 WEBLOGIC_HOST.key
 custom_mod_wl_apache.conf  WEBLOGIC_HOST.crt  README.md
Prepare input values for the Apache webtier Helm chart.
Run the following commands to prepare the input value file for the Apache webtier Helm chart.
$ base64 -i ${SSL_CERT_FILE} | tr -d '\n'
$ base64 -i ${SSL_CERT_KEY_FILE} | tr -d '\n'
$ touch input.yaml
Update virtualHostName with the value of the WEBLOGIC_HOST in file ${WORKDIR}/charts/apache-samples/custom-sample/input.yaml
 $ cat apache-samples/custom-sample/input.yaml
 # Use this to provide your own Apache webtier configuration as needed; simply define this
 # path and put your own custom_mod_wl_apache.conf file under this path.
 persistentVolumeClaimName: wcp-domain-domain-pvc
 # The VirtualHostName of the Apache HTTP server. It is used to enable custom SSL configuration.
 virtualHostName: <WEBLOGIC_HOST>
Install the Apache webtier Helm chart to the domain wcpns namespace with the specified input parameters:
$ cd ${WORKDIR}/charts
$ kubectl create namespace apache-webtier
$ helm install  apache-webtier --values apache-samples/custom-sample/input.yaml --namespace wcpns apache-webtier --set image=oracle/apache:12.2.1.3
Check the status of the Apache webtier:
 $ kubectl get all -n wcpns | grep apache
Sample output of the status of the apache webtier:
pod/apache-webtier-apache-webtier-65f69dc6bc-zg5pj   1/1     Running     0          22h
service/apache-webtier-apache-webtier   NodePort       10.108.29.98     <none>        80:30305/TCP,4433:30443/TCP   22h
deployment.apps/apache-webtier-apache-webtier   1/1     1            1           22h
replicaset.apps/apache-webtier-apache-webtier-65f69dc6bc   1         1         1       22h
Once the Apache webtier load balancer is up, verify that the domain applications are accessible through the load balancer port 30305/30443. The application URLs for domain of type wcp are:
Note: Port
30305is the LOADBALANCER-Non-SSLPORT and Port30443is LOADBALANCER-SSLPORT.
 http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/console
 http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/em
 http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/webcenter
 http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/webcenterhelp
 http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/rest
 http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/rsscrawl
https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenter
https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/console
https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/em
https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rsscrawl
https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenterhelp
https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rest
$ helm delete apache-webtier -n wcpns