Skip to main content

MarkLogic Server on Kubernetes

MarkLogic HAProxy Load Balancer Configuration

This section describes how to configure the HAProxy Load Balancer.

Configure the ODBC App Server

First, configure the ODBC App Server by providing these values in the values.yaml file:

## Ports and load balancing type configuration for HAproxy
## There are three types of backends supported:
## 1. HTTP: HTTP(Layer 7) proxy mode. This works for most of the App Servers handling HTTP connections.
## 2. TCP: TCP(Layer 4) proxy mode. This works for the MarkLogic App Servers handling TCP connections like ODBC. 
ports:
  - name: app-service
    type: HTTP
    port: 8000
    targetPort: 8000
  - name: admin
    type: HTTP
    port: 8001
    targetPort: 8001
  - name: manage
    type: HTTP
    port: 8002
    targetPort: 8002
  - name: odbc
    type: TCP
    port: 5432
Auto-generated HAProxy configuration file

After adding the values to the values.yaml file, this appears in the auto-generated HAProxy configuration file:

## ODBC
 

 
frontend ml-cluster-odbc
 
    description "ml-cluster-odbc"
 
    mode tcp
 
    option tcplog
 
    bind :5432
 
    use_backend ml-cluster-odbc
 
 
backend ml-cluster-odbc
 
    description "ml-cluster-manage"
 
    mode tcp
 
    balance leastconn
 
    server ml-enode-mlenode-0 ml-enode-mlenode-0.ml-enode-mlenode-headless.ml.svc.cluster.local:5432 check resolvers dns init-addr none
 
    server ml-enode-mlenode-1 ml-enode-mlenode-1.ml-enode-mlenode-headless.ml.svc.cluster.local:5432 check resolvers dns init-addr none
Code explanation

In the Auto-generated HAProxy configuration file:

  • mode tcp - This mode is used because Layer4 LB is only required for ODBC connections.

  • option tcplog - This allows the log output to be enriched with data from the connection timers, the session status, the connection numbers, the frontend, backend, and server name. The source address and ports can also be included.

  • balance leastconn - With this configuration, HAProxy selects the servers with the fewest active sessions.

Service

After the HAProxy configuration file is generated, this service is deployed for the HAProxy load balancer:

apiVersion: v1
kind: Service
metadata:
  annotations:
    meta.helm.sh/release-name: ml-enode
    meta.helm.sh/release-namespace: ml
  labels:
    app.kubernetes.io/instance: ml-enode
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: ml-lb
    app.kubernetes.io/version: "2.7"
    helm.sh/chart: ml-lb-2.7
  name: ml-enode-ml-lb
  namespace: ml-lb
spec:
  clusterIP: 10.100.14.59
  clusterIPs:
  - 10.100.14.59
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: https
  - name: ml-admin
    port: 8001
    protocol: TCP
    targetPort: ml-admin
  - name: ml-manage
    port: 8002
    protocol: TCP
    targetPort: ml-manage
  - name: ml-odbc
    port: 5432
    protocol: TCP
    targetPort: ml-odbc
  - name: ml-query
    port: 8000
    protocol: TCP
    targetPort: ml-query
  - name: stat
    port: 1024
    protocol: TCP
    targetPort: stat
  selector:
    app.kubernetes.io/instance: ml-enode
    app.kubernetes.io/name: ml-lb
  sessionAffinity: None
  type: ClusterIP

Code explanation

In the Service code, this section is dedicated to ODBC:

 - name: ml-odbc
port: 5432
protocol: TCP
targetPort: ml-odbc

Note

The service is a standard ClusterIP service.