# Enhanced Services with Load Balancing Configuration
# These services include session affinity, health checks, and load balancing optimizations

---
# Backend API Service with Session Affinity
apiVersion: v1
kind: Service
metadata:
  name: veza-backend-api
  namespace: veza-production
  labels:
    app: veza-backend-api
  annotations:
    # Optional: For cloud load balancers
    # service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
    # service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
spec:
  type: ClusterIP
  # Session affinity for stateful operations (optional)
  # Uncomment if needed for sticky sessions
  # sessionAffinity: ClientIP
  # sessionAffinityConfig:
  #   clientIP:
  #     timeoutSeconds: 3600  # 1 hour
  ports:
  - name: http
    port: 8080
    targetPort: 8080
    protocol: TCP
  selector:
    app: veza-backend-api
---
# Frontend Service
apiVersion: v1
kind: Service
metadata:
  name: veza-frontend
  namespace: veza-production
  labels:
    app: veza-frontend
spec:
  type: ClusterIP
  ports:
  - name: http
    port: 80
    targetPort: 80
    protocol: TCP
  selector:
    app: veza-frontend
---
# Chat Server Service with WebSocket Support
apiVersion: v1
kind: Service
metadata:
  name: veza-chat-server
  namespace: veza-production
  labels:
    app: veza-chat-server
spec:
  type: ClusterIP
  # Session affinity recommended for WebSocket connections
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 3600  # 1 hour for WebSocket sessions
  ports:
  - name: http
    port: 8081
    targetPort: 8081
    protocol: TCP
  - name: ws
    port: 8082
    targetPort: 8082
    protocol: TCP
  selector:
    app: veza-chat-server
---
# Stream Server Service
apiVersion: v1
kind: Service
metadata:
  name: veza-stream-server
  namespace: veza-production
  labels:
    app: veza-stream-server
spec:
  type: ClusterIP
  ports:
  - name: http
    port: 8080
    targetPort: 8080
    protocol: TCP
  - name: ws
    port: 8081
    targetPort: 8081
    protocol: TCP
  selector:
    app: veza-stream-server

