apiVersion: apps/v1
kind: Deployment
metadata:
  name: litellm
  namespace: ai-core
  labels:
    app.kubernetes.io/name: litellm
    app.kubernetes.io/component: llm-gateway
    agentic-os.io/layer: ai-core
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app.kubernetes.io/name: litellm
  template:
    metadata:
      labels:
        app.kubernetes.io/name: litellm
        agentic-os.io/layer: ai-core
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "4000"
        prometheus.io/path: "/metrics"
    spec:
      containers:
        - name: litellm
          image: ghcr.io/berriai/litellm:main-v1.55.10
          args:
            - "--config"
            - "/etc/litellm/config.yaml"
          ports:
            - containerPort: 4000
              name: http
          env:
            - name: LITELLM_MASTER_KEY
              valueFrom:
                secretKeyRef:
                  name: litellm-master
                  key: LITELLM_MASTER_KEY
            - name: LITELLM_SALT_KEY
              valueFrom:
                secretKeyRef:
                  name: litellm-master
                  key: LITELLM_SALT_KEY
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: litellm-master
                  key: DATABASE_URL
            - name: STORE_MODEL_IN_DB
              value: "True"
          livenessProbe:
            httpGet:
               path: /health/readiness
               port: 4000
            initialDelaySeconds: 30
            periodSeconds: 20
            timeoutSeconds: 5
            failureThreshold: 3
          readinessProbe:
            httpGet:
               path: /health/readiness
               port: 4000
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 3
          volumeMounts:
            - name: config
              mountPath: /etc/litellm
              readOnly: true
          resources:
            requests:
              cpu: 250m
              memory: 512Mi
            limits:
              cpu: "2"
              memory: 2Gi
      volumes:
        - name: config
          configMap:
            name: litellm-config
