apiVersion: apps/v1
kind: Deployment
metadata:
  name: plex-app
  namespace: plex
  labels:
    app.kubernetes.io/name: plex
    app.kubernetes.io/instance: plex
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: plex
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: plex
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
        - name: plex-app
          image: plexinc/pms-docker:1.25.1.5286-34f965be8
          imagePullPolicy: Always
          ports:
            - containerPort: 32400
              hostPort: 32400
            - containerPort: 32410
              hostPort: 32410
              protocol: UDP
            - containerPort: 32412
              hostPort: 32412
              protocol: UDP
            - containerPort: 32413
              hostPort: 32413
              protocol: UDP
            - containerPort: 32414
              hostPort: 32414
              protocol: UDP
          envFrom:
            - configMapRef:
                name: plex-envs
          volumeMounts:
            - mountPath: /config
              name: config-volume
            - mountPath: /data
              name: videos-volume
            - mountPath: /transcode
              name: transcode-volume
      volumes:
        - name: config-volume
          hostPath:
            # Ensure the file directory is created.
            path: /mnt/ssd/containers/config/plex
            type: DirectoryOrCreate
        - name: transcode-volume
          hostPath:
            # Ensure the file directory is created.
            path: /mnt/ssd/containers/config/plex/transcode
            type: DirectoryOrCreate
        - name: videos-volume
          hostPath:
            # Ensure the file directory is created.
            path: /mnt/data/videos
            type: DirectoryOrCreate
