apiVersion: v1
kind: Service
metadata:
  name: bgs
  namespace: atproto
spec:
  selector:
    app: bgs
  ports:
    - port: 2470
      targetPort: 2470
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: bgs-data
  namespace: atproto
spec:
  accessModes: ["ReadWriteOnce"]
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bgs
  namespace: atproto
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bgs
  template:
    metadata:
      labels:
        app: bgs
    spec:
      containers:
        - name: bgs
          image: registry/bgs
          ports:
            - containerPort: 2470
          env:
            - name: DATABASE_URL
              value: "postgres://postgres:postgres@database/bgs"
            - name: CARSTORE_DATABASE_URL
              value: "postgres://postgres:postgres@database/carstore"
            - name: DATA_DIR
              value: "/data"
            - name: ATP_PLC_HOST
              value: "https://plc.syu.is"
            - name: BGS_NEW_PDS_PER_DAY_LIMIT
              value: "1000"
            - name: BGS_ADMIN_KEY
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: bgs-admin-key
          volumeMounts:
            - name: data
              mountPath: /data
          livenessProbe:
            httpGet:
              path: /xrpc/_health
              port: 2470
            initialDelaySeconds: 15
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /xrpc/_health
              port: 2470
            initialDelaySeconds: 5
            periodSeconds: 5
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: bgs-data
