J release changes
[ric-plt/ric-dep.git] / helm / infrastructure / subcharts / kong / templates / ingress-class.yaml
1 {{/* Default to not managing if unsupported or created outside this chart */}}
2 {{- $includeIngressClass := false -}}
3 {{- if .Values.ingressController.enabled -}}
4   {{- if (.Capabilities.APIVersions.Has "networking.k8s.io/v1/IngressClass") -}}
5     {{- with (lookup "networking.k8s.io/v1" "IngressClass" "" .Values.ingressController.ingressClass) -}}
6       {{- if (hasKey .metadata "annotations") -}}
7         {{- if (eq $.Release.Name (get .metadata.annotations "meta.helm.sh/release-name")) -}}
8           {{/* IngressClass exists and is managed by this chart */}}
9           {{- $includeIngressClass = true -}}
10         {{- end -}}
11       {{- end -}}
12     {{- else -}}
13       {{/* IngressClass doesn't exist */}}
14       {{- $includeIngressClass = true -}}
15     {{- end -}}
16   {{- end -}}
17 {{- end -}}
18 {{- if $includeIngressClass -}}
19 apiVersion: networking.k8s.io/v1
20 kind: IngressClass
21 metadata:
22   name: {{ .Values.ingressController.ingressClass }}
23   {{- if .Values.ingressController.ingressClassAnnotations }}
24   annotations:
25   {{- range $key, $value := .Values.ingressController.ingressClassAnnotations }}
26     {{ $key }}: {{ $value | quote }}
27   {{- end }}
28   {{- end }}
29   labels:
30   {{- include "kong.metaLabels" . | nindent 4 }}
31 spec:
32   controller: ingress-controllers.konghq.com/kong
33 {{- end -}}