Add Transmission chart with guarded bcachefs storage
This commit is contained in:
commit
1abc79ff8e
8 files changed
+395
No files matched your search
@@ -0,0 +1,62 @@
|
||||
name: Validate, publish and promote Transmission chart
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Lint and render
|
||||
run: ./scripts/test-chart.sh
|
||||
publish:
|
||||
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
||||
needs: validate
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Derive chart version
|
||||
run: echo "CHART_VERSION=$(./scripts/chart-version.sh)" >> "$GITHUB_ENV"
|
||||
- name: Publish public chart
|
||||
env:
|
||||
PACKAGE_USERNAME: ${{ secrets.PACKAGE_USERNAME }}
|
||||
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -n "$PACKAGE_USERNAME" && test -n "$PACKAGE_TOKEN"
|
||||
helm package chart --destination "$RUNNER_TEMP" --version "$CHART_VERSION"
|
||||
curl --fail --silent --show-error --user "$PACKAGE_USERNAME:$PACKAGE_TOKEN" \
|
||||
--request POST --upload-file "$RUNNER_TEMP/transmission-$CHART_VERSION.tgz" \
|
||||
https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts
|
||||
- name: Confirm current main
|
||||
env:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
git fetch --no-tags origin main
|
||||
test "$(git rev-parse FETCH_HEAD)" = "$COMMIT_SHA"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: feedc0de/homelab-gitops
|
||||
ref: main
|
||||
token: ${{ secrets.GITOPS_TOKEN }}
|
||||
path: homelab-gitops
|
||||
- name: Promote exact chart
|
||||
working-directory: homelab-gitops
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./scripts/update-chart-version.sh transmission "$CHART_VERSION"
|
||||
git config user.name feedc0de
|
||||
git config user.email feedc0de@users.noreply.code.brunner.ninja
|
||||
git add bootstrap/transmission.yaml
|
||||
if git diff --cached --quiet; then exit 0; fi
|
||||
git commit -m "Deploy transmission chart $CHART_VERSION"
|
||||
for attempt in 1 2 3; do
|
||||
git push origin HEAD:main && exit 0
|
||||
test "$attempt" = 3 && exit 1
|
||||
git fetch origin main
|
||||
git rebase origin/main
|
||||
done
|
||||
@@ -0,0 +1,20 @@
|
||||
# Transmission chart
|
||||
|
||||
`chart/Chart.yaml.appVersion` is the only application version field. Tag a
|
||||
release `v<appVersion>`, then push `main` and its tag. CI validates, publishes
|
||||
the chart to `https://brunner.ninja/charts`, and promotes its exact chart
|
||||
version in `homelab-gitops`. For a chart-only commit, the chart version gains
|
||||
the commit count and hash. The image is the public LinuxServer Transmission
|
||||
image selected by the chart's `appVersion`.
|
||||
|
||||
The chart creates a config PVC, a single Deployment, web and peer Services,
|
||||
an optional Traefik Ingress, and optional Prometheus exporter/monitor/rules.
|
||||
It requires a host path whose filesystem is bcachefs and refuses startup
|
||||
without the configured download directory. The first start seeds
|
||||
`settings.json` with that path. It runs with `uid`/`gid` matching the host
|
||||
owner. The peer Service is a LoadBalancer and accepts optional MikroTik
|
||||
forwarding annotations.
|
||||
|
||||
For a manual install, run `./install.sh -f values.yaml`. The production values
|
||||
and Argo Application live in `homelab-gitops/apps/transmission` and
|
||||
`homelab-gitops/bootstrap/transmission.yaml`.
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: transmission
|
||||
description: Transmission with guarded local storage, peer service, and metrics
|
||||
type: application
|
||||
version: 0.0.0
|
||||
appVersion: "4.1.4"
|
||||
@@ -0,0 +1,256 @@
|
||||
{{- if not .Values.config.existingClaim }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: transmission-config
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
storageClassName: {{ .Values.config.storageClass | quote }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.config.size }}
|
||||
---
|
||||
{{- end }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: transmission-tools
|
||||
data:
|
||||
prepare.sh: |
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
test "$(stat -f -c '%t' {{ .Values.media.mountPath }})" = ca451a4e
|
||||
test -d {{ .Values.media.downloadDir }}
|
||||
test -w {{ .Values.media.downloadDir }}
|
||||
if [ ! -e /config/settings.json ]; then
|
||||
printf '{"download-dir":"{{ .Values.media.downloadDir }}","rpc-whitelist-enabled":false,"rpc-host-whitelist-enabled":false}\n' > /config/settings.json
|
||||
fi
|
||||
check.sh: |
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
test "$(stat -f -c '%t' {{ .Values.media.mountPath }})" = ca451a4e
|
||||
test -w {{ .Values.media.downloadDir }}
|
||||
curl --fail --silent --output /dev/null http://127.0.0.1:9091/transmission/web/
|
||||
{{- if .Values.monitoring.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: transmission-exporter-config
|
||||
data:
|
||||
config.yaml: |
|
||||
transmission:
|
||||
url: http://127.0.0.1:9091/transmission/rpc
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: transmission
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: transmission
|
||||
app.kubernetes.io/component: server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: transmission
|
||||
app.kubernetes.io/component: server
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
nodeSelector:
|
||||
{{- toYaml .Values.nodeSelector | nindent 8 }}
|
||||
tolerations:
|
||||
{{- toYaml .Values.tolerations | nindent 8 }}
|
||||
terminationGracePeriodSeconds: 120
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
fsGroup: {{ .Values.gid }}
|
||||
initContainers:
|
||||
- name: media-ready
|
||||
image: docker.io/library/alpine:3.24.2
|
||||
command: [/tools/prepare.sh]
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
runAsNonRoot: true
|
||||
runAsUser: {{ .Values.uid }}
|
||||
runAsGroup: {{ .Values.gid }}
|
||||
volumeMounts:
|
||||
- name: media
|
||||
mountPath: {{ .Values.media.mountPath }}
|
||||
- name: config
|
||||
mountPath: /config
|
||||
- name: tools
|
||||
mountPath: /tools
|
||||
readOnly: true
|
||||
containers:
|
||||
- name: transmission
|
||||
image: {{ .Values.image.repository }}:{{ .Chart.AppVersion }}
|
||||
env:
|
||||
- {name: PUID, value: {{ .Values.uid | quote }}}
|
||||
- {name: PGID, value: {{ .Values.gid | quote }}}
|
||||
- {name: TZ, value: {{ .Values.timezone | quote }}}
|
||||
- {name: PEERPORT, value: "51413"}
|
||||
ports:
|
||||
- {name: http, containerPort: 9091, protocol: TCP}
|
||||
- {name: peer-tcp, containerPort: 51413, protocol: TCP}
|
||||
- {name: peer-udp, containerPort: 51413, protocol: UDP}
|
||||
startupProbe:
|
||||
exec:
|
||||
command: [/tools/check.sh]
|
||||
periodSeconds: 5
|
||||
failureThreshold: 60
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: [/tools/check.sh]
|
||||
periodSeconds: 10
|
||||
failureThreshold: 3
|
||||
livenessProbe:
|
||||
exec:
|
||||
command: [/tools/check.sh]
|
||||
periodSeconds: 30
|
||||
failureThreshold: 3
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
volumeMounts:
|
||||
- {name: config, mountPath: /config}
|
||||
- {name: media, mountPath: {{ .Values.media.mountPath }}}
|
||||
- {name: tools, mountPath: /tools, readOnly: true}
|
||||
{{- if .Values.monitoring.enabled }}
|
||||
- name: exporter
|
||||
image: {{ .Values.monitoring.exporterImage }}
|
||||
args: [--config, /etc/mediamon/config.yaml]
|
||||
ports:
|
||||
- {name: metrics, containerPort: 8080, protocol: TCP}
|
||||
startupProbe:
|
||||
httpGet: {path: /metrics, port: metrics}
|
||||
periodSeconds: 5
|
||||
failureThreshold: 60
|
||||
readinessProbe:
|
||||
httpGet: {path: /metrics, port: metrics}
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
httpGet: {path: /metrics, port: metrics}
|
||||
periodSeconds: 30
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities: {drop: [ALL]}
|
||||
runAsNonRoot: true
|
||||
volumeMounts:
|
||||
- {name: exporter-config, mountPath: /etc/mediamon, readOnly: true}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: config
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ default "transmission-config" .Values.config.existingClaim }}
|
||||
- name: media
|
||||
hostPath:
|
||||
path: {{ .Values.media.hostPath }}
|
||||
type: Directory
|
||||
- name: tools
|
||||
configMap:
|
||||
name: transmission-tools
|
||||
defaultMode: 0555
|
||||
{{- if .Values.monitoring.enabled }}
|
||||
- name: exporter-config
|
||||
configMap:
|
||||
name: transmission-exporter-config
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: transmission
|
||||
labels:
|
||||
app.kubernetes.io/name: transmission
|
||||
app.kubernetes.io/component: service
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/name: transmission
|
||||
app.kubernetes.io/component: server
|
||||
ports:
|
||||
- {name: http, port: 9091, targetPort: http, protocol: TCP}
|
||||
{{- if .Values.monitoring.enabled }}
|
||||
- {name: metrics, port: 8080, targetPort: metrics, protocol: TCP}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: transmission-peers
|
||||
annotations:
|
||||
{{- toYaml .Values.peerService.annotations | nindent 4 }}
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app.kubernetes.io/name: transmission
|
||||
app.kubernetes.io/component: server
|
||||
ports:
|
||||
- {name: peer-tcp, port: 51413, targetPort: peer-tcp, protocol: TCP}
|
||||
- {name: peer-udp, port: 51413, targetPort: peer-udp, protocol: UDP}
|
||||
{{- if .Values.ingress.enabled }}
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: transmission
|
||||
annotations:
|
||||
{{- toYaml .Values.ingress.annotations | nindent 4 }}
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: {{ required "ingress.host required" .Values.ingress.host }}
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: transmission
|
||||
port:
|
||||
name: http
|
||||
{{- end }}
|
||||
{{- if .Values.monitoring.enabled }}
|
||||
---
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: transmission
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: transmission
|
||||
app.kubernetes.io/component: service
|
||||
endpoints:
|
||||
- port: metrics
|
||||
path: /metrics
|
||||
interval: 30s
|
||||
---
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: transmission
|
||||
spec:
|
||||
groups:
|
||||
- name: transmission
|
||||
rules:
|
||||
- alert: TransmissionMetricsTargetDown
|
||||
expr: max(kube_deployment_status_replicas_available{namespace="{{ .Release.Namespace }}",deployment="transmission"}) >= 1 and on() (max(up{namespace="{{ .Release.Namespace }}",service="transmission"}) < 1 or absent(up{namespace="{{ .Release.Namespace }}",service="transmission"}))
|
||||
for: 10m
|
||||
labels: {severity: warning}
|
||||
annotations: {summary: Transmission metrics target is down}
|
||||
- alert: TransmissionContainerRestarting
|
||||
expr: sum by (container) (increase(kube_pod_container_status_restarts_total{namespace="{{ .Release.Namespace }}",pod=~"transmission-.*"}[15m])) > 2
|
||||
for: 5m
|
||||
labels: {severity: warning}
|
||||
annotations: {summary: Transmission container is repeatedly restarting}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,25 @@
|
||||
image:
|
||||
repository: lscr.io/linuxserver/transmission
|
||||
media:
|
||||
hostPath: /data
|
||||
mountPath: /data
|
||||
downloadDir: /data/Downloads
|
||||
nodeSelector: {}
|
||||
tolerations: []
|
||||
config:
|
||||
existingClaim: ""
|
||||
storageClass: ""
|
||||
size: 1Gi
|
||||
timezone: UTC
|
||||
uid: "1000"
|
||||
gid: "1000"
|
||||
resources: {}
|
||||
ingress:
|
||||
enabled: false
|
||||
host: ""
|
||||
annotations: {}
|
||||
peerService:
|
||||
annotations: {}
|
||||
monitoring:
|
||||
enabled: false
|
||||
exporterImage: ghcr.io/clambin/mediamon:v2.16.0
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
version=$(./scripts/chart-version.sh)
|
||||
package_dir=$(mktemp -d)
|
||||
trap 'rm -rf -- "$package_dir"' EXIT
|
||||
helm package chart --version "$version" --destination "$package_dir" >/dev/null
|
||||
helm upgrade --install "${RELEASE_NAME:-transmission}" "$package_dir/transmission-$version.tgz" \
|
||||
--namespace "${NAMESPACE:-transmission}" --create-namespace --wait --timeout 20m "$@"
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
description=$(git describe --tags --long --match 'v[0-9]*' --dirty)
|
||||
case "$description" in *-dirty) echo 'Refusing dirty tree' >&2; exit 1 ;; esac
|
||||
version=${description#v}
|
||||
case "$version" in *-0-g*) version=${version%%-0-g*} ;; esac
|
||||
printf '%s\n' "$version"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
helm lint chart
|
||||
helm template transmission chart --namespace transmission > /dev/null
|
||||
helm template transmission chart --namespace transmission \
|
||||
--set media.hostPath=/komposthaufen \
|
||||
--set media.mountPath=/komposthaufen \
|
||||
--set media.downloadDir=/komposthaufen/Downloads \
|
||||
--set ingress.enabled=true \
|
||||
--set ingress.host=transmission.example.org \
|
||||
--set monitoring.enabled=true > /dev/null
|
||||
Reference in new issue
Block a user