HAProxy Enterprise Documentation 1.6

Kubernetes (Generic)

This section shows you how to install the HAProxy Kubernetes Ingress Controller into your Kubernetes cluster.

Pre-installation checklist

  • A running Kubernetes cluster
  • The helm command-line tool
  • The kubectl command-line tool

Choose one of the following installation methods:

Install with Helm

  1. Add the HAProxy Technologies Helm repository:

    $ helm repo add haproxytech https://haproxytech.github.io/helm-charts
  2. Update your list of charts:

    $ helm repo update
  3. Install the latest version of the ingress controller:

    $ helm install kubernetes-ingress haproxytech/kubernetes-ingress

    By default, the Helm chart adds --ingress.class=haproxy to the ingress controller. That means that it will use Ingress resources only if they specify an annotation of kubernetes.io/ingress.class: haproxy. You can disable this by setting --set controller.ingressClass=null when calling helm install.

Install a Specific Version

  1. You can use helm search repo with the --versions flag to list all of the available versions of the Helm chart:

    $ helm search repo haproxy --versions
    
      NAME                            CHART VERSION  APP VERSION  DESCRIPTION
      haproxytech/kubernetes-ingress  1.16.3          1.6.7           A Helm chart for HAProxy Kubernetes Ingress Con...
      haproxytech/kubernetes-ingress  1.16.2          1.6.5           A Helm chart for HAProxy Kubernetes Ingress Con...
      haproxytech/kubernetes-ingress  1.16.1          1.6.5           A Helm chart for HAProxy Kubernetes Ingress Con...
      haproxytech/kubernetes-ingress  1.16.0          1.6.3           A Helm chart for HAProxy Kubernetes Ingress Con...
      haproxytech/kubernetes-ingress  1.15.4          1.6.3           A Helm chart for HAProxy Kubernetes Ingress Con...
  2. Then, use a specific chart version when you call helm install:

    $ helm install kubernetes-ingress haproxytech/kubernetes-ingress \
      --version 1.16.2

Install with preset NodePort values

By default, the ingress controller creates a Kubernetes service that assigns random NodePort ports. You can see this by calling kubectl get service kubernetes-service. In the example below, the ingress controller listens on port 30706 for HTTP traffic and 30675 for HTTPS traffic. Port 31441 publishes the HAProxy Stats page.

$ kubectl get service kubernetes-ingress

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                     AGE
kubernetes-ingress   NodePort    10.97.154.7      <none>        80:30706/TCP,443:30675/TCP,1024:31441/TCP   32s

You can choose specific NodePort ports instead by setting the controller.service.nodePort.http, controller.service.nodePort.https, and controller.service.nodePort.stat Helm chart fields.

$ helm install kubernetes-ingress haproxytech/kubernetes-ingress \
  --set controller.service.nodePorts.http=30000 \
  --set controller.service.nodePorts.https=30001 \
  --set controller.service.nodePorts.stat=30002

Run the ingress controller as a DaemonSet

By default, the ingress controller is installed using a Deployment resource. To use a DaemonSet instead, set the controller.kind field to DaemonSet and controller.daemonset.useHostPort to true.

$ helm install haproxy haproxytech/kubernetes-ingress \
  --set controller.kind=DaemonSet \
  --set controller.daemonset.useHostPort=true

Install with kubectl

If you prefer to install without Helm, then you can install the Deployment YAML file directly.

  1. Use the kubectl apply command to deploy the controller:

    $ kubectl apply -f https://raw.githubusercontent.com/haproxytech/kubernetes-ingress/v1.6/deploy/haproxy-ingress.yaml
    You can also download the YAML file and modify it for your needs before you apply it (such as changing the namespace in which the controller runs and/or its exposed ports).

Check your installation

Verify that the controller is installed into your Kubernetes cluster by using the command kubectl get pods -A:

$ kubectl get pods -A

  NAMESPACE   NAME                                                  READY   STATUS    RESTARTS   AGE
  default     kubernetes-ingress-7dd4cc4b-x5fkv                     1/1     Running   0          1m
  default     kubernetes-ingress-default-backend-5579b8796c-dkk4v   1/1     Running   0          1m

Call kubectl get svc -A to see which ports were mapped. In this example, port 32063 forwards to port 80 on the ingress controller.

$ kubectl get svc -A

default  kubernetes-ingress  NodePort  10.102.234.240  <none>  80:32063/TCP,443:30286/TCP,1024:32290/TCP  26m

Next up

Rancher