Skip to content

Commit 35f2e5c

Browse files
committed
DOC: Add an IngressClass section
1 parent b4559c7 commit 35f2e5c

File tree

4 files changed

+84
-4
lines changed

4 files changed

+84
-4
lines changed

documentation/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,11 @@ tls-alpn: http/1.1
841841
##### `ingress.class`
842842

843843
Identifies the ingress controller to be used. If this value is the same as the [--ingress.class](./controller.md#--ingressclass) controller arg, the ingress resource will be processed.
844-
Starting from kubernetes 1.18, a new `ingressClassName` field has been added to the Ingress spec resource. This fields should reference an `IngressClass` and HAProxy Ingress controller will process the Ingress resource if the controller value of the referenced `IngressClass` is `haproxy.org/ingress-controller`. More About how IngressClass mechanism can be found in official kubernetes [documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class).
845844

846845
Available on: `ingress`
847846

847+
:information_source: In kubernetes 1.18+, a new `IngressClass` resource can be referenced by Ingress objects to target an Ingress Controller. More details can be found in the [IngressClass doc entry](./ingressclass.md).
848+
848849
:information_source: In case both `ingress.class` annotation and `ingressClassName` are used, `ingress.class` will have precedence.
849850

850851
Possible values:

documentation/controller.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ args:
239239

240240
A name to assign to the ingress controller so that Ingress objects can target it apart from other running ingress controllers.
241241

242-
:information_source: Starting from kubernetes 1.18, a new `ingressClass` resource can be referenced by Ingress objects to target an Ingress Controller. HAProxy Ingress Controller will handle IngressClasses with controller value equal to `haproxy.org/ingress-controller`. More About how IngressClass mechanism can be found in official kubernetes [documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class).
242+
:information_source: In kubernetes 1.18+, a new `IngressClass` resource can be referenced by Ingress objects to target an Ingress Controller. More details can be found in the [IngressClass doc entry](./ingressclass.md).
243243

244244
Possible values:
245245

documentation/doc.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ image_arguments:
138138
- argument: --ingress.class
139139
description: A name to assign to the ingress controller so that Ingress objects can target it apart from other running ingress controllers.
140140
tip:
141-
- Starting from kubernetes 1.18, a new `ingressClass` resource can be referenced by Ingress objects to target an Ingress Controller. HAProxy Ingress Controller will handle IngressClasses with controller value equal to `haproxy.org/ingress-controller`. More About how IngressClass mechanism can be found in official kubernetes [documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class).
141+
- In kubernetes 1.18+, a new `IngressClass` resource can be referenced by Ingress objects to target an Ingress Controller.
142+
More details can be found in the [IngressClass doc entry](./ingressclass.md).
142143
values:
143144
- The name of the ingress class
144145
version_min: "1.4"
@@ -931,8 +932,9 @@ annotations:
931932
default: ""
932933
description:
933934
- Identifies the ingress controller to be used. If this value is the same as the [--ingress.class](./controller.md#--ingressclass) controller arg, the ingress resource will be processed.
934-
- Starting from kubernetes 1.18, a new `ingressClassName` field has been added to the Ingress spec resource. This fields should reference an `IngressClass` and HAProxy Ingress controller will process the Ingress resource if the controller value of the referenced `IngressClass` is `haproxy.org/ingress-controller`. More About how IngressClass mechanism can be found in official kubernetes [documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class).
935935
tip:
936+
- In kubernetes 1.18+, a new `IngressClass` resource can be referenced by Ingress objects to target an Ingress Controller.
937+
More details can be found in the [IngressClass doc entry](./ingressclass.md).
936938
- In case both `ingress.class` annotation and `ingressClassName` are used, `ingress.class` will have precedence.
937939
values:
938940
- The ingress class name

documentation/ingressclass.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# IngressClass
2+
3+
An Ingress resource can target a specific Ingress controller instance which is useful when running multiple ingress controllers in the same cluster. Targetting an Ingress controller means only a specific controller should handle/implement the ingress resource.
4+
This can be done using either the `IngressClassName` field or the `ingress.class` annotation.
5+
6+
## IngressClassName
7+
The `IngressClassName` field is available in kubernetes 1.18+ and is the [official](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class) way to handle this. This field should reference an IngressClass resource that contains the name of the controller that should implement the class.
8+
For example, let's consider the following Ingress object:
9+
```yaml
10+
kind: Ingress
11+
apiVersion: networking.k8s.io/v1
12+
metadata:
13+
name: test
14+
spec:
15+
ingressClassName: haproxy
16+
rules:
17+
- host: test.k8s.local
18+
http:
19+
paths:
20+
- path: /
21+
backend:
22+
serviceName: http-echo
23+
servicePort: http
24+
```
25+
26+
If there is a single HAProxy Ingress Controller instance then no need to set `--ingress.class`, but rather create an IngressClass resource with Spec.Controller set to **haproxy.org/ingress-controller**
27+
```yaml
28+
apiVersion: networking.k8s.io/v1
29+
kind: IngressClass
30+
metadata:
31+
name: haproxy
32+
spec:
33+
controller: haproxy.org/ingress-controller
34+
```
35+
36+
In the other hand if multiple HAProxy Ingress Controllers are deployed then `--ingress.class` argument can be used to target one of them. This can be done via the following IngressClass (notice Spec.Controller is set to **haproxy.org/ingress-controller/prod**)
37+
```yaml
38+
apiVersion: networking.k8s.io/v1
39+
kind: IngressClass
40+
metadata:
41+
name: haproxy-prod
42+
spec:
43+
controller: haproxy.org/ingress-controller/prod
44+
```
45+
In this case `--ingress.class` should be set to **prod** and the `ingressClassName` field should be **haproxy-prod**.
46+
47+
## ingress.class annotation
48+
The `ingress.class` annotation is the legacy way to target an Ingress Controller.
49+
For example, let's consider the following Ingress object:
50+
```yaml
51+
kind: Ingress
52+
apiVersion: networking.k8s.io/v1
53+
metadata:
54+
name: test
55+
annotations:
56+
ingress.class: haproxy
57+
spec:
58+
rules:
59+
- host: test.k8s.local
60+
http:
61+
paths:
62+
- path: /
63+
backend:
64+
serviceName: http-echo
65+
servicePort: http
66+
```
67+
In this case only HAProxy Ingress Controllers with `--ingress.class` set to "haproxy" are going to implement the previous Ingress object.
68+
69+
## Eligibility rules
70+
- If the `--ingress.class` argument of the controller is not configured:
71+
- **Accept** Ingress resource when neither `ingress.class` annotation nor `ingressClassName` fields are set.
72+
- **Accept** Ingress resource when `ingress.class` annotation is not set but `ingressClassName` field matches.
73+
- If the `--ingress.class` argument of the controller is configured:
74+
- **Accept** Ingress resource when neither `ingress.class` annotation nor `ingressClassName` fields are set but controller argument `--EmptyIngressClass` is enabled.
75+
- **Accept** Ingress resource when --`ingress.class` argument is equal to `ingress.class` annotation.
76+
- **Accept** Ingress resource when `ingressClassName` field matches.
77+
- **Ignore** Ingress resource otherwise.

0 commit comments

Comments
 (0)