Skip to content

Commit

Permalink
Create Helm chart
Browse files Browse the repository at this point in the history
Feleuxens committed Dec 8, 2023
1 parent a2c6cab commit da3119b
Showing 12 changed files with 613 additions and 0 deletions.
23 changes: 23 additions & 0 deletions jellyfin/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
24 changes: 24 additions & 0 deletions jellyfin/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: jellyfin
description: A Helm chart for Jellyfin

# 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: "10.8.13"
71 changes: 71 additions & 0 deletions jellyfin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Jellyfin

Jellyfin is the volunteer-built media solution that puts you in control of your media.

## Parameters

### General settings

| Name | Description | Value |
| ---------------------------------- | ------------------------------------ | ------------------- |
| `replicaCount` | Replica count | `1` |
| `image.repository` | The Docker image to use | `jellyfin/jellyfin` |
| `image.pullPolicy` | Pull policy | `IfNotPresent` |
| `image.tag` | Image tag. Defaults to Chart version | `""` |
| `imagePullSecrets` | | `[]` |
| `nameOverride` | | `""` |
| `fullnameOverride` | | `""` |
| `resources` | Set resources | `{}` |
| `nodeSelector` | | `{}` |
| `tolerations` | | `[]` |
| `affinity` | | `{}` |
| `podAnnotations` | | `{}` |
| `podSecurityContext` | | `{}` |
| `securityContext` | | `{}` |
| `service.type` | Service type | `ClusterIP` |
| `service.port` | Service port | `8096` |
| `service.annotations` | Additional service annotations | `{}` |
| `service.labels` | Additional service labels | `{}` |
| `service.clusterIP` | Specify explicit cluster IP | `nil` |
| `service.loadBalancerIP` | Specify explicit load balancer IP | `nil` |
| `service.loadBalancerSourceRanges` | Specify load balancer source range | `[]` |
| `service.externalIPs` | Specify external IP | `[]` |
| `service.externalTrafficPolicy` | External traffic policy | `Cluster` |

### Discovery Service

| Name | Description | Value |
| ------------------------------------------- | ------------------------------------------------------------ | ------- |
| `enableDLNA` | Enables DLNA port. Creates a loadbalancer service | `false` |
| `enableLocalDiscovery` | Enables local discovery port. Creates a loadbalancer service | `false` |
| `discoveryService.annotations` | Annotations for the discovery service | `{}` |
| `discoveryService.labels` | Labels for the discovery service | `{}` |
| `discoveryService.loadBalancerIP` | Specify loadbalancer IP | `nil` |
| `discoveryService.loadBalancerSourceRanges` | Specify loadbalancer source range | `[]` |

### Ingress

| Name | Description | Value |
| --------------------- | ---------------------------------------- | ------- |
| `ingress.enabled` | Enable ingress | `false` |
| `ingress.className` | Ingress class name | `nginx` |
| `ingress.annotations` | Ingress annotations | `{}` |
| `ingress.hosts` | Hosts of the ingress record | `[]` |
| `ingress.tls` | List of secrets with the TLS certificate | `[]` |

### Persistence

| Name | Description | Value |
| ---------------------------------- | ------------------------------------------------------------------------------ | ------------------- |
| `persistence.config.enabled` | Enable persistence for the config | `false` |
| `persistence.config.storageClass` | Choose storage class for the PVC. "~" will choose the default storage provider | `~` |
| `persistence.config.existingClaim` | Specify an existing claim | `nil` |
| `persistence.config.accessModes` | Access modes of the PVC | `["ReadWriteOnce"]` |
| `persistence.config.size` | Size of the PVC | `1Gi` |
| `persistence.media.enabled` | Enable persistence for the config | `false` |
| `persistence.media.storageClass` | Choose storage class for the PVC. "~" will choose the default storage provider | `~` |
| `persistence.media.existingClaim` | Specify an existing claim | `nil` |
| `persistence.media.accessModes` | Access modes of the PVC | `["ReadWriteOnce"]` |
| `persistence.media.size` | Size of the PVC | `10Gi` |
| `extraVolumes` | Specify extra volumes | `[]` |
| `extraVolumeMounts` | Specify extra volume mounts | `[]` |
22 changes: 22 additions & 0 deletions jellyfin/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.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.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.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}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions jellyfin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions jellyfin/templates/config-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if and .Values.persistence.config.enabled (not .Values.persistence.config.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "jellyfin.fullname" . }}-config
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
spec:
accessModes: {{ .Values.persistence.config.accessModes }}
resources:
requests:
storage: {{ .Values.persistence.config.size }}
{{- if not (eq .Values.persistence.config.storageClass "~") }}
storageClassName: "{{ .Values.persistence.config.storageClass }}"
{{- end }}
{{- end }}
92 changes: 92 additions & 0 deletions jellyfin/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "jellyfin.fullname" . }}
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
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: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.enableDLNA }}
- name: dlna
containerPort: 1900
{{- end }}
{{- if .Values.enableLocalDiscovery }}
- name: local-discovery
containerPort: 7359
{{- end }}
livenessProbe:
tcpSocket:
port: http
readinessProbe:
tcpSocket:
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- if .Values.persistence.config.enabled }}
- mountPath: /config
name: config
{{- end }}
{{- if .Values.persistence.media.enabled }}
- mountPath: /media
name: media
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
{{- if .Values.persistence.config.enabled }}
- name: config
presistentVolumeClaim:
claimName: {{ if .Values.persistence.config.existingClaim }}{{ .Values.persistence.config.existingClaim }}{{ else }}{{ template "jellyfin.fullname" . }}-config{{ end }}
{{- end }}
{{- if .Values.persistence.media.enabled }}
- name: media
persistentVolumeClaim:
claimName: {{ if .Values.persistence.media.existingClaim }}{{ .Values.persistence.media.existingClaim }}{{ else }}{{ template "jellyfin.fullname" . }}-media{{ end }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
32 changes: 32 additions & 0 deletions jellyfin/templates/discovery-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if or .Values.enableDLNA .Values.enableLocalDiscovery }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "jellyfin.fullname" . }}-local-discovery
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
spec:
type: LoadBalancer
{{- if .Values.discoveryService.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.discoveryService.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports:
{{- if .Values.enableLocalDiscovery }}
- port: 7359
targetPort: local-discovery
name: local-discovery
{{- end }}
{{- if .Values.enableDLNA }}
- port: 1900
targetPort: dlna
name: dlna
{{- end }}
selector:
{{- include "jellyfin.selectorLabels" . | nindent 4 }}
{{- end }}
61 changes: 61 additions & 0 deletions jellyfin/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions jellyfin/templates/media-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if and .Values.persistence.media.enabled (not .Values.persistence.media.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "jellyfin.fullname" . }}-media
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
spec:
accessModes: {{ .Values.persistence.media.accessModes }}
resources:
requests:
storage: {{ .Values.persistence.media.size }}
{{- if not (eq .Values.persistence.media.storageClass "~") }}
storageClassName: "{{ .Values.persistence.media.storageClass }}"
{{- end }}
{{- end }}
37 changes: 37 additions & 0 deletions jellyfin/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "jellyfin.fullname" . }}
labels:
{{- include "jellyfin.labels" . | nindent 4 }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
spec:
type: {{ .Values.service.type | default "ClusterIP" }}
{{- if (and .Values.service.clusterIP (eq .Values.service.type "ClusterIP" )) }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
{{- if (and .Values.service.clusterIP (eq .Values.service.type "loadBalancerIP" )) }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
{{- if and .Values.service.externalIPs (eq .Values.service.type "ExternalName") }}
externalIPs:
{{- toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }}
{{- if and .Values.service.externalTrafficPolicy (eq .Values.service.type "LoadBalancer") }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
{{- if (and (eq .Values.service.type "NodePort") .Values.service.nodePort)}}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
selector:
{{- include "jellyfin.selectorLabels" . | nindent 4 }}
157 changes: 157 additions & 0 deletions jellyfin/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
## @section General settings

## @param replicaCount Replica count
replicaCount: 1

## @param image.repository The Docker image to use
## @param image.pullPolicy Pull policy
## @param image.tag Image tag. Defaults to Chart version
image:
repository: jellyfin/jellyfin
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

## @param imagePullSecrets
## @param nameOverride
## @param fullnameOverride
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

## @param resources Set resources
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

## @param nodeSelector
nodeSelector: {}

## @param tolerations
tolerations: []

## @param affinity
affinity: {}

## @param podAnnotations
podAnnotations: {}

## @param podSecurityContext
podSecurityContext: {}
# fsGroup: 2000

## @param securityContext
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

## @param service.type Service type
## @param service.port Service port
## @param service.annotations Additional service annotations
## @param service.labels Additional service labels
## @param service.clusterIP Specify explicit cluster IP
## @param service.loadBalancerIP Specify explicit load balancer IP
## @param service.loadBalancerSourceRanges Specify load balancer source range
## @param service.externalIPs Specify external IP
## @param service.externalTrafficPolicy External traffic policy
service:
type: ClusterIP
port: 8096
annotations: {}
labels: {}
clusterIP:
loadBalancerIP:
loadBalancerSourceRanges: []
externalIPs: []
externalTrafficPolicy: Cluster

## @section Discovery Service

## @param enableDLNA Enables DLNA port. Creates a loadbalancer service
## @param enableLocalDiscovery Enables local discovery port. Creates a loadbalancer service
enableDLNA: false
enableLocalDiscovery: false

## @param discoveryService.annotations Annotations for the discovery service
## @param discoveryService.labels Labels for the discovery service
## @param discoveryService.loadBalancerIP Specify loadbalancer IP
## @param discoveryService.loadBalancerSourceRanges Specify loadbalancer source range
discoveryService:
annotations: {}
labels: {}
loadBalancerIP:
loadBalancerSourceRanges: []

## @section Ingress

## @param ingress.enabled Enable ingress
## @param ingress.className Ingress class name
## @param ingress.annotations Ingress annotations
## @param ingress.hosts [array] Hosts of the ingress record
## @param ingress.tls [array] List of secrets with the TLS certificate
ingress:
enabled: false
className: "nginx"
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

## @section Persistence

## @param persistence.config.enabled Enable persistence for the config
## @param persistence.config.storageClass Choose storage class for the PVC. "~" will choose the default storage provider
## @param persistence.config.existingClaim Specify an existing claim
## @param persistence.config.accessModes Access modes of the PVC
## @param persistence.config.size Size of the PVC
persistence:
config:
enabled: false
storageClass: "~"
existingClaim:
accessModes:
- ReadWriteOnce
size: 1Gi
## @param persistence.media.enabled Enable persistence for the config
## @param persistence.media.storageClass Choose storage class for the PVC. "~" will choose the default storage provider
## @param persistence.media.existingClaim Specify an existing claim
## @param persistence.media.accessModes Access modes of the PVC
## @param persistence.media.size Size of the PVC
media:
enabled: false
storageClass: "~"
existingClaim:
accessModes:
- ReadWriteOnce
size: 10Gi

## @param extraVolumes Specify extra volumes
extraVolumes: []
#- name: renderD129
# hostPath:
# path: /dev/dri/renderD129

## @param extraVolumeMounts Specify extra volume mounts
extraVolumeMounts: []
#- mountPath: /dev/dri/renderD129
# name: renderD129

0 comments on commit da3119b

Please sign in to comment.