---
apiVersion: v1
kind: ConfigMap
metadata:
  name: sollol-config
  namespace: sollol
data:
  hosts.txt: |
    http://ollama-node-1:11434
    http://ollama-node-2:11434
    http://ollama-node-3:11434
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sollol-gateway
  namespace: sollol
  labels:
    app: sollol-gateway
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sollol-gateway
  template:
    metadata:
      labels:
        app: sollol-gateway
    spec:
      containers:
      - name: sollol
        image: ghcr.io/benevolentjoker-johnl/sollol:latest
        ports:
        - containerPort: 8000
          name: http
          protocol: TCP
        - containerPort: 9090
          name: metrics
          protocol: TCP
        env:
        - name: SOLLOL_PORT
          value: "8000"
        - name: SOLLOL_WORKERS
          value: "4"
        - name: SOLLOL_DASK_WORKERS
          value: "4"
        - name: LOG_LEVEL
          value: "INFO"
        volumeMounts:
        - name: config
          mountPath: /app/config
          readOnly: true
        resources:
          requests:
            memory: "512Mi"
            cpu: "500m"
          limits:
            memory: "2Gi"
            cpu: "2000m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 10
          periodSeconds: 5
      volumes:
      - name: config
        configMap:
          name: sollol-config
---
apiVersion: v1
kind: Service
metadata:
  name: sollol-gateway
  namespace: sollol
  labels:
    app: sollol-gateway
spec:
  type: ClusterIP
  ports:
  - port: 8000
    targetPort: 8000
    protocol: TCP
    name: http
  - port: 9090
    targetPort: 9090
    protocol: TCP
    name: metrics
  selector:
    app: sollol-gateway
---
apiVersion: v1
kind: Service
metadata:
  name: sollol-gateway-external
  namespace: sollol
  labels:
    app: sollol-gateway
spec:
  type: LoadBalancer
  ports:
  - port: 8000
    targetPort: 8000
    protocol: TCP
    name: http
  selector:
    app: sollol-gateway
