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

[Helm] Add support for ingressClassName #780

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions charts/consul/templates/ui-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This is because while networks.k8s.io/v1 was introduced in Kubernetes v1.15+, the Ingress resource was
promoted to v1 only in Kubernetes v1.19+. This ensures the correct API version is chosen that supports
the Ingress resource. */}}
{{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "19" ) }}
{{- if semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1
{{- else }}
apiVersion: networking.k8s.io/v1beta1
Expand All @@ -25,9 +25,12 @@ metadata:
{{ tpl .Values.ui.ingress.annotations . | nindent 4 | trim }}
{{- end }}
spec:
{{- if and .Values.ui.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ui.ingress.className }}
{{- end }}
rules:
{{ $global := .Values.global }}
{{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "19" ) }}
{{- if semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion }}
{{- range .Values.ui.ingress.hosts }}
- host: {{ .host | quote }}
http:
Expand Down
22 changes: 22 additions & 0 deletions charts/consul/test/unit/ui-ingress.bats
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,25 @@ load _helpers
yq -r '.spec.rules[0].http.paths[0].pathType' | tee /dev/stderr)
[ "${actual}" = "ImplementationSpecific" ]
}

#--------------------------------------------------------------------
# ingressClassName

@test "ui/Ingress: no ingressClassName by default" {
local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.ingressClassName' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "ui/Ingress: no ingressClassName by default" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the tests are complaining about a duplicate test name? Should this be "ui/Ingress: set ingressClassName to nginx"

local actual=$(helm template \
-s templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'ui.ingress.ingressClassName=nginx' \
. | tee /dev/stderr |
yq -r '.spec.ingressClassName' | tee /dev/stderr)
[ "${actual}" = "nginx" ]
}
3 changes: 2 additions & 1 deletion charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,8 @@ ui:
ingress:
# This will create an Ingress resource for the Consul UI.
# @type: boolean
enabled: false
enabled: true
className: ""

# pathType override - see: https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types
pathType: Prefix
Expand Down