---
# Service for RAG API
apiVersion: v1
kind: Service
metadata:
  name: provisioning-rag
  namespace: provisioning-rag
  labels:
    app: provisioning-rag
    component: api-service
  annotations:
    description: "RAG Service API endpoint"
spec:
  type: LoadBalancer
  selector:
    app: provisioning-rag
    component: api-service
  ports:
    - name: api
      port: 9090
      targetPort: api
      protocol: TCP
    - name: metrics
      port: 8888
      targetPort: metrics
      protocol: TCP
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 3600

---
# Headless Service for RAG StatefulSet (if needed for DNS resolution)
apiVersion: v1
kind: Service
metadata:
  name: provisioning-rag-headless
  namespace: provisioning-rag
  labels:
    app: provisioning-rag
    component: api-service
  annotations:
    description: "Headless service for RAG pods"
spec:
  type: ClusterIP
  clusterIP: None
  selector:
    app: provisioning-rag
    component: api-service
  ports:
    - name: api
      port: 9090
      targetPort: api
      protocol: TCP
    - name: metrics
      port: 8888
      targetPort: metrics
      protocol: TCP

---
# Service for SurrealDB
apiVersion: v1
kind: Service
metadata:
  name: surrealdb
  namespace: provisioning-rag
  labels:
    app: surrealdb
    component: database
  annotations:
    description: "SurrealDB service"
spec:
  type: ClusterIP
  selector:
    app: surrealdb
    component: database
  ports:
    - name: http
      port: 8000
      targetPort: http
      protocol: TCP
  sessionAffinity: None
