Skip to content

Commit

Permalink
Create Helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Feleuxens committed Dec 8, 2023
1 parent a2c6cab commit da3119b
Show file tree
Hide file tree
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 }}
Loading

0 comments on commit da3119b

Please sign in to comment.