---
# ============================================================================
# Ingress for undateable.me (with TLS)
# ============================================================================
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: undateable-ingress
  namespace: undateable
  labels:
    app.kubernetes.io/name: undateable
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "50m"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
    # HSTS
    nginx.ingress.kubernetes.io/hsts: "true"
    nginx.ingress.kubernetes.io/hsts-max-age: "31536000"
    nginx.ingress.kubernetes.io/hsts-include-subdomains: "true"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - undateable.me
        - www.undateable.me
      secretName: undateable-tls-secret
  rules:
    # undateable.me
    - host: undateable.me
      http:
        paths:
          - path: /api/auth
            pathType: Prefix
            backend:
              service:
                name: auth-service
                port:
                  number: 8001
          - path: /api/profiles
            pathType: Prefix
            backend:
              service:
                name: profiles-service
                port:
                  number: 8002
          - path: /api/messages
            pathType: Prefix
            backend:
              service:
                name: messaging-service
                port:
                  number: 8003
          - path: /burn-api
            pathType: Prefix
            backend:
              service:
                name: burn-service
                port:
                  number: 8004
          - path: /ws
            pathType: Prefix
            backend:
              service:
                name: websocket-service
                port:
                  number: 8005
          - path: /
            pathType: Prefix
            backend:
              service:
                name: frontend-service
                port:
                  number: 80
    # www.undateable.me
    - host: www.undateable.me
      http:
        paths:
          - path: /api/auth
            pathType: Prefix
            backend:
              service:
                name: auth-service
                port:
                  number: 8001
          - path: /api/profiles
            pathType: Prefix
            backend:
              service:
                name: profiles-service
                port:
                  number: 8002
          - path: /api/messages
            pathType: Prefix
            backend:
              service:
                name: messaging-service
                port:
                  number: 8003
          - path: /burn-api
            pathType: Prefix
            backend:
              service:
                name: burn-service
                port:
                  number: 8004
          - path: /ws
            pathType: Prefix
            backend:
              service:
                name: websocket-service
                port:
                  number: 8005
          - path: /
            pathType: Prefix
            backend:
              service:
                name: frontend-service
                port:
                  number: 80
---
# ============================================================================
# Ingress for burnyourex.games (with TLS)
# ============================================================================
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: burnyourex-ingress
  namespace: undateable
  labels:
    app.kubernetes.io/name: burnyourex
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "50m"
    nginx.ingress.kubernetes.io/hsts: "true"
    nginx.ingress.kubernetes.io/hsts-max-age: "31536000"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - burnyourex.games
        - www.burnyourex.games
      secretName: burnyourex-tls-secret
  rules:
    - host: burnyourex.games
      http:
        paths:
          - path: /api
            pathType: Prefix
            backend:
              service:
                name: burn-service
                port:
                  number: 8004
          - path: /
            pathType: Prefix
            backend:
              service:
                name: burnyourex-frontend
                port:
                  number: 80
    - host: www.burnyourex.games
      http:
        paths:
          - path: /api
            pathType: Prefix
            backend:
              service:
                name: burn-service
                port:
                  number: 8004
          - path: /
            pathType: Prefix
            backend:
              service:
                name: burnyourex-frontend
                port:
                  number: 80
---
# ============================================================================
# WebSocket Ingress (with TLS + sticky sessions)
# ============================================================================
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: websocket-ingress
  namespace: undateable
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/upstream-hash-by: "$remote_addr"
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/session-cookie-name: "ws-sticky"
    nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
    nginx.ingress.kubernetes.io/websocket-services: "websocket-service"
    nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - undateable.me
        - www.undateable.me
      secretName: undateable-tls-secret
  rules:
    - host: undateable.me
      http:
        paths:
          - path: /socket.io
            pathType: Prefix
            backend:
              service:
                name: websocket-service
                port:
                  number: 8005
    - host: www.undateable.me
      http:
        paths:
          - path: /socket.io
            pathType: Prefix
            backend:
              service:
                name: websocket-service
                port:
                  number: 8005
