Skip to content

Commit

Permalink
Create a chart for jellyfin (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzkilcan authored Oct 14, 2023
1 parent e98fcff commit 6a12793
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 0 deletions.
22 changes: 22 additions & 0 deletions charts/jellyfin/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
13 changes: 13 additions & 0 deletions charts/jellyfin/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
type: application
name: jellyfin
version: 1.0.0
appVersion: 10.8.11
description: Streaming app for movies, TV, music, web shows and podcasts
home: https://jellyfin.org/
icon: https://cdn.icon-icons.com/icons2/3912/PNG/512/jellyfin_logo_icon_247973.png
sources:
- https://github.com/jellyfin/jellyfin
- https://hub.docker.com/r/linuxserver/jellyfin
maintainers:
- name: oguzkilcan
19 changes: 19 additions & 0 deletions charts/jellyfin/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }}
{{- end }}
{{- else if contains "NodePort" .Values.service.main.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "jellyfin.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.main.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "jellyfin.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "jellyfin.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.main.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "jellyfin.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}
94 changes: 94 additions & 0 deletions charts/jellyfin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{{/* vim: set filetype=mustache: */}}
{{/*
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 -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "jellyfin.ingress.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}}
{{- print "networking.k8s.io/v1" -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}
{{/*
Return if ingress is stable.
*/}}
{{- define "jellyfin.ingress.isStable" -}}
{{- eq (include "jellyfin.ingress.apiVersion" .) "networking.k8s.io/v1" -}}
{{- end -}}
{{/*
Return if ingress supports ingressClassName.
*/}}
{{- define "jellyfin.ingress.supportsIngressClassName" -}}
{{- or (eq (include "jellyfin.ingress.isStable" .) "true") (and (eq (include "jellyfin.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}}
{{/*
Return if ingress supports pathType.
*/}}
{{- define "jellyfin.ingress.supportsPathType" -}}
{{- or (eq (include "jellyfin.ingress.isStable" .) "true") (and (eq (include "jellyfin.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}}
12 changes: 12 additions & 0 deletions charts/jellyfin/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.extraEnv }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "jellyfin.fullname" . }}
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
data:
{{- with .Values.extraEnv }}
{{ tpl (toYaml .) $ | indent 2 }}
{{- end }}
{{- end }}
73 changes: 73 additions & 0 deletions charts/jellyfin/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{- if .Values.ingress.enabled -}}
{{- $ingressApiIsStable := eq (include "jellyfin.ingress.isStable" .) "true" -}}
{{- $ingressSupportsIngressClassName := eq (include "jellyfin.ingress.supportsIngressClassName" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "jellyfin.ingress.supportsPathType" .) "true" -}}
{{- $fullName := include "jellyfin.fullname" . -}}
{{- $servicePort := .Values.service.main.port -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $ingressPathType := .Values.ingress.pathType -}}
apiVersion: {{ include "jellyfin.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
{{- if .Values.ingress.labels }}
{{ toYaml .Values.ingress.labels | indent 4 }}
{{- end }}
{{- if .Values.ingress.annotations }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
spec:
{{- if and $ingressSupportsIngressClassName .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ tpl (toYaml .Values.ingress.tls) $ | indent 4 }}
{{- end }}
rules:
{{- if .Values.ingress.hosts }}
{{- range .Values.ingress.hosts }}
- host: {{ tpl . $}}
http:
paths:
- path: {{ $ingressPath }}
{{- if $ingressSupportsPathType }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $ingressApiIsStable }}
service:
name: {{ $fullName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end }}
{{- else }}
- http:
paths:
- backend:
{{- if $ingressApiIsStable }}
service:
name: {{ $fullName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- if $ingressPath }}
path: {{ $ingressPath }}
{{- end }}
{{- if $ingressSupportsPathType }}
pathType: {{ $ingressPathType }}
{{- end }}
{{- end -}}
{{- end }}
25 changes: 25 additions & 0 deletions charts/jellyfin/templates/service-tcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.service.tcp }}
{{- if .Values.service.tcp.ports }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "jellyfin.fullname" . }}-lb-tcp
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
{{- with .Values.service.tcp.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.tcp.type }}
ports:
{{- range .Values.service.tcp.ports }}
- name: jellyfin-{{ .port }}
port: {{ .port }}
targetPort: {{ .containerPort }}
protocol: TCP
{{- end }}
selector:
{{- include "jellyfin.selectorLabels" . | nindent 4 }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/jellyfin/templates/service-udp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.service.udp }}
{{- if .Values.service.udp.ports }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "jellyfin.fullname" . }}-lb-udp
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
{{- with .Values.service.udp.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.udp.type }}
ports:
{{- range .Values.service.udp.ports }}
- name: jellyfin-{{ .port }}
port: {{ .port }}
targetPort: {{ .containerPort }}
protocol: UDP
{{- end }}
selector:
{{- include "jellyfin.selectorLabels" . | nindent 4 }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/jellyfin/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "jellyfin.fullname" . }}
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.main.type }}
ports:
- port: {{ .Values.service.main.port }}
targetPort: 8096
protocol: TCP
name: http
selector:
{{- include "jellyfin.selectorLabels" . | nindent 4 }}
8 changes: 8 additions & 0 deletions charts/jellyfin/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "jellyfin.serviceAccountName" . }}
labels:
{{ include "jellyfin.labels" . | nindent 4 }}
{{- end -}}
Loading

0 comments on commit 6a12793

Please sign in to comment.