apiVersion: apps/v1
kind: Deployment
metadata:
  name: qbittorrentvpn
  namespace: stack-arr
spec:
  replicas: 1
  selector:
    matchLabels:
      app: qbittorrentvpn
  template:
    metadata:
      labels:
        app: qbittorrentvpn
    spec:
      imagePullSecrets:
      - name: regcred
      containers:
      - name: qbittorrentvpn
        image: j4ym0/pia-qbittorrent:5.1.2-ubuntu
        securityContext:
          capabilities:
            add:
              - NET_ADMIN
        ports:
          - containerPort: 8080
            name: webui
          - containerPort: 51413
            name: torrent-tcp
          - containerPort: 51413
            name: torrent-udp
            protocol: UDP
        env:
        - name: USER
          valueFrom:
            secretKeyRef:
              name: vpn-secret
              key: username
        - name: PASSWORD
          valueFrom:
            secretKeyRef:
              name: vpn-secret
              key: password
        - name: REGION
          value: "Netherlands"  # ou outro servidor PIA
        - name: WEBUI_PORT
          value: "8080"
        - name: DNS_SERVERS
          value: "1.1.1.1,1.0.0.1"
        - name: UID
          value: "1013"
        - name: GID
          value: "1013"
        - name: PORT_FORWARDING
          value: 'true'
        - name: HOSTHEADERVALIDATION
          value: 'false'
        volumeMounts:
        - name: config
          mountPath: /config
        - name: downloads
          mountPath: /downloads
      volumes:
      - name: config
        persistentVolumeClaim:
          claimName: qbittorrent-config-pvc
      - name: downloads
        persistentVolumeClaim:
          claimName: qbittorrent-downloads-pvc
