{{- if .Values.ingress.enabled }}
{{- $path := .Values.ingress.path -}}
{{- $pathType := .Values.ingress.pathType -}}
{{- $servicePort := .Values.service.servicePort -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
{{- if .Values.ingress.annotations }}
  annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
  labels:
  {{- include "chart.labels" . | nindent 4 }}
  {{ with .Values.ingress.extraLabels }}
{{ toYaml . | indent 4 }}
  {{ end }}
  name: {{ template "chart.fullname" . }}
  namespace: {{ .Release.Namespace }}
spec:
  ingressClassName: {{ .Values.ingress.ingressClassName }}
  rules:
  {{- $serviceName := include "chart.fullname" . }}
  {{- range .Values.ingress.hosts }}
  - host: {{ . | quote }}
    http:
      paths:
        - path: {{ $path }}
          pathType: {{ $pathType }}
          backend:
            service:
              name: {{ $serviceName }}
              port:
                number: {{ $servicePort }}
  {{- end -}}
{{- if .Values.ingress.tls }}
  tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}