Skip to content

Commit

Permalink
helm:bugfix - handle kubernetes ingress api depreciation (#545)
Browse files Browse the repository at this point in the history
The extensions/v1beta1 and networking.k8s.io/v1beta1 API versions
of Ingress are no longer supported in v1.22. Platform helm files were no
able to handle with this changes. This pull request adds a validation
to check the cluster version and use a correct ingress api version.

Signed-off-by: Nathan Martins <nathan.martins@zup.com.br>
  • Loading branch information
nathanmartinszup authored Feb 2, 2022
1 parent 37cb256 commit c06306c
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions deployments/helm/horusec-platform/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,12 @@ Print "true" if the API pathType field is supported.
Return the appropriate apiVersion for Ingress.
*/}}
{{- define "ingress.apiVersion" -}}
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.Version -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "networking.k8s.io/v1" -}}
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -414,23 +416,26 @@ If enabled, return Ingress Rules.
{{- end -}}

rules:
{{- range $host, $components := $hosts }}
- host: {{ $host }}
http:
paths:
{{- range $component := $components }}
- backend:
serviceName: {{ $component.name }}
servicePort: {{ $component.port.http }}
{{- if not (eq "manager" $component.name) }}
path: {{ $component.ingress.path }}
{{- if eq "true" (include "ingress.supportsPathType" .) }}
pathType: Prefix
{{- range $host, $components := $hosts }}
- host: {{ $host }}
http:
paths:
{{- range $component := $components }}
- path: {{ $component.ingress.path }}
pathType: "Prefix"
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $component.name }}
port:
number: {{ $component.port.http }}
{{- else }}
serviceName: {{ $component.name }}
servicePort: {{ $component.port.http }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end }}
{{- end }}


{{/*
Expand Down

0 comments on commit c06306c

Please sign in to comment.