-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e380d76
commit a35ed67
Showing
19 changed files
with
885 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
charts/ | ||
|
||
/charts/**/charts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dependencies: | ||
- name: postgresql | ||
repository: oci://registry-1.docker.io/bitnamicharts | ||
version: 16.0.4 | ||
digest: sha256:8112059bbff6d708a187fcfceb87d35b8624aeb8cee0441873f80b3c5f840dd5 | ||
generated: "2024-11-09T11:00:15.684251128-08:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: v2 | ||
name: mega-media | ||
description: A Helm chart for Kubernetes | ||
|
||
# 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: "1.16.0" | ||
|
||
# Chart dependencies | ||
dependencies: | ||
- name: postgresql | ||
version: 16.0.4 | ||
repository: oci://registry-1.docker.io/bitnamicharts | ||
condition: postgresql.enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "mega-media.name" (merge (dict "name" "arr-config") .) }} | ||
labels: | ||
{{- include "mega-media.labels" (merge (dict "name" "arr-config") .) | nindent 4 }} | ||
data: | ||
PUID: "1000" | ||
PGID: "1000" | ||
UMASK: "002" | ||
TZ: "Etc/UTC" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{{- range tuple "sonarr" "radarr" "lidarr" "readarr" "prowlarr" }} | ||
{{- $tableSelect := get $.Values.arrs . -}} | ||
{{- $apiKey := lower (randAlphaNum 32) -}} | ||
|
||
{{ if eq $tableSelect.enabled true }} | ||
{{ template "mega-media.arr.deployment" (merge (dict "selected" $tableSelect "apiKey" $apiKey) $) }} | ||
{{ template "mega-media.api-key-secret" (merge (dict "name" $tableSelect.name "apiKey" $apiKey) $) }} | ||
{{ template "mega-media.service" (merge (dict "name" $tableSelect.name "port" $tableSelect.port "targetPort" "http") $) }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- define "mega-media.api-key-secret" -}} | ||
{{- $nameInTable := merge (dict "name" .name) . -}} | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "mega-media.name" $nameInTable }}-api-key | ||
labels: | ||
{{- include "mega-media.labels" $nameInTable | nindent 4 }} | ||
data: | ||
key: {{ b64enc .apiKey }} | ||
{{- end }} |
129 changes: 129 additions & 0 deletions
129
charts/mega-media/templates/helpers/_arr_deployment.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{{- define "mega-media.arr.deployment" -}} | ||
{{- $nameInTable := merge (dict "name" .selected.name) . -}} | ||
|
||
{{- $db_host := .Values.postgresql.enabled | ternary (printf "%s-postgresql" .Release.Name) .Values.externalPostgres.host -}} | ||
{{- $db_port := .Values.postgresql.enabled | ternary "5432" .Values.externalPostgres.port -}} | ||
{{- $db_user := .Values.postgresql.enabled | ternary "postgres" .Values.externalPostgres.username -}} | ||
{{- $db_secret_name := .Values.postgresql.enabled | ternary (printf "%s-postgresql" .Release.Name) .Values.externalPostgres.passwordFromSecretKeyRef.name -}} | ||
{{- $db_secret_key := .Values.postgresql.enabled | ternary "postgres-password" .Values.externalPostgres.passwordFromSecretKeyRef.key -}} | ||
{{- $db_dict := dict "host" $db_host "port" $db_port "user" $db_user "secret_name" $db_secret_name "secret_key" $db_secret_key -}} | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "mega-media.name" $nameInTable }} | ||
labels: | ||
{{- include "mega-media.labels" $nameInTable | nindent 4 }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
{{- include "mega-media.selectorLabels" $nameInTable | nindent 6 }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
labels: | ||
{{- include "mega-media.labels" $nameInTable | nindent 8 }} | ||
{{- with .Values.podLabels }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
affinity: | ||
{{- include "mega-media.sameNodePodAffinity" . | nindent 8 }} | ||
# https://wiki.servarr.com/sonarr/postgres-setup | ||
initContainers: | ||
- name: wait-for-db | ||
image: docker.io/bitnami/postgresql:17 | ||
command: | ||
- 'sh' | ||
- '-e' | ||
- '-c' | ||
- 'until pg_isready -U "postgres" -h {{ $db_host }} -p 5432; do sleep 1; done' | ||
{{- include "mega-media.initDb" (merge (dict "database" (printf "%s_main" .selected.name) "db_config" $db_dict) .) | nindent 8 }} | ||
{{- include "mega-media.initDb" (merge (dict "database" (printf "%s_log" .selected.name) "db_config" $db_dict) .) | nindent 8 }} | ||
{{- include "mega-media.initDb" (merge (dict "database" (printf "%s_cache" .selected.name) "db_config" $db_dict) .) | nindent 8 }} | ||
- name: init-myservice | ||
image: docker.io/busybox:1 | ||
command: | ||
- 'sh' | ||
- '-c' | ||
- | | ||
echo ' | ||
<Config> | ||
<BindAddress>*</BindAddress> | ||
<Port>{{ .selected.port }}</Port> | ||
<Branch>develop</Branch> | ||
<LogLevel>debug</LogLevel> | ||
<UrlBase></UrlBase> | ||
<ApiKey>{{ .apiKey }}</ApiKey> | ||
<AuthenticationMethod>External</AuthenticationMethod> | ||
<InstanceName>{{ .Release.Name }}</InstanceName> | ||
<PostgresUser>{{ $db_user }}</PostgresUser> | ||
<PostgresPassword>$(DB_PASSWORD)</PostgresPassword> | ||
<PostgresPort>{{ $db_port }}</PostgresPort> | ||
<PostgresHost>{{ $db_host }}</PostgresHost> | ||
<PostgresMainDb>{{ .selected.name }}_main</PostgresMainDb> | ||
<PostgresLogDb>{{ .selected.name }}_log</PostgresLogDb> | ||
<PostgresCacheDb>{{ .selected.name }}_cache</PostgresCacheDb> | ||
</Config>' > /config/config.xml && chmod 664 /config/config.xml | ||
env: | ||
- name: DB_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ $db_secret_name }} | ||
key: {{ $db_secret_key }} | ||
volumeMounts: | ||
- mountPath: /config | ||
name: config | ||
- name: init-media-subpath | ||
image: docker.io/busybox:1 | ||
command: | ||
- 'sh' | ||
- '-c' | ||
- | | ||
mkdir -p /media/{{ .selected.mediaDir }} | ||
chown 1000:1000 /media/{{ .selected.mediaDir }} | ||
volumeMounts: | ||
- mountPath: /media | ||
name: media | ||
containers: | ||
- name: {{ .selected.name }} | ||
image: "{{ .selected.image }}:{{ .selected.tag }}" | ||
imagePullPolicy: {{ .selected.pullPolicy }} | ||
ports: | ||
- name: http | ||
containerPort: {{ .selected.port }} | ||
protocol: TCP | ||
livenessProbe: | ||
{{- .selected.livenessProbe | default .Values.arrs.probes.livenessProbe | toYaml | nindent 12 }} | ||
readinessProbe: | ||
{{- .selected.readinessProbe | default .Values.arrs.probes.readinessProbe | toYaml | nindent 12 }} | ||
resources: | ||
{{- toYaml .selected.resources | nindent 12 }} | ||
envFrom: | ||
- configMapRef: | ||
name: {{ include "mega-media.name" (merge (dict "name" "arr-config") .) }} | ||
volumeMounts: | ||
- mountPath: /media | ||
name: media | ||
- mountPath: /config/config.xml | ||
name: config | ||
subPath: config.xml | ||
volumes: | ||
- name: config | ||
emptyDir: | ||
medium: Memory | ||
- name: media | ||
persistentVolumeClaim: | ||
claimName: {{ include "mega-media.name" (merge (dict "name" "media") .) }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- define "mega-media.config.pvc" -}} | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: {{ include "mega-media.name" (merge (dict "name" .name) .) }}-config | ||
labels: | ||
{{- include "mega-media.labels" (merge (dict "name" .name) .) | nindent 4 }} | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: {{ .storageClassName }} | ||
resources: | ||
requests: | ||
storage: {{ .size }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "mega-media.name" -}} | ||
{{- printf "%s-%s" (default .Release.Name .Values.nameOverride) .name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "mega-media.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "mega-media.labels" -}} | ||
helm.sh/chart: {{ include "mega-media.chart" . }} | ||
{{ include "mega-media.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "mega-media.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "mega-media.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
media/service: {{ .name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Same Node Pod Affinity | ||
*/}} | ||
{{- define "mega-media.sameNodePodAffinity" -}} | ||
podAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: app.kubernetes.io/instance | ||
operator: In | ||
values: | ||
- {{ .Release.Name }} | ||
topologyKey: kubernetes.io/hostname | ||
{{- end }} | ||
|
||
{{/* | ||
Postgres Init Db | ||
*/}} | ||
{{- define "mega-media.initDb" -}} | ||
- name: create-{{ kebabcase .database }}-if-missing | ||
image: docker.io/bitnami/postgresql:17 | ||
command: | ||
- 'sh' | ||
- '-e' | ||
- '-c' | ||
- | | ||
echo $(DB_PASSWORD) && PGPASSWORD="$(DB_PASSWORD)" psql -U {{ .db_config.user }} -h {{ .db_config.host }} -p {{ .db_config.port }} -tc "SELECT 1 FROM pg_database WHERE datname = '{{ .database }}'" | grep -q 1 || PGPASSWORD="$(DB_PASSWORD)" psql -U {{ .db_config.user }} -h {{ .db_config.host }} -p {{ .db_config.port }} -c "CREATE DATABASE {{ .database }}" | ||
env: | ||
- name: DB_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .db_config.secret_name }} | ||
key: {{ .db_config.secret_key }} | ||
{{- end }} |
Oops, something went wrong.