First of all I’d like to thank James Munelly (https://github.com/munnerz) for for the awesome helm charts (cert-manager is awesome) and the functionality of distributing the transcoding as pod jobs! Below are the instructions to mount a persistent volume to your K8S / Plex deployment assuming you are using Linux and your node.
- Mount the CIFS Share
Install SMBClient and test by listing the content of the share on the node(s)
#Install
sudo apt install smbclient
#Test
smbclient -L //NAS-Address.local/
2. Install the CIFS utilities on the node(s)
sudo apt-get install cifs-utils
3. Create a new directory and mount it the share to your local node, this will mount the volume once for testing. To mount it at startup use the instructions in step #3 of this link.
mkdir /mnt/tutorials
sudo mount -t cifs -o 'username=workgroupadmin' //NAS-Address.local/video /mnt/tutorials
4. Now that we the mount and we can see the content we can create the yaml file for the persistent volume. Save as: pv-vol.yaml
VIM:apiVersion: v1
kind: PersistentVolume
metadata:
name: tutorials
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 100Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/tutorials"
5. Then apply it as a resource:
microk8s.kubectl apply -f pv-vol.yaml
6. Now we can create the yaml file for the persistent volume share. Save as pv-claim.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: tutorials-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
7. Then apply the PVC as a resource:
microk8s.kubectl apply -f pv-claim.yaml
8. Now that we have the volume and the volume claim we can install the app and pass the claim in the parameter for extraData
helm install plex ./charts/kube-plex \
--namespace plex \
--set claimToken=[insert claim token here] \
--set persistence.data.claimName=tutorials-pv-claim \
--set ingress.enabled=true
One important piece of info is to set review and change the persistent volume policy to avoid data loss when resetting or deleting the claims. You might have to restart the node in order for changes to take effect if you don’t see the data in your pod. Also
Sources:
https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolumeclaim