apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: vibevideo-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    # Sticky sessions to avoid mixed-version Next.js assets during rolling updates
    # (HTML from one pod + _next/static from another pod => client side error / ChunkLoadError)
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/affinity-mode: "persistent"
    nginx.ingress.kubernetes.io/session-cookie-name: "vv_route"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
    nginx.ingress.kubernetes.io/proxy-body-size: "16m"
    # Trust Cloudflare headers for real client IP
    nginx.ingress.kubernetes.io/use-forwarded-headers: "true"
    nginx.ingress.kubernetes.io/forwarded-for-header: "CF-Connecting-IP"
    nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
    nginx.ingress.kubernetes.io/proxy-buffers-number: "4"
    nginx.ingress.kubernetes.io/proxy-busy-buffers-size: "256k"
    nginx.ingress.kubernetes.io/large-client-header-buffers: "4 32k"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
spec:
  rules:
  - host: your-domain.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: vibevideo
            port:
              number: 80
  - host: your-domain.com
    http:
      paths:
      - path: /_worker
        pathType: Prefix
        backend:
          service:
            name: vibevideo-worker
            port:
              number: 80
# Optional API host. Uncomment only when deployment-api.yaml and service-api.yaml
# are enabled in kustomization.yaml.
#  - host: api.your-domain.com
#    http:
#      paths:
#      - path: /
#        pathType: Prefix
#        backend:
#          service:
#            name: vibevideo-api
#            port:
#              number: 80

