transmission use helm chart

This commit is contained in:
Sense T 2025-01-13 20:38:04 +08:00
parent 2652ec12fd
commit 51d4d965af
19 changed files with 508 additions and 155 deletions

23
transmission/.helmignore Normal file
View File

@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

24
transmission/Chart.yaml Normal file
View File

@ -0,0 +1,24 @@
apiVersion: v2
name: transmission
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

View File

@ -1,85 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: transmission
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: transmission
template:
metadata:
labels:
app: transmission
spec:
volumes:
- name: config
hostPath:
path: /data/transmission/config
- name: downloads
hostPath:
path: /data/transmission/downloads
- name: watch
hostPath:
path: /data/transmission/watch
containers:
- name: transmission
image: <Image>
envFrom:
- configMapRef:
name: transmission
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 9091
name: web
- containerPort: 51413
name: s
- containerPort: 51413
protocol: UDP
name: s-u
volumeMounts:
- mountPath: /config
name: config
- mountPath: /downloads
name: downloads
- mountPath: /watch
name: watch
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: webdav
spec:
selector:
matchLabels:
app: webdav
template:
metadata:
labels:
app: webdav
spec:
volumes:
- name: file
hostPath:
path: /data/transmission/downloads
containers:
- name: webdav
image: dockerproxy.com/bytemark/webdav
resources:
limits:
memory: "128Mi"
cpu: "100m"
ports:
- containerPort: 80
envFrom:
- configMapRef:
name: webdav
- secretRef:
name: webdav
volumeMounts:
- name: file
mountPath: /var/lib/dav/data

View File

@ -1,29 +0,0 @@
# yaml-language-server: $schema=https://json.schemastore.org/kustomization.json
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- deployment.yaml
- services.yaml
namespace: transmission
configMapGenerator:
- name: transmission
files:
- config/PASS
- config/TZ
- config/USER
- config/PGID
- config/PUID
- name: webdav
files:
- config/AUTH_TYPE
- config/USERNAME
secretGenerator:
- name: webdav
files:
- config/PASSWORD
images:
- name: <Image>
newName: linuxserver/transmission
newTag: 4.0.5

View File

@ -1,4 +0,0 @@
apiVersion: v1
kind: Namespace
metadata:
name: transmission

View File

@ -1,37 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: transmission
spec:
type: LoadBalancer
ipFamilyPolicy: PreferDualStack
ipFamilies:
- IPv4
- IPv6
selector:
app: transmission
ports:
- port: 9091
targetPort: web
protocol: TCP
name: web
- port: 51413
targetPort: s
protocol: TCP
name: torrent
---
apiVersion: v1
kind: Service
metadata:
name: webdav
spec:
selector:
app: webdav
ports:
- port: 9092
targetPort: 80
type: LoadBalancer
ipFamilyPolicy: PreferDualStack
ipFamilies:
- IPv4
- IPv6

View File

@ -0,0 +1,2 @@
transmission user/password: {{ .Values.transmission.username }}/{{ include "transmission.transmission.password" $ }}
webdav user/password: {{ .Values.webdav.username }}/{{ include "transmission.webdav.password" $ }}

View File

@ -0,0 +1,67 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "transmission.name" -}}
{{- .Values.nameOverride | default .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
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 "transmission.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 }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "transmission.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "transmission.labels" -}}
helm.sh/chart: {{ include "transmission.chart" . }}
{{ include "transmission.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "transmission.selectorLabels" -}}
app.kubernetes.io/name: {{ include "transmission.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "transmission.transmission.password" -}}
{{- if .Values.transmission.password -}}
{{ .Values.transmission.password }}
{{- else -}}
{{ randAlphaNum 10 }}
{{- end -}}
{{- end -}}
{{- define "transmission.webdav.password" -}}
{{- if .Values.webdav.password -}}
{{ .Values.webdav.password }}
{{- else -}}
{{ randAlphaNum 10 }}
{{- end -}}
{{- end -}}

View File

@ -0,0 +1,13 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: transmission
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
data:
TZ: {{ .Values.timezone |default "Asia/Shanghai" | quote }}
USER: {{ .Values.transmission.username | quote }}
PGID: {{ .Values.transmission.PGID | default "1000" | quote }}
PUID: {{ .Values.transmission.PUID | default "1000" | quote }}

View File

@ -0,0 +1,11 @@
kind: Configmap
apiVersion: v1
metadata:
name: webdav
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
data:
AUTH_TYPE: {{ .Values.webdav.AUTH_TYPE | default "Digest" | quote }}
USERNAME: {{ .Values.webdav.USERNAME | quote }}

View File

@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: transmission
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: transmission
template:
metadata:
labels:
app: transmission
spec:
volumes:
- name: config
hostPath:
path: {{ .Values.directory.config }}
- name: downloads
hostPath:
path: {{ .Values.directory.downloads }}
- name: watch
hostPath:
path: {{ .Values.directory.watch }}
containers:
- name: transmission
image: {{ printf "%s:%s" .Values.images.transmission.repository .Values.images.transmission.tag | quote }}
pullPolicy: {{ .Values.images.transmission.pullPolicy }}
envFrom:
- configMapRef:
name: transmission
- secretRef:
name: transmission
resources:
{{- toYaml .Values.resources.transmission | nindent 10 }}
ports:
- containerPort: {{ .Values.ports.transmission.web }}
name: web
- containerPort: {{ .Values.ports.transmission.torrent }}
name: torrent-tcp
- containerPort: {{ .Values.ports.transmission.torrent }}
protocol: UDP
name: torrent-udp
volumeMounts:
- mountPath: /config
name: config
- mountPath: /downloads
name: downloads
- mountPath: /watch
name: watch

View File

@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: webdav
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: webdav
template:
metadata:
labels:
app: webdav
spec:
volumes:
- name: file
hostPath:
path: {{ .Values.directory.downloads }}
containers:
- name: webdav
image: {{ printf "%s:%s" .Values.images.webdav.repository .Values.images.webdav.tag | quote }}
pullPolicy: {{ .Values.images.webdav.pullPolicy }}
resources:
{{- toYaml .Values.resources.transmission | nindent 10 }}
ports:
- containerPort: {{ .Values.ports.webdav.web }}
name: web
envFrom:
- configMapRef:
name: webdav
- secretRef:
name: webdav
volumeMounts:
- name: file
mountPath: /var/lib/dav/data

View File

@ -0,0 +1,7 @@
kind: Namespace
apiVersion: v1
metadata:
name: {{ .Values.namespace }}
labels:
app: {{ .Values.namespace }}
{{- include "transmission.labels" . | nindent 4 }}

View File

@ -0,0 +1,11 @@
kind: Secret
apiVersion: v1
metadata:
name: transmission
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
type: Opaque
data:
PASS: {{ include "transmission.transmission.password" $ | b64enc | quote }}

View File

@ -0,0 +1,11 @@
kind: Secret
apiVersion: v1
metadata:
name: webdav
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
type: Opaque
data:
PASSWORD: {{ include "transmission.webdav.password" $ | b64enc | quote }}

View File

@ -0,0 +1,47 @@
kind: Service
apiVersion: v1
metadata:
name: transmission-tcp
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
spec:
type: LoadBalancer
ipFamilyPolicy: PreferDualStack
ipFamilies:
- IPv4
- IPv6
selector:
app: transmission
ports:
- port: {{ .Values.ports.transmission.web }}
targetPort: web
protocol: TCP
name: web
- port: {{ .Values.ports.transmission.torrent }}
targetPort: torrent-tcp
protocol: TCP
name: torrent
---
kind: Service
apiVersion: v1
metadata:
name: transmission-udp
namespace: {{ .Values.namespace }}
labels:
app: {{ .Chart.Name }}
{{- include "transmission.labels" . | nindent 4 }}
spec:
type: LoadBalancer
ipFamilyPolicy: PreferDualStack
ipFamilies:
- IPv4
- IPv6
selector:
app: transmission
ports:
- port: {{ .Values.ports.transmission.torrent }}
targetPort: torrent-udp
protocol: UDP
name: torrent

View File

@ -0,0 +1,19 @@
kind: Service
apiVersion: v1
metadata:
name: webdav
namespace: {{ .Values.namespace }}
labels:
app: webdav
{{- include "transmission.labels" . | nindent 4 }}
spec:
selector:
app: webdav
ports:
- port: 9092
targetPort: web
type: LoadBalancer
ipFamilyPolicy: PreferDualStack
ipFamilies:
- IPv4
- IPv6

View File

@ -0,0 +1,135 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"directory": {
"type": "object",
"properties": {
"config": {
"type": "string"
},
"downloads": {
"type": "string"
},
"watch": {
"type": "string"
}
}
},
"fullnameOverride": {
"type": "string"
},
"images": {
"type": "object",
"properties": {
"transmission": {
"type": "object",
"properties": {
"pullPolicy": {
"type": "string"
},
"repository": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"webdav": {
"type": "object",
"properties": {
"pullPolicy": {
"type": "string"
},
"repository": {
"type": "string"
},
"tag": {
"type": "string"
}
}
}
}
},
"nameOverride": {
"type": "string"
},
"namespace": {
"type": "string"
},
"ports": {
"type": "object",
"properties": {
"transmission": {
"type": "object",
"properties": {
"torrent": {
"type": "integer"
},
"web": {
"type": "integer"
}
}
},
"webdav": {
"type": "object",
"properties": {
"web": {
"type": "integer"
}
}
}
}
},
"resources": {
"type": "object",
"properties": {
"transmission": {
"type": "object",
"properties": {
"limits": {
"type": "object",
"properties": {
"cpu": {
"type": "string"
},
"memory": {
"type": "string"
}
}
}
}
}
}
},
"timezone": {
"type": "string"
},
"transmission": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"webdav": {
"type": "object",
"properties": {
"authType": {
"type": "string"
},
"password": {
"type": "string"
},
"username": {
"type": "string"
}
}
}
}
}

45
transmission/values.yaml Normal file
View File

@ -0,0 +1,45 @@
# yaml-language-server: $schema=./values.schema.json
transmission:
username: rouji
password: ""
webdav:
username: secret
password: ""
authType: Digest
images:
transmission:
repository: linuxserver/transmission
tag: latest
pullPolicy: IfNotPresent
webdav:
repository: bytemark/webdav
tag: latest
pullPolicy: IfNotPresent
directory:
downloads: /data/transmission/downloads
config: /data/transmission/config
watch: /data/transmission/watch
ports:
transmission:
web: 9091
torrent: 51413
webdav:
web: 80
resources:
transmission:
limits:
memory: 128Mi
cpu: 500m
namespace: "transmission"
nameOverride: ""
fullnameOverride: ""
timezone: Asia/Shanghai