{{- if .Values.ingress.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "rocketchat.fullname" . }}
  labels:
    app: {{ template "rocketchat.name" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
  annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- if .Values.ingress.tls }}
    kubernetes.io/tls-acme: "true"
{{- end }}
spec:
{{- if .Values.ingress.tls }}
  tls:
  - hosts:
    - {{ .Values.host }}
{{- if (ne "-" .Values.ingress.secretName) }}
    secretName: {{ .Values.ingress.secretName | default (printf "%s-tls" (include "rocketchat.fullname" .)) }}
{{- end }}
{{- end }}
  rules:
  - host: {{ .Values.host }}
    http:
      paths:
      - path: /
        backend:
          serviceName: {{ template "rocketchat.fullname" . }}
          servicePort: 3000
{{- end -}}
