diff --git a/Kubernetes/SMB/deployment.yaml b/Kubernetes/SMB/deployment.yaml new file mode 100644 index 0000000..0ff46d5 --- /dev/null +++ b/Kubernetes/SMB/deployment.yaml @@ -0,0 +1,75 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: jellyfin + app.kubernetes.io/instance: jellyfin + app.kubernetes.io/name: jellyfin + name: jellyfin + namespace: jellyfin +spec: + replicas: 1 + selector: + matchLabels: + app: jellyfin + template: + metadata: + labels: + app: jellyfin + app.kubernetes.io/name: jellyfin + spec: + nodeSelector: + worker: "true" + containers: + - image: jellyfin/jellyfin + imagePullPolicy: Always + name: jellyfin + ports: + - containerPort: 8096 + name: web + protocol: TCP + env: + - name: TZ + value: Europe/London + volumeMounts: + - mountPath: "/Audiobooks" + readOnly: false + name: smb + subPath: Audiobooks + - mountPath: "/Films" + readOnly: false + name: smb + subPath: Films + - mountPath: "/TVShows" + readOnly: false + name: smb + subPath: TVShows + - mountPath: "/Music" + readOnly: false + name: smb + subPath: Music + volumes: + - name: smb + persistentVolumeClaim: + claimName: pvc-jellyfin-smb +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: jellyfin + name: jellyfin + namespace: jellyfin +spec: + ports: + - name: web-tcp + port: 8096 + protocol: TCP + targetPort: 8096 + - name: web-udp + port: 8096 + protocol: UDP + targetPort: 8096 + selector: + app: jellyfin \ No newline at end of file diff --git a/Kubernetes/SMB/pv-smb.yaml b/Kubernetes/SMB/pv-smb.yaml new file mode 100644 index 0000000..d7db3f1 --- /dev/null +++ b/Kubernetes/SMB/pv-smb.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + annotations: + pv.kubernetes.io/provisioned-by: smb.csi.k8s.io + name: pv-jellyfin-smb +spec: + capacity: + storage: 100Gi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + storageClassName: smb + mountOptions: + - dir_mode=0777 + - file_mode=0777 + csi: + driver: smb.csi.k8s.io + readOnly: false + # volumeHandle format: {smb-server-address}#{sub-dir-name}#{share-name} + # make sure this value is unique for every share in the cluster + volumeHandle: jellyfin + volumeAttributes: + source: "//192.168.6.2/FreeNAS" # Change this to your SMB IP and share name + nodeStageSecretRef: + name: smbcreds + namespace: default \ No newline at end of file diff --git a/Kubernetes/SMB/pvc-smb.yaml b/Kubernetes/SMB/pvc-smb.yaml new file mode 100644 index 0000000..87402b0 --- /dev/null +++ b/Kubernetes/SMB/pvc-smb.yaml @@ -0,0 +1,14 @@ +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: pvc-jellyfin-smb + namespace: jellyfin +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi + volumeName: pv-jellyfin-smb + storageClassName: smb \ No newline at end of file diff --git a/Kubernetes/SMB/readme.md b/Kubernetes/SMB/readme.md new file mode 100644 index 0000000..ac40f60 --- /dev/null +++ b/Kubernetes/SMB/readme.md @@ -0,0 +1,33 @@ +# Install CSI driver +``` +curl -skSL https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/v1.13.0/deploy/install-driver.sh | bash -s v1.13.0 -- +``` + +# Create SMB creds +``` +kubectl create secret generic smbcreds --from-literal username=USERNAME --from-literal password="PASSWORD" +``` + +# Create storage class +``` +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: smb +provisioner: smb.csi.k8s.io +parameters: + source: //smb-server.default.svc.cluster.local/share + # if csi.storage.k8s.io/provisioner-secret is provided, will create a sub directory + # with PV name under source + csi.storage.k8s.io/provisioner-secret-name: smbcreds + csi.storage.k8s.io/provisioner-secret-namespace: default + csi.storage.k8s.io/node-stage-secret-name: smbcreds + csi.storage.k8s.io/node-stage-secret-namespace: default +reclaimPolicy: Delete # available values: Delete, Retain +volumeBindingMode: Immediate +mountOptions: + - dir_mode=0777 + - file_mode=0777 + - uid=1001 + - gid=1001 +``` \ No newline at end of file