apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: htpc
    run: bazarr
  name: bazarr
  namespace: media
spec:
  replicas: 1
  selector:
    matchLabels:
      app: htpc
      run: bazarr
  template:
    metadata:
      labels:
        app: htpc
        run: bazarr
    spec:
      containers:
      - env:
        - name: TZ
          value: Africa/Johannesburg
        - name: PUID
          value: "1000"
        - name: PGID
          value: "1000"
        image: linuxserver/bazarr:latest
        name: bazarr
        ports:
        - containerPort: 6767
          name: webui
        volumeMounts:
        - mountPath: /config
          name: nfs
          subPath: bazarr
        - mountPath: /movies
          name: nfs
          subPath: media/movies
        - mountPath: /tv
          name: nfs
          subPath: media/tv
      initContainers:
      - command:
        - sh
        - -c
        - until wget -qO- sonarr:8989/sonarr &> /dev/null && wget -qO- radarr:7878/radarr
          &> /dev/null; do echo waiting for sonarr and radarr; sleep 2; done;
        image: busybox
        name: wait-for-sonarr-and-radarr
      - command:
        - sh
        - -c
        - "echo 'Sonarr and Radarr are UP'"
        image: busybox
        name: config
        volumeMounts:
        - mountPath: /htpc
          name: nfs
      securityContext:
        fsGroup: 1000
      volumes:
      - persistentVolumeClaim:
          claimName: nfs
        name: nfs
