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-ee-backend:latest
        imagePullPolicy: IfNotPresent
        command:
          - "/bin/sh"
          - "-c"
          - |
            alembic upgrade head &&
            echo "Starting Danswer Api Server" &&
            uvicorn ee.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
        env:
        - name: OAUTH_CLIENT_ID
          valueFrom:
            secretKeyRef:
              name: danswer-secrets
              key: google_oauth_client_id
        - name: OAUTH_CLIENT_SECRET
          valueFrom:
            secretKeyRef:
              name: danswer-secrets
              key: google_oauth_client_secret
        envFrom:
        - configMapRef:
            name: env-configmap
