Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart: Render controller.ingressClassResource.parameters natively. #11126

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions charts/ingress-nginx/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,6 @@ Check the ingress controller version tag is at most three versions behind the la
{{- end -}}
{{- end -}}

{{/*
IngressClass parameters.
*/}}
{{- define "ingressClass.parameters" -}}
{{- if .Values.controller.ingressClassResource.parameters -}}
parameters:
{{ toYaml .Values.controller.ingressClassResource.parameters | indent 4}}
{{ end }}
{{- end -}}

{{/*
Extra modules.
*/}}
Expand Down
8 changes: 5 additions & 3 deletions charts/ingress-nginx/templates/controller-ingressclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Values.controller.ingressClassResource.name }}
{{- if .Values.controller.ingressClassResource.default }}
{{- if .Values.controller.ingressClassResource.default }}
annotations:
ingressclass.kubernetes.io/is-default-class: "true"
{{- end }}
{{- end }}
spec:
controller: {{ .Values.controller.ingressClassResource.controllerValue }}
{{ template "ingressClass.parameters" . }}
{{- with .Values.controller.ingressClassResource.parameters }}
parameters: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/ingress-nginx/tests/controller-daemonset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ tests:
path: spec.template.spec.containers[0].args
content: --enable-metrics=false

- it: should create a DaemonSet with argument `--controller-class=k8s.io/ingress-nginx-internal` if `controller.ingressClassResource.controllerValue` is "k8s.io/ingress-nginx-internal"
set:
controller.kind: DaemonSet
controller.ingressClassResource.controllerValue: k8s.io/ingress-nginx-internal
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --controller-class=k8s.io/ingress-nginx-internal

- it: should create a DaemonSet with resource limits if `controller.resources.limits` is set
set:
controller.kind: DaemonSet
Expand Down
8 changes: 8 additions & 0 deletions charts/ingress-nginx/tests/controller-deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ tests:
path: spec.template.spec.containers[0].args
content: --enable-metrics=false

- it: should create a Deployment with argument `--controller-class=k8s.io/ingress-nginx-internal` if `controller.ingressClassResource.controllerValue` is "k8s.io/ingress-nginx-internal"
set:
controller.ingressClassResource.controllerValue: k8s.io/ingress-nginx-internal
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --controller-class=k8s.io/ingress-nginx-internal

- it: should create a Deployment with resource limits if `controller.resources.limits` is set
set:
controller.resources.limits.cpu: 500m
Expand Down
77 changes: 77 additions & 0 deletions charts/ingress-nginx/tests/controller-ingressclass_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
suite: Controller > IngressClass
templates:
- controller-ingressclass.yaml

tests:
- it: should create an IngressClass
asserts:
- hasDocuments:
count: 1
- isKind:
of: IngressClass
- equal:
path: metadata.name
value: nginx

- it: should create an IngressClass with name "nginx-internal" if `controller.ingressClassResource.name` is "nginx-internal"
set:
controller.ingressClassResource.name: nginx-internal
asserts:
- hasDocuments:
count: 1
- isKind:
of: IngressClass
- equal:
path: metadata.name
value: nginx-internal

- it: "should create an IngressClass with annotation `ingressclass.kubernetes.io/is-default-class: \"true\"` if `controller.ingressClassResource.default` is true"
set:
controller.ingressClassResource.default: true
asserts:
- hasDocuments:
count: 1
- isKind:
of: IngressClass
- equal:
path: metadata.name
value: nginx
- equal:
path: metadata.annotations["ingressclass.kubernetes.io/is-default-class"]
value: "true"

- it: should create an IngressClass with controller "k8s.io/ingress-nginx-internal" if `controller.ingressClassResource.controllerValue` is "k8s.io/ingress-nginx-internal"
set:
controller.ingressClassResource.controllerValue: k8s.io/ingress-nginx-internal
asserts:
- hasDocuments:
count: 1
- isKind:
of: IngressClass
- equal:
path: metadata.name
value: nginx
- equal:
path: spec.controller
value: k8s.io/ingress-nginx-internal

- it: should create an IngressClass with parameters if `controller.ingressClassResource.parameters` is set
set:
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
- equal:
path: spec.parameters
value:
apiGroup: k8s.example.com
kind: IngressParameters
name: external-lb