apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: archon-ingress
  labels:
    app.kubernetes.io/component: ingress
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/proxy-body-size: 50m
    nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
    nginx.ingress.kubernetes.io/proxy-set-headers: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/upstream-vhost: $host
    nginx.ingress.kubernetes.io/websocket-services: archon-server-service
spec:
  tls:
    - hosts:
        - archon.automatizase.com.br
      secretName: archon-tls-cert
  rules:
    - host: archon.automatizase.com.br
      http:
        paths:
          # Backend API routes
          - path: /api
            pathType: ImplementationSpecific
            backend:
              service:
                name: archon-server-service
                port:
                  number: 8181

          # Health check
          - path: /health
            pathType: ImplementationSpecific
            backend:
              service:
                name: archon-server-service
                port:
                  number: 8181

          # WebSocket
          - path: /socket.io
            pathType: ImplementationSpecific
            backend:
              service:
                name: archon-server-service
                port:
                  number: 8181

          # MCP Server
          - path: /mcp
            pathType: Prefix
            backend:
              service:
                name: archon-mcp-service
                port:
                  number: 8051

          # Agents Service
          - path: /agents
            pathType: Prefix
            backend:
              service:
                name: archon-agents-service
                port:
                  number: 8052

          # Frontend (must be last - catch-all)
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: archon-frontend-service
                port:
                  number: 3737
