diff --git a/transmission/.helmignore b/transmission/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/transmission/.helmignore @@ -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/ diff --git a/transmission/Chart.yaml b/transmission/Chart.yaml new file mode 100644 index 0000000..861faf0 --- /dev/null +++ b/transmission/Chart.yaml @@ -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" diff --git a/transmission/deployment.yaml b/transmission/deployment.yaml deleted file mode 100644 index 903ece7..0000000 --- a/transmission/deployment.yaml +++ /dev/null @@ -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: - 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 \ No newline at end of file diff --git a/transmission/kustomization.yaml b/transmission/kustomization.yaml deleted file mode 100644 index 1dd27dc..0000000 --- a/transmission/kustomization.yaml +++ /dev/null @@ -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: - newName: linuxserver/transmission - newTag: 4.0.5 \ No newline at end of file diff --git a/transmission/namespace.yaml b/transmission/namespace.yaml deleted file mode 100644 index d8a215a..0000000 --- a/transmission/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: transmission \ No newline at end of file diff --git a/transmission/services.yaml b/transmission/services.yaml deleted file mode 100644 index e414e4c..0000000 --- a/transmission/services.yaml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/transmission/templates/NOTES.txt b/transmission/templates/NOTES.txt new file mode 100644 index 0000000..ab12db1 --- /dev/null +++ b/transmission/templates/NOTES.txt @@ -0,0 +1,2 @@ +transmission user/password: {{ .Values.transmission.username }}/{{ include "transmission.transmission.password" $ }} +webdav user/password: {{ .Values.webdav.username }}/{{ include "transmission.webdav.password" $ }} \ No newline at end of file diff --git a/transmission/templates/_helpers.tpl b/transmission/templates/_helpers.tpl new file mode 100644 index 0000000..19de82f --- /dev/null +++ b/transmission/templates/_helpers.tpl @@ -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 -}} diff --git a/transmission/templates/configmap-transmission.yaml b/transmission/templates/configmap-transmission.yaml new file mode 100644 index 0000000..8154917 --- /dev/null +++ b/transmission/templates/configmap-transmission.yaml @@ -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 }} \ No newline at end of file diff --git a/transmission/templates/configmap-webdav.yaml b/transmission/templates/configmap-webdav.yaml new file mode 100644 index 0000000..a87bdac --- /dev/null +++ b/transmission/templates/configmap-webdav.yaml @@ -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 }} \ No newline at end of file diff --git a/transmission/templates/deployment-transmission.yaml b/transmission/templates/deployment-transmission.yaml new file mode 100644 index 0000000..406eebd --- /dev/null +++ b/transmission/templates/deployment-transmission.yaml @@ -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 diff --git a/transmission/templates/deployment-webdav.yaml b/transmission/templates/deployment-webdav.yaml new file mode 100644 index 0000000..0d87067 --- /dev/null +++ b/transmission/templates/deployment-webdav.yaml @@ -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 \ No newline at end of file diff --git a/transmission/templates/namespace.yaml b/transmission/templates/namespace.yaml new file mode 100644 index 0000000..3cd3eb7 --- /dev/null +++ b/transmission/templates/namespace.yaml @@ -0,0 +1,7 @@ +kind: Namespace +apiVersion: v1 +metadata: + name: {{ .Values.namespace }} + labels: + app: {{ .Values.namespace }} + {{- include "transmission.labels" . | nindent 4 }} \ No newline at end of file diff --git a/transmission/templates/secret-transmission.yaml b/transmission/templates/secret-transmission.yaml new file mode 100644 index 0000000..5bc0c08 --- /dev/null +++ b/transmission/templates/secret-transmission.yaml @@ -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 }} \ No newline at end of file diff --git a/transmission/templates/secret-webdav.yaml b/transmission/templates/secret-webdav.yaml new file mode 100644 index 0000000..c021b8c --- /dev/null +++ b/transmission/templates/secret-webdav.yaml @@ -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 }} \ No newline at end of file diff --git a/transmission/templates/service-transmission.yaml b/transmission/templates/service-transmission.yaml new file mode 100644 index 0000000..e216186 --- /dev/null +++ b/transmission/templates/service-transmission.yaml @@ -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 \ No newline at end of file diff --git a/transmission/templates/service-webdav.yaml b/transmission/templates/service-webdav.yaml new file mode 100644 index 0000000..e499d8d --- /dev/null +++ b/transmission/templates/service-webdav.yaml @@ -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 \ No newline at end of file diff --git a/transmission/values.schema.json b/transmission/values.schema.json new file mode 100644 index 0000000..0efab1d --- /dev/null +++ b/transmission/values.schema.json @@ -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" + } + } + } + } +} diff --git a/transmission/values.yaml b/transmission/values.yaml new file mode 100644 index 0000000..5bb9e4f --- /dev/null +++ b/transmission/values.yaml @@ -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 \ No newline at end of file