|
| 1 | +# Load balancing with Voyager/HAProxy |
| 2 | + |
| 3 | +This document explains how to set up Voyager to use HAProxy as load balancer to WebLogic domain(s) running in Kubernetes. |
| 4 | + |
| 5 | +Voyager is a HAProxy backed ingress controller for Kubernetes. More information about Voyager ingress controller can be found at: https://appscode.com/products/voyager/6.0.0/concepts/. |
| 6 | + |
| 7 | +## Set up Voyager/HAProxy automatically |
| 8 | +To set up Voyager/HAProxy automatically you can run the create-weblogic-domain.sh script to create a WebLogic domain in Kubernetes. You need to change the domain inputs YAML file first. There are three related properties. |
| 9 | + |
| 10 | +``` |
| 11 | +... |
| 12 | +# Load balancer to deploy. Supported values are: APACHE, TRAEFIK, VOYAGER, NONE |
| 13 | +loadBalancer: VOYAGER |
| 14 | +... |
| 15 | +# Load balancer web port |
| 16 | +loadBalancerWebPort: 30305 |
| 17 | +
|
| 18 | +# Load balancer dashboard port |
| 19 | +loadBalancerDashboardPort: 30315 |
| 20 | +``` |
| 21 | + |
| 22 | +* The `loadBalancer` property needs to be changed to `VOYAGER`. |
| 23 | +* The `loadBalancerWebPort` property is to specify the `NodePort` number to access the HAProxy load balancer itself. |
| 24 | +* The `loadBalancerDashboardPort` property is to specify the `NodePort` number to access the HAPRoxy stats webpage. |
| 25 | + |
| 26 | +Then after running create-weblogic-domain.sh script, the WebLogic domain is created and the Voyager/HAProxy is also installed and configured properly. |
| 27 | +You can access the HAProxy stats webpage via `http://<hostIP>:30315/` and you'll get a webpage like below. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +After you deploy some application to the WebLogic cluster, you can send requests to the application via `http://<hostIP>:30305/<ctx>/`. The requests are sent to the HAProxy load balancer and the HAProxy will distribute the requests to managed servers of the WebLogic cluster. |
| 32 | + |
| 33 | +### What happens underground? |
| 34 | +#### 1. Install the Voyager operator |
| 35 | +The Voyager operator is installed in `voyager` namespace if it hasn't been done before. |
| 36 | + |
| 37 | +You should have a voyager-operator-*** pod running in the `voyager` namespace. |
| 38 | +``` |
| 39 | +$ kubectl get pod -n voyager |
| 40 | +NAME READY STATUS RESTARTS AGE |
| 41 | +voyager-operator-86bcd6f656-jj2t6 1/1 Running 1 8d |
| 42 | +``` |
| 43 | +And new CRD groups are registered by the Voyager operator. |
| 44 | +``` |
| 45 | +$ kubectl get crd -l app=voyager |
| 46 | +NAME AGE |
| 47 | +certificates.voyager.appscode.com 8d |
| 48 | +ingresses.voyager.appscode.com 8d |
| 49 | +``` |
| 50 | +Now the Voyager operator watches Ingress resources in any namespace. |
| 51 | + |
| 52 | +#### 2. Create an Voyager Ingress resource |
| 53 | +An Ingress resource is generated based on the WebLogic domain configuration and deployed to Kubernetes. Here is an example of what the Voyager Ingress resource might look like for a WebLogic cluster named `cluster-1`, in a domain named `base_domain` with domainUID `domain1`. |
| 54 | + |
| 55 | +```yaml |
| 56 | +apiVersion: voyager.appscode.com/v1beta1 |
| 57 | +kind: Ingress |
| 58 | +metadata: |
| 59 | + name: domain1-voyager |
| 60 | + namespace: default |
| 61 | + labels: |
| 62 | + weblogic.domainUID: domain1 |
| 63 | + weblogic.domainName: base_domain |
| 64 | + annotations: |
| 65 | + ingress.appscode.com/type: 'NodePort' |
| 66 | + ingress.appscode.com/stats: 'true' |
| 67 | +spec: |
| 68 | + rules: |
| 69 | + - host: domain1.cluster-1 |
| 70 | + http: |
| 71 | + nodePort: '30305' |
| 72 | + paths: |
| 73 | + - backend: |
| 74 | + serviceName: domain1-cluster-cluster-1 |
| 75 | + servicePort: '8001' |
| 76 | +``` |
| 77 | +
|
| 78 | +The Kubernetes service named `domain1-cluster-cluster-1` referred by the Ingress resource is also created by create-weblogic-domain.sh which dynamically includes all the managed servers in the cluster. |
| 79 | + |
| 80 | +```bash |
| 81 | +$ kubectl get endpoints domain1-cluster-cluster-1 |
| 82 | +NAME ENDPOINTS AGE |
| 83 | +domain1-cluster-cluster-1 10.244.0.170:8001,10.244.0.171:8001,10.244.0.172:8001 2d |
| 84 | +``` |
| 85 | +When the Ingress resource is deployed, following Kubernetes resources are created by the Voyager operator: |
| 86 | +```bash |
| 87 | +$ kubectl get deploy,pod,svc | awk '/voyager/ || /NAME/' |
| 88 | +NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE |
| 89 | +deploy/voyager-domain1-voyager 1 1 1 1 1d |
| 90 | +
|
| 91 | +NAME READY STATUS RESTARTS AGE |
| 92 | +po/voyager-domain1-voyager-577bcfb4b-kbnhp 1/1 Running 0 1d |
| 93 | +
|
| 94 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 95 | +svc/voyager-domain1-voyager NodePort 10.109.137.41 <none> 80:30305/TCP 1d |
| 96 | +svc/voyager-domain1-voyager-stats ClusterIP 10.105.160.124 <none> 56789/TCP 1d |
| 97 | +``` |
| 98 | +#### 3. Create a NodePort service |
| 99 | +A NodePort service is created to expose the HAProxy stats. Following are the example yaml file for the service. |
| 100 | +```yaml |
| 101 | +apiVersion: v1 |
| 102 | +kind: Service |
| 103 | +metadata: |
| 104 | + name: domain1-voyager-stats |
| 105 | + namespace: default |
| 106 | + labels: |
| 107 | + app: domain1-voyager-stats |
| 108 | + weblogic.domainUID: domain1 |
| 109 | + weblogic.domainName: base_domain |
| 110 | +spec: |
| 111 | + type: NodePort |
| 112 | + ports: |
| 113 | + - name: client |
| 114 | + protocol: TCP |
| 115 | + port: 56789 |
| 116 | + targetPort: 56789 |
| 117 | + nodePort: 30315 |
| 118 | + selector: |
| 119 | + origin: voyager |
| 120 | + origin-name: domain1-voyager |
| 121 | +``` |
| 122 | + |
| 123 | +## Set up Voyager manually to WebLogic domain running in Kubernetes |
| 124 | +You may want to manually set up Voyager to WebLogic domain running in Kubernetes, in cases when some of the default settings of the automatic steps don't meet your requirements, or your WebLogic domain is not created by the WebLogic Operator. |
| 125 | +You need to refer to Voyager documents to do the setup: https://appscode.com/products/voyager/6.0.0/setup/. |
| 126 | +### 1. Install the Voyager operator |
| 127 | +Refer to install guide of Voyager here: install guide: https://appscode.com/products/voyager/6.0.0/setup/install/. |
| 128 | +### 2. Create an Voyager Ingress resource |
| 129 | +Refer to the detail here: https://appscode.com/products/voyager/6.0.0/concepts/overview/. You can choose different types for your Ingress: LoadBalancer, NodePort, HostPort and Internal. |
| 130 | + |
0 commit comments