apiVersion: apps/v1
kind: Deployment
metadata:
  name: video-files
spec:
  replicas: 1
  selector:
    matchLabels:
      app: video-files
  template:
    metadata:
      labels:
        app: video-files
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8004"
    spec:
      volumes:
        - { name: video-data-download, persistentVolumeClaim: { claimName: video-data-download } }
        - { name: video-data-src, persistentVolumeClaim: { claimName: video-data-src } }
        - { name: secret, secret: { secretName: video } }
      containers:
        - name: ingest
          image: reg:5000/video_image
          command:
            - pdm
            - run
            - python
            - ingest.py
          volumeMounts:
            - { name: video-data-download, mountPath: /data/video-download }
            - { name: video-data-src, mountPath: /data/video-src }


        - name: files
          image: reg:5000/video_image
          # alternate: [ "webfsd", "-Fp", "9054", "-r", "/vids/" ]
          command:
            - pnpm
            - exec
            - node
            - ./serve-files.js
          ports:
            - containerPort: 8003
          volumeMounts:
            - { name: video-data-download, mountPath: /data/video-download }
            - { name: video-data-src, mountPath: /data/video-src }
            - { name: secret, mountPath: /secret }

        - name: api
          image: reg:5000/video_image
          command:
            - pdm
            - run
            - python
            - video.py
          ports:
            - containerPort: 8004
          volumeMounts:
            - { name: secret, mountPath: /secret }
          resources:
            requests:
              cpu: "2"

      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: "kubernetes.io/hostname"
                    operator: In
                    values: ["ditto"]
---
apiVersion: v1
kind: Service
metadata:
  name: video-files
spec:
  ports:
    - { port: 8003, targetPort: 8003, name: files }
    - { port: 8004, targetPort: 8004, name: api }
  selector:
    app: video-files
