{{- if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ include "apache.fullname" . }}
  labels: {{- include "apache.labels" . | nindent 4 }}
  annotations:
    {{- if .Values.ingress.certManager }}
    kubernetes.io/tls-acme: "true"
    {{- end }}
    {{- range $key, $value := .Values.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  rules:
    {{- if .Values.ingress.hostname }}
    - host: {{ .Values.ingress.hostname }}
      http:
        paths:
          - path: /
            backend:
              serviceName: "{{ template "apache.fullname" $ }}"
              servicePort: http
    {{- end }}
    {{- range .Values.ingress.hosts }}
    - host: {{ .name }}
      http:
        paths:
          - path: {{ default "/" .path }}
            backend:
              serviceName: "{{ template "apache.fullname" $ }}"
              servicePort: http
    {{- end }}
  {{- if .Values.ingress.tls }}
  tls: {{- toYaml .Values.ingress.tls | nindent 4 }}
  {{- end }}
{{- end }}
