# Headless Service for external endpoint (no selector)
apiVersion: v1
kind: Service
metadata:
  name: moltbot-gateway
  namespace: home-apps
  labels:
    name: moltbot-gateway
spec:
  # No selector - this is a headless service for external endpoint
  ports:
  - name: gateway
    port: 18789
    targetPort: 18789
    protocol: TCP
  - name: bridge
    port: 18790
    targetPort: 18790
    protocol: TCP
---
# Manual EndpointSlice pointing to external IP
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
  name: moltbot-gateway-external
  namespace: home-apps
  labels:
    kubernetes.io/service-name: moltbot-gateway
addressType: IPv4
endpoints:
  - addresses:
      - "192.168.1.10"
ports:
  - name: gateway
    port: 18789
    protocol: TCP
  - name: bridge
    port: 18790
    protocol: TCP
---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: moltbot-gateway-ingress
  namespace: home-apps
  annotations:
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    # WebSocket support - required for moltbot gateway
    nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    # Enable WebSocket upgrade via standard nginx-ingress annotation
    nginx.ingress.kubernetes.io/websocket-services: "moltbot-gateway"
    # Note: OAuth2 removed - moltbot uses its own gateway token authentication
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - bot.junv.cc
    secretName: moltbot-gateway-tls
  rules:
  - host: bot.junv.cc
    http:
      paths:
      - backend:
          service:
            name: moltbot-gateway
            port:
              number: 18789
        path: /
        pathType: Prefix
