-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chart: Add IngressClass aliases. (#11109)
- Loading branch information
Showing
4 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
charts/ingress-nginx/templates/controller-ingressclass-aliases.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{- if .Values.controller.ingressClassResource.enabled -}} | ||
{{- range .Values.controller.ingressClassResource.aliases }} | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: IngressClass | ||
metadata: | ||
labels: | ||
{{- include "ingress-nginx.labels" $ | nindent 4 }} | ||
app.kubernetes.io/component: controller | ||
{{- with $.Values.controller.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
name: {{ . }} | ||
spec: | ||
controller: {{ $.Values.controller.ingressClassResource.controllerValue }} | ||
{{- with $.Values.controller.ingressClassResource.parameters }} | ||
parameters: {{ toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
92 changes: 92 additions & 0 deletions
92
charts/ingress-nginx/tests/controller-ingressclass-aliases_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
suite: Controller > IngressClass > Aliases | ||
templates: | ||
- controller-ingressclass-aliases.yaml | ||
|
||
tests: | ||
- it: should not create IngressClass aliases | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
|
||
- it: should create an IngressClass alias with name "nginx-alias" if `controller.ingressClassResource.aliases` is set | ||
set: | ||
controller.ingressClassResource.aliases: | ||
- nginx-alias | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: IngressClass | ||
- equal: | ||
path: metadata.name | ||
value: nginx-alias | ||
|
||
- it: should create an IngressClass alias without annotation `ingressclass.kubernetes.io/is-default-class` if `controller.ingressClassResource.default` is true | ||
set: | ||
controller.ingressClassResource.aliases: | ||
- nginx-alias | ||
controller.ingressClassResource.default: true | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: IngressClass | ||
- equal: | ||
path: metadata.name | ||
value: nginx-alias | ||
- notExists: | ||
path: metadata.annotations["ingressclass.kubernetes.io/is-default-class"] | ||
|
||
- it: should create an IngressClass alias with controller "k8s.io/ingress-nginx-internal" if `controller.ingressClassResource.controllerValue` is "k8s.io/ingress-nginx-internal" | ||
set: | ||
controller.ingressClassResource.aliases: | ||
- nginx-alias | ||
controller.ingressClassResource.controllerValue: k8s.io/ingress-nginx-internal | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: IngressClass | ||
- equal: | ||
path: metadata.name | ||
value: nginx-alias | ||
- equal: | ||
path: spec.controller | ||
value: k8s.io/ingress-nginx-internal | ||
|
||
- it: should create an IngressClass alias with parameters if `controller.ingressClassResource.parameters` is set | ||
set: | ||
controller.ingressClassResource.aliases: | ||
- nginx-alias | ||
controller.ingressClassResource.parameters: | ||
apiGroup: k8s.example.com | ||
kind: IngressParameters | ||
name: external-lb | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: IngressClass | ||
- equal: | ||
path: metadata.name | ||
value: nginx-alias | ||
- equal: | ||
path: spec.parameters | ||
value: | ||
apiGroup: k8s.example.com | ||
kind: IngressParameters | ||
name: external-lb | ||
|
||
- it: should create two IngressClass aliases if `controller.ingressClassResource.aliases` has two elements | ||
set: | ||
controller.ingressClassResource.aliases: | ||
- nginx-alias-1 | ||
- nginx-alias-2 | ||
asserts: | ||
- hasDocuments: | ||
count: 2 | ||
- isKind: | ||
of: IngressClass | ||
- matchRegex: | ||
path: metadata.name | ||
pattern: nginx-alias-(1|2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters