{{- if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "rabbitmq-ha.fullname" . }}
  labels:
    app: {{ template "rabbitmq-ha.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  annotations:
    {{- range $key, $value := .Values.ingress.annotations }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  rules:
    {{- if .Values.ingress.hostName }}
    - host: {{ .Values.ingress.hostName }}
      http:
    {{- else }}
    - http:
    {{- end }}
        paths:
          - path: {{ .Values.ingress.path }}
            backend:
              serviceName: {{ template "rabbitmq-ha.fullname" . }}
              servicePort: {{ .Values.rabbitmqManagerPort }}
{{- if .Values.ingress.tls }}
  tls:
    - secretName: {{  .Values.ingress.tlsSecret }}
      {{- if .Values.ingress.hostName }}
      hosts:
        - {{ .Values.ingress.hostName }}
      {{- end }}
{{- end }}
{{- end }}
