Configuration reference
IngressClass
An Ingress resource can target a specific ingress controller instance, which is useful when running multiple ingress controllers in the same cluster. To target a specific ingress controller, you must first install that ingress controller with a unique class name.
Configure the controller’s class name Jump to heading
There are two ways to assign a class name to an ingress controller:
- define an
IngressClass
resource - set the
--ingress.class
argument
The IngressClass
resource is available in Kubernetes 1.18+ and is the
official method.
Default ingress class
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 ingressClassName: haproxy
. You can disable this by setting --set controller.ingressClass=null
when calling helm install
.
This change was introduced in version 1.6.
Define an IngressClass resource Jump to heading
Create an IngressClass
resource with its spec.controller
field set to the name of the ingress controller you want to use:
ingress-class.ymlyaml
apiVersion: networking.k8s.io/v1kind: IngressClassmetadata:name: haproxyspec:controller: haproxy.org/ingress-controller
ingress-class.ymlyaml
apiVersion: networking.k8s.io/v1kind: IngressClassmetadata:name: haproxyspec:controller: haproxy.org/ingress-controller
Set the --ingress.class argument Jump to heading
You can set the class name via the --ingress.class
argument during installation:
nix
helm install haproxy-kubernetes-ingress haproxytech/kubernetes-ingress \--create-namespace \--namespace haproxy-controller \--set controller.ingressClass=haproxy
nix
helm install haproxy-kubernetes-ingress haproxytech/kubernetes-ingress \--create-namespace \--namespace haproxy-controller \--set controller.ingressClass=haproxy
Set IngressClassName Jump to heading
To target an ingress controller from within an Ingress
resource, add an IngressClassName
field:
yaml
kind: IngressapiVersion: networking.k8s.io/v1metadata:name: testspec:ingressClassName: haproxyrules:- host: test.k8s.localhttp:paths:- path: /backend:serviceName: http-echoservicePort: http
yaml
kind: IngressapiVersion: networking.k8s.io/v1metadata:name: testspec:ingressClassName: haproxyrules:- host: test.k8s.localhttp:paths:- path: /backend:serviceName: http-echoservicePort: http
Set ingress.class Jump to heading
The ingress.class
annotation is the legacy way to target an Ingress Controller. For example, consider the following Ingress
object in which we use ingress.class
to target the haproxy ingress controller:
yaml
kind: IngressapiVersion: networking.k8s.io/v1metadata:name: testannotations:ingress.class: haproxyspec:rules:- host: test.k8s.localhttp:paths:- path: /backend:serviceName: http-echoservicePort: http
yaml
kind: IngressapiVersion: networking.k8s.io/v1metadata:name: testannotations:ingress.class: haproxyspec:rules:- host: test.k8s.localhttp:paths:- path: /backend:serviceName: http-echoservicePort: http
Eligibility rules Jump to heading
- If the
--ingress.class
argument of the controller is not configured:- Accept Ingress resource when neither
ingress.class
annotation noringressClassName
fields are set. - Accept Ingress resource when
ingress.class
annotation is not set butingressClassName
field matches.
- Accept Ingress resource when neither
- If the
--ingress.class
argument of the controller is configured:- Accept Ingress resource when neither
ingress.class
annotation noringressClassName
fields are set but controller argument--EmptyIngressClass
is enabled. - Accept Ingress resource when –
ingress.class
argument is equal toingress.class
annotation. - Accept Ingress resource when
ingressClassName
field matches.
- Accept Ingress resource when neither
- Ignore Ingress resource otherwise.
Do you have any suggestions on how we can improve the content of this page?