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.
-
Create a file named
haproxy-auxiliary.cfg. -
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
cachesection:haproxy-auxiliary.cfghaproxycache mycachetotal-max-size 4095max-object-size 10000max-age 30haproxy-auxiliary.cfghaproxycache mycachetotal-max-size 4095max-object-size 10000max-age 30Be 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.
-
Load the file into your Kubernetes cluster as a ConfigMap resource.
nixkubectl create configmap haproxy-auxiliary-configmap --from-file haproxy-auxiliary.cfg --namespace haproxy-unified-gatewaynixkubectl create configmap haproxy-auxiliary-configmap --from-file haproxy-auxiliary.cfg --namespace haproxy-unified-gatewayIn 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.
-
Deploy the HAProxy Unified Gateway controller again with the ConfigMap attached as a ConfigMap volume. Add a
volumeto the Deployment pod template specification and avolumeMountto the container.controller.yamlyamlapiVersion: apps/v1kind: Deploymentmetadata:labels:run: haproxy-unified-gatewayname: haproxy-unified-gatewaynamespace: haproxy-unified-gatewayspec:template:spec:volumes:- name: aux-configconfigMap:name: hug-aux-config...containers:- name: haproxy-unified-gatewayvolumeMounts:- name: aux-configmountPath: /usr/local/hug/auxcontroller.yamlyamlapiVersion: apps/v1kind: Deploymentmetadata:labels:run: haproxy-unified-gatewayname: haproxy-unified-gatewaynamespace: haproxy-unified-gatewayspec:template:spec:volumes:- name: aux-configconfigMap:name: hug-aux-config...containers:- name: haproxy-unified-gatewayvolumeMounts:- name: aux-configmountPath: /usr/local/hug/auxkubectl apply -f controller.yamlkubectl apply -f controller.yamloutputtextdeployment.apps/haproxy-unified-gateway configuredservice/haproxy-unified-gateway unchangedoutputtextdeployment.apps/haproxy-unified-gateway configuredservice/haproxy-unified-gateway unchanged
Update the configuration file Jump to heading
Follow these steps to update the auxiliary configuration file later.
-
Call
kubectl editto edit the ConfigMap.nixkubectl edit configmap haproxy-auxiliary-configmap --namespace haproxy-unified-gatewaynixkubectl edit configmap haproxy-auxiliary-configmap --namespace haproxy-unified-gateway -
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.