From ea3a10b5e41e1cb22919246d349860b6763f2ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alin=20Tr=C4=83istaru?= Date: Tue, 4 Feb 2025 19:00:37 +0100 Subject: [PATCH] feat: add inv_sig_helper support (#9) --- invidious/Chart.yaml | 2 +- invidious/templates/_helpers.tpl | 27 ++++++--- invidious/templates/sighelper-service.yaml | 19 +++++++ .../templates/sighelper-statefulset.yaml | 57 +++++++++++++++++++ invidious/values.yaml | 10 ++++ 5 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 invidious/templates/sighelper-service.yaml create mode 100644 invidious/templates/sighelper-statefulset.yaml diff --git a/invidious/Chart.yaml b/invidious/Chart.yaml index 6cb41e0..791ffd5 100644 --- a/invidious/Chart.yaml +++ b/invidious/Chart.yaml @@ -4,7 +4,7 @@ description: Invidious is an alternative front-end to YouTube type: application -version: 2.0.5 +version: 2.1.0 appVersion: v2.20240427 dependencies: diff --git a/invidious/templates/_helpers.tpl b/invidious/templates/_helpers.tpl index 022f282..796307f 100644 --- a/invidious/templates/_helpers.tpl +++ b/invidious/templates/_helpers.tpl @@ -55,15 +55,24 @@ app.kubernetes.io/instance: {{ .Release.Name }} Initialize default values and validate database configuration */}} {{- define "invidious.init-defaults" -}} -{{/* Set default PostgreSQL host if using in-chart PostgreSQL */}} -{{- if .Values.postgresql.enabled }} - {{- if not .Values.config.db.host }} - {{- $_ := set .Values.config.db "host" (printf "%s-postgresql" .Release.Name) }} + {{/* Set default PostgreSQL host if using in-chart PostgreSQL */}} + {{- if .Values.postgresql.enabled }} + {{- if not .Values.config.db.host }} + {{- $_ := set .Values.config.db "host" (printf "%s-postgresql" .Release.Name) }} + {{- end }} + {{- else }} + {{/* Fail if external database host is not provided when in-chart PostgreSQL is disabled */}} + {{- if not .Values.config.db.host }} + {{- fail "config.db.host must be set when postgresql.enabled is false" }} + {{- end }} {{- end }} -{{- else }} -{{/* Fail if external database host is not provided when in-chart PostgreSQL is disabled */}} - {{- if not .Values.config.db.host }} - {{- fail "config.db.host must be set when postgresql.enabled is false" }} + + {{/* Set signature server if sighelper is enabled */}} + {{- if .Values.sighelper.enabled }} + {{- if not .Values.config.signature_server }} + {{- $serviceName := printf "%s-sighelper" (include "invidious.fullname" .) }} + {{- $servicePort := .Values.sighelper.service.port | default 12999 | int }} + {{- $_ := set .Values.config "signature_server" (printf "%s:%d" $serviceName $servicePort) }} + {{- end }} {{- end }} -{{- end }} {{- end -}} diff --git a/invidious/templates/sighelper-service.yaml b/invidious/templates/sighelper-service.yaml new file mode 100644 index 0000000..7962a03 --- /dev/null +++ b/invidious/templates/sighelper-service.yaml @@ -0,0 +1,19 @@ +{{- if .Values.sighelper.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "invidious.fullname" . }}-sighelper + labels: + {{- include "invidious.labels" . | nindent 4 }} + app.kubernetes.io/component: sighelper +spec: + type: ClusterIP + ports: + - port: {{ .Values.sighelper.service.port }} + targetPort: 12999 + protocol: TCP + name: sighelper + selector: + {{- include "invidious.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: sighelper +{{- end }} diff --git a/invidious/templates/sighelper-statefulset.yaml b/invidious/templates/sighelper-statefulset.yaml new file mode 100644 index 0000000..6f00fb7 --- /dev/null +++ b/invidious/templates/sighelper-statefulset.yaml @@ -0,0 +1,57 @@ +{{- if .Values.sighelper.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ template "invidious.fullname" . }}-sighelper + labels: + {{- include "invidious.labels" . | nindent 4 }} + app.kubernetes.io/component: sighelper +spec: + replicas: 1 + selector: + matchLabels: + {{- include "invidious.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: sighelper + serviceName: {{ template "invidious.fullname" . }}-sighelper + template: + metadata: + labels: + {{- include "invidious.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: sighelper + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: sighelper + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.sighelper.image.repository }}:{{ .Values.sighelper.image.tag }}" + imagePullPolicy: {{ .Values.sighelper.image.pullPolicy }} + args: + - "--tcp" + - "0.0.0.0:12999" + ports: + - name: sighelper + containerPort: 12999 + protocol: TCP + livenessProbe: + tcpSocket: + port: 12999 + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: 12999 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + {{- toYaml .Values.sighelper.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} diff --git a/invidious/values.yaml b/invidious/values.yaml index debc6bb..2027df8 100644 --- a/invidious/values.yaml +++ b/invidious/values.yaml @@ -97,3 +97,13 @@ config: channel_threads: 1 full_refresh: false feed_threads: 1 + +sighelper: + enabled: true + resources: {} + service: + port: 12999 + image: + repository: quay.io/invidious/inv-sig-helper + tag: latest + pullPolicy: Always