Administration

Add an auxiliary configuration

You can add raw HAProxy configuration directives to your HAProxy Unified Gateway load balancer configuration. You can define entirely new config sections, such as to define cache, mailers, or ring sections. This file will be loaded when the HAProxy Unified Gateway starts up. This may be useful if you are migrating a legacy HAProxy configuration to the HAProxy Unified Gateway.

Here are the differences between the two types of configuration files:

Filename Description Controlled by
haproxy.cfg Reflects the state of pods and services in your Kubernetes cluster. HAProxy Unified Gateway
haproxy-aux.cfg Supports additional HAProxy Enterprise directives. Kubernetes administrator

Update the controller deployment Jump to heading

To add the auxiliary configuration, you will need to add your configuration directives to a file and mount it as a ConfigMap Volume inside of the HAProxy Unified Gateway controller container.

  1. Create a file named haproxy-auxiliary.cfg.

  2. Add the HAProxy configuration directives that you want to use to the file.

    For example, let’s add an entirely new section to the file. We’ll use the cache section:

    haproxy-auxiliary.cfg
    haproxy
    cache mycache
    total-max-size 4095
    max-object-size 10000
    max-age 30
    haproxy-auxiliary.cfg
    haproxy
    cache mycache
    total-max-size 4095
    max-object-size 10000
    max-age 30

    Be sure to add a blank line at the end of the file, otherwise HAProxy will get the error Missing LF on last line, file might have been truncated and fail to load the file.

  3. Load the file into your Kubernetes cluster as a ConfigMap resource.

    nix
    kubectl create configmap haproxy-auxiliary-configmap --from-file haproxy-auxiliary.cfg --namespace haproxy-unified-gateway
    nix
    kubectl create configmap haproxy-auxiliary-configmap --from-file haproxy-auxiliary.cfg --namespace haproxy-unified-gateway

    In this example:

    • A ConfigMap is an API object for storing non-confidential information in key-value pairs that makes your applications easily portable.
    • Kubernetes automatically updates the mounted volume when you update the ConfigMap.
  4. Deploy the HAProxy Unified Gateway controller again with the ConfigMap attached as a ConfigMap volume. Add a volume to the Deployment pod template specification and a volumeMount to the container.

    controller.yaml
    yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    labels:
    run: haproxy-unified-gateway
    name: haproxy-unified-gateway
    namespace: haproxy-unified-gateway
    spec:
    template:
    spec:
    volumes:
    - name: aux-config
    configMap:
    name: hug-aux-config
    ...
    containers:
    - name: haproxy-unified-gateway
    volumeMounts:
    - name: aux-config
    mountPath: /usr/local/hug/aux
    controller.yaml
    yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    labels:
    run: haproxy-unified-gateway
    name: haproxy-unified-gateway
    namespace: haproxy-unified-gateway
    spec:
    template:
    spec:
    volumes:
    - name: aux-config
    configMap:
    name: hug-aux-config
    ...
    containers:
    - name: haproxy-unified-gateway
    volumeMounts:
    - name: aux-config
    mountPath: /usr/local/hug/aux
    kubectl apply -f controller.yaml
    kubectl apply -f controller.yaml
    output
    text
    deployment.apps/haproxy-unified-gateway configured
    service/haproxy-unified-gateway unchanged
    output
    text
    deployment.apps/haproxy-unified-gateway configured
    service/haproxy-unified-gateway unchanged

Update the configuration file Jump to heading

Follow these steps to update the auxiliary configuration file later.

  1. Call kubectl edit to edit the ConfigMap.

    nix
    kubectl edit configmap haproxy-auxiliary-configmap --namespace haproxy-unified-gateway
    nix
    kubectl edit configmap haproxy-auxiliary-configmap --namespace haproxy-unified-gateway
  2. The file opens in your text editor. Make changes to the file and then save and close it. The controller will detect the change and reload the file.

See also Jump to heading

  • For an overview of the ConfigMaps key-value mapping object, see the Kubernetes documentation at ConfigMaps.

Do you have any suggestions on how we can improve the content of this page?