{{- if semverCompare ">=1.18.0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1beta1
kind: IngressClass
metadata:
  name: {{ .Values.controller.ingressClass }}
{{- if .Values.controller.setAsDefaultIngress }}
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
{{- end }}
spec:
  controller: nginx.org/ingress-controller
{{- end }}
{{- if semverCompare ">=1.18.0-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: networking.k8s.io/v1beta1
kind: IngressClass
metadata:
  name: {{ .Values.controller.ingressClass }}
{{- if .Values.controller.setAsDefaultIngress }}
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
{{- end }}
spec:
  controller: nginx.org/ingress-controller
{{- end }}
Fix ingressclass semver comparison in helm chart
Fix ingressclass semver comparison in helm chart

Bug first appeared in: https://github.com/nginxinc/kubernetes-ingress/commit/d893dd093ea3582be48c03ed79c92bbf5ddd73d3

Helm will fail to install the ingressclass resource when the patch value
of the semver contains some non-numerical suffix.

For example:
* v1.18.8-rc.1
* v1.18.10-gke.601