{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ include "kubeinvaders.fullname" . }}
  labels:
    app.kubernetes.io/name: kubeinvaders
    helm.sh/chart: {{ include "kubeinvaders.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    {{- with .Values.additionalLabels }}
    {{- . | toYaml | nindent 4 }}
    {{- end }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  tls:
    - hosts:
      - {{ .Values.ingress.hostName | quote }}
      secretName: {{ .Values.ingress.secretName }}
  rules:
  - host: {{ .Values.ingress.hostName }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: kubeinvaders
            port:
              number: {{ .Values.service.targetPort }}
{{- end }}
