apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: grafana
  namespace: grafana
  annotations:
    kubernetes.io/tls-acme: "true"
    nginx.ingress.kubernetes.io/upstream-vhost: $service_name.$namespace.svc.cluster.local:$service_port
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header l5d-dst-override $service_name.$namespace.svc.cluster.local:$service_port;
      grpc_set_header l5d-dst-override $service_name.$namespace.svc.cluster.local:$service_port;
    nginx.ingress.kubernetes.io/auth-snippet: |
      proxy_set_header l5d-dst-override {{ template "oauth2-proxy.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:80;
      grpc_set_header l5d-dst-override {{ template "oauth2-proxy.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:80;
    nginx.ingress.kubernetes.io/auth-url: http://{{ template "oauth2-proxy.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local/oauth2/auth
    nginx.ingress.kubernetes.io/auth-signin: "https://auth.k8s.{{ .Values.domain  }}/oauth2/start?rd=$host$escaped_request_uri"
    nginx.ingress.kubernetes.io/auth-response-headers: X-Auth-Request-User, X-Auth-Request-Email
spec:
  tls:
  - hosts:
    - grafana.k8s.{{ .Values.domain }}
    secretName: grafana-tls
  rules:
  - host: grafana.k8s.{{ .Values.domain }}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: grafana
            port:
              number: 80

