266 lines
8.2 KiB
YAML
266 lines
8.2 KiB
YAML
{{- 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
|
|
timeoutSeconds: 20
|
|
readinessProbe:
|
|
exec:
|
|
command: [/tools/check.sh]
|
|
periodSeconds: 10
|
|
failureThreshold: 3
|
|
timeoutSeconds: 15
|
|
livenessProbe:
|
|
exec:
|
|
command: [/tools/check.sh]
|
|
periodSeconds: 30
|
|
failureThreshold: 10
|
|
timeoutSeconds: 20
|
|
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: 9090, protocol: TCP}
|
|
startupProbe:
|
|
httpGet: {path: /metrics, port: metrics}
|
|
periodSeconds: 5
|
|
failureThreshold: 60
|
|
timeoutSeconds: 20
|
|
readinessProbe:
|
|
httpGet: {path: /metrics, port: metrics}
|
|
periodSeconds: 10
|
|
timeoutSeconds: 15
|
|
livenessProbe:
|
|
httpGet: {path: /metrics, port: metrics}
|
|
periodSeconds: 30
|
|
failureThreshold: 10
|
|
timeoutSeconds: 20
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities: {drop: [ALL]}
|
|
runAsNonRoot: true
|
|
runAsUser: {{ .Values.uid }}
|
|
runAsGroup: {{ .Values.gid }}
|
|
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: 9090, 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 }}
|