apiVersion: v1
kind: Secret
metadata:
  name: orcheo-postgres
stringData:
  ORCHEO_POSTGRES_DSN: postgresql://orcheo:orcheo@orcheo-postgres:5432/orcheo
---
apiVersion: v1
kind: Service
metadata:
  name: orcheo-api
spec:
  selector:
    app: orcheo-api
  ports:
    - name: http
      port: 8000
      targetPort: 8000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: orcheo-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: orcheo-api
  template:
    metadata:
      labels:
        app: orcheo-api
    spec:
      containers:
        - name: api
          image: ghcr.io/orcheo/app:latest
          ports:
            - containerPort: 8000
          env:
            - name: ORCHEO_REPOSITORY_BACKEND
              value: postgres
            - name: ORCHEO_CHECKPOINT_BACKEND
              value: postgres
            - name: ORCHEO_CHATKIT_BACKEND
              value: postgres
            - name: ORCHEO_HOST
              value: 0.0.0.0
            - name: ORCHEO_PORT
              value: "8000"
          envFrom:
            - secretRef:
                name: orcheo-postgres
          readinessProbe:
            httpGet:
              path: /docs
              port: 8000
            initialDelaySeconds: 10
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /docs
              port: 8000
            initialDelaySeconds: 20
            periodSeconds: 20
