Skip to content

Commit

Permalink
rework persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
kriegalex committed Aug 1, 2024
1 parent babe79d commit a82774d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 78 deletions.
2 changes: 1 addition & 1 deletion charts/qbittorrent-gluetun/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: "4.6.5" # this is not updated automatically
description: A Helm chart for qBittorrent with Gluetun VPN
name: qbittorrent-gluetun
version: 0.1.1
version: 0.2.0
keywords:
- qbittorrent
- torrrent
Expand Down
47 changes: 17 additions & 30 deletions charts/qbittorrent-gluetun/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{{/*
Create a default fully qualified name.
Expand the name of the chart.
*/}}
{{- define "qbittorrent-gluetun.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" $name .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "qbittorrent-gluetun.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a name, preferring the nameOverride if provided.
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "qbittorrent-gluetun.name" -}}
{{- if .Values.nameOverride -}}
{{- .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "qbittorrent-gluetun.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Expand All @@ -27,18 +29,3 @@ Create a chart name with version.
{{- define "qbittorrent-gluetun.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version }}
{{- end }}

{{/*
Create PVC names for various components.
*/}}
{{- define "qbittorrent-gluetun.gluetunConfigPVC" -}}
{{ include "qbittorrent-gluetun.fullname" . }}-gluetun-config
{{- end }}

{{- define "qbittorrent-gluetun.qbittorrentConfigPVC" -}}
{{ include "qbittorrent-gluetun.fullname" . }}-qbittorrent-config
{{- end }}

{{- define "qbittorrent-gluetun.downloadsPVC" -}}
{{ include "qbittorrent-gluetun.fullname" . }}-downloads
{{- end }}
6 changes: 3 additions & 3 deletions charts/qbittorrent-gluetun/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ spec:
volumes:
- name: gluetun-config
persistentVolumeClaim:
claimName: {{ include "qbittorrent-gluetun.gluetunConfigPVC" . }}
claimName: {{ if .Values.persistence.gluetun.existingClaim }}{{ .Values.persistence.gluetun.existingClaim }}{{- else }}{{ template "qbittorrent-gluetun.fullname" . }}-gluetun{{- end }}
- name: qbittorrent-config
persistentVolumeClaim:
claimName: {{ include "qbittorrent-gluetun.qbittorrentConfigPVC" . }}
claimName: {{ if .Values.persistence.qbittorrent.existingClaim }}{{ .Values.persistence.qbittorrent.existingClaim }}{{- else }}{{ template "qbittorrent-gluetun.fullname" . }}-qbittorrent{{- end }}
- name: downloads
persistentVolumeClaim:
claimName: {{ include "qbittorrent-gluetun.downloadsPVC" . }}
claimName: {{ if .Values.persistence.qbittorrent.data.existingClaim }}{{ .Values.persistence.qbittorrent.data.existingClaim }}{{- else }}{{ template "qbittorrent-gluetun.fullname" . }}-data{{- end }}
16 changes: 9 additions & 7 deletions charts/qbittorrent-gluetun/templates/pv.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{{- if .Values.persistence.qbittorrent.data.nfs }}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Release.Name }}-qbittorrent-pv
name: {{ template "qbittorrent-gluetun.fullname" . }}-data
labels:
app: {{ .Release.Name }}-qbittorrent
app: {{ .Release.Name }}-data
spec:
capacity:
storage: {{ .Values.qbittorrent.downloads.persistentVolume.size }}
storage: {{ .Values.persistence.qbittorrent.data.size }}
accessModes:
- {{ .Values.qbittorrent.downloads.persistentVolume.accessMode }}
- {{ .Values.persistence.qbittorrent.data.accessMode }}
nfs:
server: {{ .Values.qbittorrent.downloads.persistentVolume.nfs.server }}
path: {{ .Values.qbittorrent.downloads.persistentVolume.nfs.path }}
server: {{ .Values.persistence.qbittorrent.data.nfs.server }}
path: {{ .Values.persistence.qbittorrent.data.nfs.path }}
persistentVolumeReclaimPolicy: Retain
storageClassName: {{ .Values.qbittorrent.downloads.persistentVolume.storageClass }}
storageClassName: {{ .Values.persistence.qbittorrent.data.storageClass }}
{{- end }}
43 changes: 30 additions & 13 deletions charts/qbittorrent-gluetun/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,57 @@

{{- if and .Values.persistence.gluetun.enabled (not .Values.persistence.gluetun.existingClaim) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "qbittorrent-gluetun.qbittorrentConfigPVC" . }}
name: {{ template "qbittorrent-gluetun.fullname" . }}-gluetun
spec:
accessModes:
- {{ .Values.qbittorrent.config.persistentVolume.accessMode }}
- {{ .Values.persistence.gluetun.accessMode | quote }}
resources:
requests:
storage: {{ .Values.qbittorrent.config.persistentVolume.size }}
storageClassName: {{ .Values.qbittorrent.config.persistentVolume.storageClass }}
storage: {{ .Values.persistence.gluetun.size }}
storageClassName: {{ .Values.persistence.gluetun.storageClass | quote }}
{{- if .Values.persistence.gluetun.label }}
selector:
matchLabels:
app: {{ .Values.persistence.gluetun.label | quote }}
{{- end }}
{{- end }}
{{- if and .Values.persistence.qbittorrent.enabled (not .Values.persistence.qbittorrent.existingClaim) }}

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "qbittorrent-gluetun.gluetunConfigPVC" . }}
name: {{ template "qbittorrent-gluetun.fullname" . }}-qbittorrent
spec:
accessModes:
- {{ .Values.gluetun.config.persistentVolume.accessMode }}
- {{ .Values.persistence.qbittorrent.accessMode | quote }}
resources:
requests:
storage: {{ .Values.gluetun.config.persistentVolume.size }}
storageClassName: {{ .Values.gluetun.config.persistentVolume.storageClass }}
storage: {{ .Values.persistence.qbittorrent.size }}
storageClassName: {{ .Values.persistence.qbittorrent.storageClass | quote }}
{{- if .Values.persistence.qbittorrent.label }}
selector:
matchLabels:
app: {{ .Values.persistence.qbittorrent.label | quote }}
{{- end }}
{{- end }}
{{- if and .Values.persistence.qbittorrent.data.enabled (not .Values.persistence.qbittorrent.data.existingClaim) }}

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "qbittorrent-gluetun.downloadsPVC" . }}
name: {{ template "qbittorrent-gluetun.fullname" . }}-data
spec:
accessModes:
- {{ .Values.qbittorrent.downloads.persistentVolume.accessMode }}
- {{ .Values.persistence.qbittorrent.data.accessMode | quote }}
resources:
requests:
storage: {{ .Values.qbittorrent.downloads.persistentVolume.size }}
storageClassName: {{ .Values.qbittorrent.downloads.persistentVolume.storageClass }}
storage: {{ .Values.persistence.qbittorrent.data.size }}
storageClassName: {{ .Values.persistence.qbittorrent.data.storageClass | quote }}
selector:
matchLabels:
app: {{ .Release.Name }}-qbittorrent
app: {{ .Release.Name }}-data
{{- end }}
57 changes: 33 additions & 24 deletions charts/qbittorrent-gluetun/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
nameOverride: ""
fullnameOverride: ""

# qBittorrent Configuration
qbittorrent:
image: linuxserver/qbittorrent
Expand All @@ -6,43 +9,49 @@ qbittorrent:
pgid: 1000
webuiPort: 8080
torrentingPort: 47872
config:
persistentVolume:
enabled: true
# existingClaim: ""
storageClass: "nfs-client"
size: "1Gi"
accessMode: "ReadWriteOnce"
downloads:
persistentVolume:
enabled: true
# existingClaim: ""
storageClass: ""
size: "500Gi"
accessMode: "ReadWriteOnce"
nfs:
server: "10.0.0.7"
path: "/torrent"

# Gluetun VPN Configuration
gluetun:
image: qmcgaw/gluetun
tag: latest
controlServerPort: 8000
config:
persistentVolume:
enabled: true
# existingClaim: ""
storageClass: "nfs-client"
size: "1Gi"
accessMode: "ReadWriteOnce"

env:
VPN_SERVICE_PROVIDER: "private internet access"
SERVER_REGIONS: "Switzerland"
VPN_PORT_FORWARDING: true
secret:
name: vpn-credentials

# Persistence
persistence:
qbittorrent:
enabled: true
# existingClaim: ""
# storageClass: ""
label: "qbittorrent" # avoid inverting gluetun and qbittorrent
size: "1Gi"
accessMode: "ReadWriteOnce"

data:
enabled: true
# existingClaim: ""
# storageClass: ""
size: "500Gi"
accessMode: "ReadWriteOnce"
nfs:
server: "10.0.0.7"
path: "/torrent"

gluetun:
enabled: true
# existingClaim: ""
# storageClass: ""
label: "gluetun" # avoid inverting gluetun and qbittorrent
size: "1Gi"
accessMode: "ReadWriteOnce"


# Service Configuration
service:
type: LoadBalancer
Expand Down

0 comments on commit a82774d

Please sign in to comment.