HAProxy with Kubernetes in a DR setup HAProxy with Kubernetes in a DR setup kubernetes kubernetes

HAProxy with Kubernetes in a DR setup


Now, this solution works, but the worker names and the corresponding nodePorts are hard-coded in this config, which obviously is inconvenient as and when more workers are added (or removed/changed).

You can explicitly configure the NodePort for your Kubernetes Service so it doesn't pick a random port and you always use the same port on your external HAProxy:

apiVersion: v1kind: Servicemetadata:  name: <my-nodeport-service>  labels:    <my-label-key>: <my-label-value>spec:  selector:    <my-selector-key>: <my-selector-value>  type: NodePort  ports:   - port: <service-port>     nodePort: 32200

We came across the HAProxy Ingress Controller (https://www.haproxy.com/blog/haproxy_ingress_controller_for_kubernetes/) which sounds promising, but (we feel) effectively adds another HAProxy layer to the mix..and thus, adds another failure point.

You could run the HAProxy ingress inside the cluster and remove the HAproxy outside the cluster, but this really depends on what type of service you are running. The Kubernetes Ingress is Layer 7 resource, for example. The DR here would be handled by having multiple replicas of your HAProxy ingress controller.