apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: oauth2-proxy
  labels:
    {{- include "kubernetes.labels" . | nindent 4 }}
  annotations:
    external-dns.alpha.kubernetes.io/hostname: {{ .Values.hostName | quote }}
    external-dns.alpha.kubernetes.io/ttl: "300"
    external-dns.alpha.kubernetes.io/target: {{ .Values.externalDnsTarget }}
    kubernetes.io/tls-acme: "true"
    cert-manager.io/cluster-issuer: {{ .Values.clusterIssuer }}
    kubernetes.io/ingress.class: {{ .Values.ingressClass | quote }}
    ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-csrftoken"
spec:
  rules:
    - host: {{ .Values.hostName }}
      http:
        paths:
          - backend:
              serviceName: {{ include "kubernetes.fullname" . }}
              servicePort: {{ .Values.oauthConfig.port }}
            path: /oauth2

  tls:
    - hosts:
        - {{ .Values.hostName }}
