{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ .Release.Name | quote }}
  labels:
    {{- include "..labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- with .Values.ingress.ingressClassName }}
  ingressClassName: {{ . }}
  {{- end }}
  {{- if .Values.ingress.enabled }}
  tls:
  - hosts:
    {{- range .Values.ingress.hosts }}
    - {{ . | quote }}
    {{- end }}
    secretName: {{ print .Release.Name "-tls" | quote }}
  {{- end }}
  rules:
  - host: {{ .Values.ingress.host | quote }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: {{ print .Release.Name "-webserver" | quote }}
            port:
              name: http
{{- end -}}
