apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: bakery-ingress-https
  namespace: bakery-ia
  labels:
    app.kubernetes.io/name: bakery-ia
    app.kubernetes.io/component: ingress
  annotations:
    # Nginx ingress controller annotations
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "10m"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    # SSE and WebSocket configuration for long-lived connections
    nginx.ingress.kubernetes.io/proxy-buffering: "off"
    nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
    nginx.ingress.kubernetes.io/upstream-keepalive-timeout: "3600"
    # WebSocket upgrade support
    nginx.ingress.kubernetes.io/websocket-services: "gateway-service"
    # CORS configuration for HTTPS
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-origin: "https://your-domain.com"  # To be overridden in overlays
    nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE, OPTIONS, PATCH"
    nginx.ingress.kubernetes.io/cors-allow-headers: "Content-Type, Authorization, X-Requested-With, Accept, Origin, Cache-Control"
    nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
    # Cert-manager annotations for automatic certificate issuance
    # Using issuer appropriate for environment
    cert-manager.io/cluster-issuer: "letsencrypt-prod"  # To be overridden in dev overlay
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - your-domain.com  # To be overridden in overlays
    secretName: bakery-tls-cert  # To be overridden in overlays
  rules:
  - host: your-domain.com  # To be overridden in overlays
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: frontend-service
            port:
              number: 3000
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: gateway-service
            port:
              number: 8000
  - host: api.your-domain.com  # To be overridden in overlays
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: gateway-service
            port:
              number: 8000
  # Note: SigNoz monitoring is deployed via Helm in the 'signoz' namespace
  # SigNoz creates its own Ingress via Helm chart configuration
  # Access at: https://monitoring.your-domain.com/ (configured in signoz-values.yaml)
  # SignOz ingress is managed separately - no need to configure here