Installation
Install HAProxy Unified Gateway on premises
This guide shows you how to install HAProxy Kubernetes Unified Gateway into an on-premises Kubernetes cluster and enable it as a GatewayClass. Platform engineers can be responsible for this, determining which GatewayClass resources to allow in the cluster.
Pre-installation checklist Jump to heading
Before continuing, ensure that you’ve met these prerequisites:
- You have a Kubernetes cluster.
- You’ve installed the helm command-line tool if you plan to install using Helm.
- You’ve installed the kubectl command-line tool, which you can use to manage your cluster.
Enable Gateway API in your cluster Jump to heading
Supported version
HAProxy Unified Gateway supports Gateway API version 1.5.0.
To opt in to using Gateway API in your Kubernetes cluster, you must install a set of custom resource definitions.
-
Use
kubectlto install the Gateway API custom resource definitions.nixkubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.0/experimental-install.yamlnixkubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.0/experimental-install.yamloutputtextcustomresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/httproutes.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/referencegrants.gateway.networking.k8s.io createdoutputtextcustomresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/httproutes.gateway.networking.k8s.io createdcustomresourcedefinition.apiextensions.k8s.io/referencegrants.gateway.networking.k8s.io created
Install HAProxy Unified Gateway Jump to heading
After enabling Gateway API, install the HAProxy Unified Gateway controller. The controller runs a control loop that watches the cluster and implements Gateways backed by HAProxy. We’ll also add a GatewayClass so that teams can instantiate Gateways.
Install with kubectl Jump to heading
To install HAProxy Unified Gateway using kubectl:
-
Run these commands to install the necessary resources into your cluster:
nixkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_backends.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_defaults.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_globals.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_hugconfs.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_huggates.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/namespace.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/rbac.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/controller.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/hugconf.yamlnixkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_backends.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_defaults.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_globals.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_hugconfs.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/api/definition/gate.v3.haproxy.org_huggates.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/namespace.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/rbac.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/controller.yamlkubectl apply -f https://raw.githubusercontent.com/haproxytech/haproxy-unified-gateway/refs/heads/v1.0/example/deploy/hug/hugconf.yamloutputtextcustomresourcedefinition.apiextensions.k8s.io/backends.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/defaults.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/globals.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/hugconfs.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/huggates.gate.v3.haproxy.org creatednamespace/haproxy-unified-gateway createdserviceaccount/haproxy-unified-gateway createdclusterrole.rbac.authorization.k8s.io/haproxy-unified-gateway createdclusterrolebinding.rbac.authorization.k8s.io/haproxy-unified-gateway createddeployment.apps/haproxy-unified-gateway createdservice/haproxy-unified-gateway createdhugconf.gate.v3.haproxy.org/hugconf createdoutputtextcustomresourcedefinition.apiextensions.k8s.io/backends.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/defaults.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/globals.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/hugconfs.gate.v3.haproxy.org createdcustomresourcedefinition.apiextensions.k8s.io/huggates.gate.v3.haproxy.org creatednamespace/haproxy-unified-gateway createdserviceaccount/haproxy-unified-gateway createdclusterrole.rbac.authorization.k8s.io/haproxy-unified-gateway createdclusterrolebinding.rbac.authorization.k8s.io/haproxy-unified-gateway createddeployment.apps/haproxy-unified-gateway createdservice/haproxy-unified-gateway createdhugconf.gate.v3.haproxy.org/hugconf createdThis installs the following:
- The custom resource definitions.
- A namespace named
haproxy-unified-gatewayto contain all of the controller-related resources. - A ServiceAccount named
haproxy-unified-gatewaythat the controller will run as, giving it access to the Kubernetes API. - A ClusterRole that defines the necessary permissions to watch and manage resources in the cluster and a ClusterRoleBinding to assign that role to the service account.
- A Deployment named
haproxy-unified-gatewaythat runs the HAProxy Unified Gateway controller. - A Service named
haproxy-unified-gatewayof typeNodePortto expose the gateway’s HTTP, HTTPS, and stats ports. - A HugConf custom resource that configures logging.
-
Add a GatewayClass. A GatewayClass adds the HAProxy Unified Gateway as a class of Gateways available in your cluster. Teams in your organization can then create Gateways of that type. Create a file named
gatewayclass.yamland add the following to it:gatewayclass.yamlyamlapiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata:name: haproxyspec:controllerName: gate.haproxy.org/huggatewayclass.yamlyamlapiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata:name: haproxyspec:controllerName: gate.haproxy.org/hugIn this definition:
namewill uniquely identify this GatewayClass in the cluster. Gateways will reference this name. We usehaproxy.controllerNamerefers to the controller with which this GatewayClass is associated. The default value isgate.haproxy.org/hug, but you can override it by setting the--controller-nameargument when deploying the controller.
Apply the changes with
kubectl:nixkubectl apply -f gatewayclass.yamlnixkubectl apply -f gatewayclass.yamloutputtextgatewayclass.gateway.networking.k8s.io/haproxy createdoutputtextgatewayclass.gateway.networking.k8s.io/haproxy created -
Verify that HAProxy Unified Gateway is installed into your Kubernetes cluster by using the command
kubectl get pods:nixkubectl get pods --namespace haproxy-unified-gatewaynixkubectl get pods --namespace haproxy-unified-gatewayoutputtextNAME READY STATUS RESTARTS AGEhaproxy-unified-gateway-55744dfb75-46ncx 1/1 Running 0 58moutputtextNAME READY STATUS RESTARTS AGEhaproxy-unified-gateway-55744dfb75-46ncx 1/1 Running 0 58mCall
kubectl get svcto see which ports were mapped. In this example, port 31080 forwards to port 8080 on the controller.nixkubectl get svc --namespace haproxy-unified-gatewaynixkubectl get svc --namespace haproxy-unified-gatewayoutputtextNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEhaproxy-unified-gateway NodePort 10.102.118.90 <none> 8080:31080/TCP,8443:31443/TCP,31024:31678/TCP 13houtputtextNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEhaproxy-unified-gateway NodePort 10.102.118.90 <none> 8080:31080/TCP,8443:31443/TCP,31024:31678/TCP 13h