apiVersion: v1
kind: Service
metadata:
  name: api-server-service
spec:
  selector:
    app: api-server
  ports:
    - name: api-server-port
      protocol: TCP
      port: 80
      targetPort: 8080
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-server-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api-server
  template:
    metadata:
      labels:
        app: api-server
    spec:
      containers:
      - name: api-server
        image: danswer/danswer-backend:latest
        imagePullPolicy: IfNotPresent
        command:
          - "/bin/sh"
          - "-c"
          - |
            alembic upgrade head &&
            echo "Starting Danswer Api Server" &&
            uvicorn danswer.main:app --host 0.0.0.0 --port 8080
        ports:
        - containerPort: 8080
        # There are some extra values since this is shared between services
        # There are no conflicts though, extra env variables are simply ignored
        envFrom:
        - configMapRef:
            name: env-configmap
        volumeMounts:
        - name: dynamic-storage
          mountPath: /home/storage
        - name: file-connector-storage
          mountPath: /home/file_connector_storage
      volumes:
      - name: dynamic-storage
        persistentVolumeClaim:
          claimName: dynamic-pvc
      - name: file-connector-storage
        persistentVolumeClaim:
          claimName: file-connector-pvc
