# Единый Ingress с аутентификацией для всего приложения
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: python-navigator-demo
  namespace: python-navigator-demo
  annotations:
    nginx.ingress.kubernetes.io/auth-signin: https://$host/dex-authenticator/sign_in
    nginx.ingress.kubernetes.io/auth-url: https://python-navigator-demo-auth-dex-authenticator.python-navigator-demo.svc.cluster.local/dex-authenticator/auth
    nginx.ingress.kubernetes.io/auth-response-headers: X-Auth-Request-User,X-Auth-Request-Email,Authorization
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header X-Auth-Request-User $http_x_auth_request_user;
      proxy_set_header X-Auth-Request-Email $http_x_auth_request_email;
      proxy_set_header Authorization $http_authorization;
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - python-navigator-demo.127.0.0.1.sslip.io
    secretName: python-navigator-demo-tls
  rules:
  - host: python-navigator-demo.127.0.0.1.sslip.io
    http:
      paths:
      # API запросы идут напрямую в backend
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: backend
            port:
              number: 8000
      # Все остальное идет в frontend
      - path: /
        pathType: Prefix
        backend:
          service:
            name: frontend
            port:
              number: 80

