From fc342ca1c175307a5f4733d08fb10108c3f99cb2 Mon Sep 17 00:00:00 2001 From: Alex Manning Date: Mon, 13 Mar 2023 21:45:40 +0000 Subject: [PATCH] Add jellyfin. --- .woodpecker/jellyfin.yaml | 13 ++++ charts/jellyfin/.helmignore | 23 ++++++ charts/jellyfin/Chart.yaml | 6 ++ charts/jellyfin/templates/_helpers.tpl | 62 ++++++++++++++++ charts/jellyfin/templates/deployment.yaml | 87 +++++++++++++++++++++++ charts/jellyfin/templates/ingress.yaml | 61 ++++++++++++++++ charts/jellyfin/templates/service.yaml | 15 ++++ charts/jellyfin/values.yaml | 68 ++++++++++++++++++ 8 files changed, 335 insertions(+) create mode 100644 .woodpecker/jellyfin.yaml create mode 100644 charts/jellyfin/.helmignore create mode 100644 charts/jellyfin/Chart.yaml create mode 100644 charts/jellyfin/templates/_helpers.tpl create mode 100644 charts/jellyfin/templates/deployment.yaml create mode 100644 charts/jellyfin/templates/ingress.yaml create mode 100644 charts/jellyfin/templates/service.yaml create mode 100644 charts/jellyfin/values.yaml diff --git a/.woodpecker/jellyfin.yaml b/.woodpecker/jellyfin.yaml new file mode 100644 index 0000000..ee2a186 --- /dev/null +++ b/.woodpecker/jellyfin.yaml @@ -0,0 +1,13 @@ +--- +when: + path: "charts/jellyfin/**" +branches: + - main +pipeline: + package: + image: "docker.io/alpine/helm:latest" + secrets: [helm_user, helm_password, helm_repo] + commands: + - helm plugin install https://github.com/chartmuseum/helm-push + - helm repo add therepo $HELM_REPO --username $HELM_USER --password $HELM_PASSWORD + - helm cm-push charts/jellyfin therepo diff --git a/charts/jellyfin/.helmignore b/charts/jellyfin/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/jellyfin/.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/charts/jellyfin/Chart.yaml b/charts/jellyfin/Chart.yaml new file mode 100644 index 0000000..c143f77 --- /dev/null +++ b/charts/jellyfin/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: jellyfin +description: A Helm chart for jellyfin. +type: application +version: 0.1.0 +appVersion: "10.8.9" diff --git a/charts/jellyfin/templates/_helpers.tpl b/charts/jellyfin/templates/_helpers.tpl new file mode 100644 index 0000000..47b24d9 --- /dev/null +++ b/charts/jellyfin/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "jellyfin.name" -}} +{{- default .Chart.Name .Values.nameOverride | 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 "jellyfin.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 "jellyfin.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "jellyfin.labels" -}} +helm.sh/chart: {{ include "jellyfin.chart" . }} +{{ include "jellyfin.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "jellyfin.selectorLabels" -}} +app.kubernetes.io/name: {{ include "jellyfin.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "jellyfin.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "jellyfin.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/jellyfin/templates/deployment.yaml b/charts/jellyfin/templates/deployment.yaml new file mode 100644 index 0000000..39fbf0f --- /dev/null +++ b/charts/jellyfin/templates/deployment.yaml @@ -0,0 +1,87 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "jellyfin.fullname" . }} + labels: + {{- include "jellyfin.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "jellyfin.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "jellyfin.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8096 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + volumeMounts: + - name: config + mountPath: /config + - name: media + mountPath: /media + - name: cache + mountPath: /cache + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: config + persistentVolumeClaim: + {{- if not .Values.pvc.config.existingClaim }} + claimName: {{ include "jellyfin.fullname" . }}-config + {{- else }} + claimName: {{ .Values.pvc.config.existingClaim }} + {{- end }} + - name: media + persistentVolumeClaim: + {{- if not .Values.pvc.media.existingClaim }} + claimName: {{ include "jellyfin.fullname" . }}-media + {{- else }} + claimName: {{ .Values.pvc.media.existingClaim }} + {{- end }} + - name: cache + persistentVolumeClaim: + {{- if not .Values.pvc.cache.existingClaim }} + claimName: {{ include "jellyfin.fullname" . }}-cache + {{- else }} + claimName: {{ .Values.pvc.cache.existingClaim }} + {{- end }} diff --git a/charts/jellyfin/templates/ingress.yaml b/charts/jellyfin/templates/ingress.yaml new file mode 100644 index 0000000..d8de4a3 --- /dev/null +++ b/charts/jellyfin/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "jellyfin.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "jellyfin.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/jellyfin/templates/service.yaml b/charts/jellyfin/templates/service.yaml new file mode 100644 index 0000000..3e7b41d --- /dev/null +++ b/charts/jellyfin/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "jellyfin.fullname" . }} + labels: + {{- include "jellyfin.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "jellyfin.selectorLabels" . | nindent 4 }} diff --git a/charts/jellyfin/values.yaml b/charts/jellyfin/values.yaml new file mode 100644 index 0000000..804b954 --- /dev/null +++ b/charts/jellyfin/values.yaml @@ -0,0 +1,68 @@ +image: + repository: docker.io/jellyfin/jellyfin + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +pcv: + config: + existingClaim: "" + storage: + existingClaim: "" + cache: + existingClaim: ""