# helm_charts_controller-ingress.yaml
{{- if .Values.controller.ingress.enabled -}}
{{- $fullName := include "cosbench.controller.fullname" . -}}
{{- $servicePort := .Values.controller.service.port -}}
{{- $ingressPath := .Values.controller.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    app: {{ template "cosbench.name" . }}
    chart: {{ template "cosbench.chart" . }}
    component: controller
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
{{- with .Values.controller.ingress.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.controller.ingress.tls }}
  tls:
  {{- range .Values.controller.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end }}
  rules:
  {{- range .Values.controller.ingress.hosts }}
    - host: {{ . }}
      http:
        paths:
          - path: {{ $ingressPath }}
            backend:
              serviceName: {{ $fullName }}
              servicePort: controller
  {{- end }}
{{- end }}