How to enable router HAProxy access log in Openshift 4
Environment
- Red Hat OpenShift Container Platform (RHOCP)
- 4
- IngressController
- HAProxy
Issue
- How to enable
router
HAProxy access log in Openshift 4? - How to workaround ingress access logging for Openshift prior to 4.5?
Resolution
For OSD and ROSA, refer to Customize the ingresscontroller in OSD and ROSA.
OpenShift 4.5+ and newest versions
Enabling the ingress access logs is available in newer versions of OpenShift. Refer to current documentation for Configuring Ingress access logging.
Note: It is currently not possible to configure the access log format, and RFE-3811: httpslogformat option in ingresscontroller was created to request it.
OpenShift prior 4.5 version
-
The openshift-ingress router is managed by an openshift-ingress-operator and we cannot modify configuration to enable HAProxy logging.
-
To workaround this you can export router deployment, change the name and import it as an unmanaged deployment, then modify the configuration. Note that this is unmanaged, you need to manage it by yourself and needs some extra effort on every updates - review and compare latest managed router deployment information then modify the unmanaged router if needed.
-
The following procedure is unsupported and will leave Ingress in an unmanaged state, so it is recommended to upgraded to to 4.5 and onwards to apply the official procedure in the documentation:
$ oc get deploy/router-default -o yaml --export > deploy-router-default.yaml $ cp deploy-router-default.yaml deploy-router-custom.yaml $ vi deploy-router-custom.yaml # Modify name, add ROUTER_SYSLOG_ADDRESS env var etc. $ oc patch ingresscontrollers default --type=merge -p '{"spec": {"replicas": 0}}' # Set 0 replica to managed default router $ oc create -f deploy-router-custom.yaml # Create unmanaged custom router
Root Cause
Enabling the ingress access logs is available in newer versions of OpenShift.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments