diff --git a/go2rtc/Chart.yaml b/go2rtc/Chart.yaml new file mode 100644 index 0000000..45e4d74 --- /dev/null +++ b/go2rtc/Chart.yaml @@ -0,0 +1,13 @@ +apiVersion: v2 +name: go2rtc +description: >- + go2rtc camera proxy (RTSP, WebRTC, MSE, HomeKit). Own chart (not a wrapper): + one Deployment + ConfigMap + Service + PVC + Ingress. The image tag is the + chart appVersion, which scripts/update-charts.sh bumps from AlexxIT/go2rtc + releases through the annotation below. +type: application +version: 0.1.0 +appVersion: "1.9.15" +annotations: + version-source: github-release:AlexxIT/go2rtc + version-pattern: "s|^v||" diff --git a/go2rtc/templates/configmap.yaml b/go2rtc/templates/configmap.yaml new file mode 100644 index 0000000..bbce6fe --- /dev/null +++ b/go2rtc/templates/configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-config + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} +data: + go2rtc.yaml: | + {{- .Values.config | nindent 4 }} diff --git a/go2rtc/templates/deployment.yaml b/go2rtc/templates/deployment.yaml new file mode 100644 index 0000000..91235b0 --- /dev/null +++ b/go2rtc/templates/deployment.yaml @@ -0,0 +1,128 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + app.kubernetes.io/component: proxy + annotations: + version-source: {{ index .Chart.Annotations "version-source" }} + version-pattern: {{ index .Chart.Annotations "version-pattern" | quote }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + annotations: + checksum/config: {{ .Values.config | sha256sum }} + spec: + {{- if .Values.hostNetwork }} + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.persistence.enabled }} + initContainers: + - name: init-state + image: busybox:1.37 + command: + - /bin/sh + - -ec + - | + [ -f /data/state.yaml ] || echo "{}" > /data/state.yaml + volumeMounts: + - name: data + mountPath: /data + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.persistence.enabled }} + args: + - -c + - /data/state.yaml + - -c + - /config/go2rtc.yaml + - -c + - /data/state.yaml + {{- else }} + args: + - -c + - /config/go2rtc.yaml + {{- end }} + ports: + - name: http + containerPort: {{ .Values.apiPort }} + protocol: TCP + - name: rtsp + containerPort: {{ .Values.rtspPort }} + protocol: TCP + - name: webrtc + containerPort: {{ .Values.webrtcPort }} + protocol: TCP + - name: webrtc-udp + containerPort: {{ .Values.webrtcPort }} + protocol: UDP + env: + - name: TZ + value: {{ .Values.timezone | quote }} + {{- if .Values.existingSecret }} + envFrom: + - secretRef: + name: {{ .Values.existingSecret }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + readinessProbe: + httpGet: + path: /api + port: http + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + livenessProbe: + httpGet: + path: /api + port: http + initialDelaySeconds: 30 + periodSeconds: 30 + timeoutSeconds: 10 + failureThreshold: 3 + volumeMounts: + - name: config + mountPath: /config + readOnly: true + {{- if .Values.persistence.enabled }} + - name: data + mountPath: /data + {{- end }} + volumes: + - name: config + configMap: + name: {{ .Release.Name }}-config + {{- if .Values.persistence.enabled }} + - name: data + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim | default (printf "%s-data" .Release.Name) }} + {{- end }} diff --git a/go2rtc/templates/ingress.yaml b/go2rtc/templates/ingress.yaml new file mode 100644 index 0000000..9eca732 --- /dev/null +++ b/go2rtc/templates/ingress.yaml @@ -0,0 +1,27 @@ +{{- range $name, $config := .Values.ingresses }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $.Release.Name }}-{{ $name }} + {{- with $config.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + rules: + - host: {{ $config.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ $.Release.Name }} + port: + number: {{ $.Values.service.port }} + {{- with $config.tls }} + tls: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/go2rtc/templates/pvc.yaml b/go2rtc/templates/pvc.yaml new file mode 100644 index 0000000..37bc230 --- /dev/null +++ b/go2rtc/templates/pvc.yaml @@ -0,0 +1,16 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-data + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + accessModes: + {{- toYaml .Values.persistence.accessModes | nindent 4 }} + storageClassName: {{ .Values.persistence.storageClass }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} diff --git a/go2rtc/templates/service.yaml b/go2rtc/templates/service.yaml new file mode 100644 index 0000000..dd1db1b --- /dev/null +++ b/go2rtc/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }} + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + type: {{ .Values.service.type }} + selector: + app: {{ .Release.Name }} + ports: + - name: http + port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + - name: rtsp + port: {{ .Values.service.rtspPort }} + targetPort: rtsp + protocol: TCP diff --git a/go2rtc/values.yaml b/go2rtc/values.yaml new file mode 100644 index 0000000..952d074 --- /dev/null +++ b/go2rtc/values.yaml @@ -0,0 +1,65 @@ +# Default values for the go2rtc Helm chart +image: + repository: alexxit/go2rtc + # Empty tag = chart appVersion (bumped by scripts/update-charts.sh) + tag: "" + pullPolicy: IfNotPresent + +timezone: "Europe/Kyiv" + +# HomeKit (mDNS) and WebRTC (UDP) need the real LAN address of the node. +# Keep true unless the cameras are proxied through the Service only. +hostNetwork: true + +apiPort: 1984 +rtspPort: 8554 +webrtcPort: 8555 + +service: + type: ClusterIP + port: 1984 + rtspPort: 8554 + +# go2rtc configuration (YAML text). It is mounted read-only at +# /config/go2rtc.yaml. Use ${VAR} for secrets: the variables come from +# existingSecret. Pairing data of the HomeKit server is NOT written here +# (see persistence). +config: | + api: + listen: ":1984" + streams: {} + +# Existing Secret. Every key becomes an environment variable of the container. +existingSecret: "" + +# State file of go2rtc (/data/state.yaml). go2rtc writes the HomeKit pairings +# into the first config file it gets, so this small file must be writable and +# must survive a restart. It is passed as the first and the last `-c` option, +# so its pairings win over the read-only /config/go2rtc.yaml. +persistence: + enabled: true + existingClaim: "" + storageClass: local-path + accessModes: + - ReadWriteOnce + size: 100Mi + +resources: + requests: + cpu: "100m" + memory: "128Mi" + limits: + cpu: "2" + memory: "1Gi" + +nodeSelector: {} +tolerations: [] +affinity: {} + +ingresses: {} + # https: + # host: cams.example.com + # annotations: {} + # tls: + # - hosts: + # - cams.example.com