apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
  {{- toYaml .Values.ingress.annotations | nindent 4 }}
  labels:
    app: report-aggregator
    {{- include "common.labels" . | nindent 4 }}
  name: report-aggregator
spec:
  tls:
    - hosts:
        - {{ .Values.ingress.host }}
      secretName: {{ .Values.ingress.tlsSecretName }}
  rules:
    - host: {{ .Values.ingress.host }}
      http:
        paths:
          - path: /api
            pathType: Prefix
            backend:
              service:
                name: backend
                port:
                  number: 80
          - path: /
            pathType: Prefix
            backend:
              service:
                name: frontend
                port:
                  number: 80
---
# oauth2
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: report-aggregator-oauth2
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: {{ .Values.ingress.host }}
      http:
        paths:
          - path: /oauth2
            pathType: Prefix
            backend:
              service:
                name: report-aggregator-oauth2-proxy
                port:
                  number: 4180
---
kind: Service
apiVersion: v1
metadata:
  name: report-aggregator-oauth2-proxy
spec:
  type: ExternalName
  externalName: {{ .Values.ingress.oauthExternalName }}
  ports:
    - port: 4180
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
  {{- toYaml .Values.ingressBackend.annotations | nindent 4 }}
  labels:
    app: report-aggregator
    {{- include "common.labels" . | nindent 4 }}
  name: report-aggregator-api
spec:
  tls:
    - hosts:
        - {{ .Values.ingressBackend.host }}
      secretName: {{ .Values.ingressBackend.tlsSecretName }}
  rules:
    - host: {{ .Values.ingressBackend.host }}
      http:
        paths:
          - path: /api
            pathType: Prefix
            backend:
              service:
                name: backend
                port:
                  number: 80
          - path: /
            pathType: Prefix
            backend:
              service:
                name: frontend
                port:
                  number: 80