apiVersion: v1
kind: Service
metadata:
  name: pds
  namespace: atproto
spec:
  selector:
    app: pds
  ports:
    - port: 3000
      targetPort: 3000
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pds-data
  namespace: atproto
spec:
  accessModes: ["ReadWriteOnce"]
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pds
  namespace: atproto
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pds
  template:
    metadata:
      labels:
        app: pds
    spec:
      containers:
        - name: pds
          image: registry/pds
          command: ["node", "--enable-source-maps", "index.js"]
          ports:
            - containerPort: 3000
          env:
            - name: PDS_HOSTNAME
              value: "syu.is"
            - name: PDS_DB_POSTGRES_URL
              value: "postgres://postgres:postgres@database/pds"
            - name: PDS_DATA_DIRECTORY
              value: "/data"
            - name: PDS_BLOBSTORE_DISK_LOCATION
              value: "/data/img/static"
            - name: PDS_BSKY_APP_VIEW_DID
              value: "did:web:bsky.syu.is"
            - name: PDS_BSKY_APP_VIEW_URL
              value: "https://bsky.syu.is"
            - name: PDS_CRAWLERS
              value: "https://bgs.syu.is"
            - name: PDS_SEQUENCER_ENABLED
              value: "true"
            - name: PDS_SEQUENCER_DB_LOCATION
              value: "/data/sequencer.sqlite"
            - name: PDS_DEV_MODE
              value: "true"
            - name: PDS_DID_PLC_URL
              value: "https://plc.syu.is"
            - name: PDS_ENABLE_DID_DOC_WITH_SESSION
              value: "true"
            - name: PDS_INVITE_INTERVAL
              value: "604800000"
            - name: PDS_SERVICE_DID
              value: "did:web:syu.is"
            - name: PDS_EMAIL_FROM_ADDRESS
              value: "no-reply@syu.is"
            - name: PDS_INVITE_REQUIRED
              value: "true"
            - name: PDS_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: pds-admin-password
            - name: PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: pds-plc-rotation-key
            - name: PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: pds-repo-signing-key
            - name: PDS_JWT_SECRET
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: pds-jwt-secret
            - name: PDS_EMAIL_SMTP_URL
              valueFrom:
                secretKeyRef:
                  name: atproto-secrets
                  key: pds-email-smtp-url
          volumeMounts:
            - name: data
              mountPath: /data
          livenessProbe:
            httpGet:
              path: /xrpc/_health
              port: 3000
            initialDelaySeconds: 15
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /xrpc/_health
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 5
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: pds-data
