From 50ed6fe844da4a4b2adcab676b73832ddbfccc49 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 6 Nov 2023 21:12:17 +0800 Subject: [PATCH] Support storage for srs-stack. --- README.md | 25 ++++++++++++++++++++---- srs-stack/Chart.yaml | 10 +++++----- srs-stack/templates/deployment.yaml | 8 ++++++++ srs-stack/templates/pvc.yaml | 30 +++++++++++++++++++++++++++++ srs-stack/values.yaml | 12 ++++++++++++ 5 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 srs-stack/templates/pvc.yaml diff --git a/README.md b/README.md index 8204e06..d1e53fa 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,16 @@ To install the SRS origin server, run: helm install srs srs/srs-server ``` -> Note: If enable WebRTC, please setup the [CANDIDATE](https://ossrs.io/lts/en-us/docs/v5/doc/webrtc#config-candidate) -> by `helm install srs srs/srs-server --set candidate=your-internal-public-ip` - Visit [http://localhost:8080](http://localhost:8080) to access the SRS console. +Important config for both srs-server and srs-stack: + +* If enable WebRTC, please setup the [CANDIDATE](https://ossrs.io/lts/en-us/docs/v5/doc/webrtc#config-candidate) by `helm install srs srs/srs-server --set candidate=your-internal-public-ip` + +Important config for srs-stack only: + +* By default, use `/data` of host as storage directory, if want to change, please use `--set persistence.path=$HOME/data` for example. + For detailed information on using SRS, please refer to [https://ossrs.io](https://ossrs.io). > Note: If you are in China, please refer to [https://ossrs.net](https://ossrs.net). @@ -95,7 +100,19 @@ Now, you can utilize SRS HELM. For more information, refer to the [Usage](#usage ## Develop Repository -Serve current directory in Nginx or other HTTP server, for example: +The simplest way to develop is to build a new chart by: + +```bash +helm package srs-server +``` + +Then install the local chart by: + +```bash +helm install srs srs-server-1.0.0.tgz +``` + +Or, to test the repo, serve current directory in Nginx or other HTTP server, for example: ```bash docker run --rm -it -p 3000:80 -v $(pwd):/usr/share/nginx/html \ diff --git a/srs-stack/Chart.yaml b/srs-stack/Chart.yaml index 751f867..445bb48 100644 --- a/srs-stack/Chart.yaml +++ b/srs-stack/Chart.yaml @@ -1,11 +1,11 @@ apiVersion: v2 name: srs-stack appVersion: "5.11.10" -version: 1.0.2 -description: SRS Stack is a one-click, open-source video solution for creating online services on - cloud or self-hosting. Built with SRS, FFmpeg, and WebRTC, it supports various protocols and offers - features like authentication, multi-platform streaming, recording, transcoding, virtual live events, - automatic HTTPS, and HTTP Open API. +version: 1.0.3 +description: SRS Stack is an all-in-one, one-click, and open-source video solution for creating online + services on cloud or self-hosting. Built with SRS, FFmpeg, and WebRTC, it supports various protocols + and offers features like authentication, multi-platform streaming, recording, transcoding, virtual + live events, automatic HTTPS, and HTTP Open API. home: https://helm.ossrs.io/stable icon: https://ossrs.io/lts/en-us/img/srs-220x234.png keywords: diff --git a/srs-stack/templates/deployment.yaml b/srs-stack/templates/deployment.yaml index 8153c0d..1860e3a 100644 --- a/srs-stack/templates/deployment.yaml +++ b/srs-stack/templates/deployment.yaml @@ -20,6 +20,10 @@ spec: labels: {{- include "srs.selectorLabels" . | nindent 8 }} spec: + volumes: + - name: srs-pv-storage + persistentVolumeClaim: + claimName: srs-pv-claim {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} @@ -29,6 +33,10 @@ spec: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - name: {{ .Chart.Name }} + volumeMounts: + - mountPath: "/data" + name: srs-pv-storage + subPath: {{ .Values.persistence.subPath | quote }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" diff --git a/srs-stack/templates/pvc.yaml b/srs-stack/templates/pvc.yaml new file mode 100644 index 0000000..06ec7cf --- /dev/null +++ b/srs-stack/templates/pvc.yaml @@ -0,0 +1,30 @@ +{{- if (.Values.persistence.enabled) }} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: srs-pv-volume + labels: + type: local +spec: + storageClassName: srs-disk-storage + capacity: + storage: {{ .Values.persistence.storage }} + accessModes: + - ReadWriteOnce + hostPath: + path: {{ .Values.persistence.path }} + +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: srs-pv-claim +spec: + storageClassName: srs-disk-storage + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.persistence.storage }} +{{- end }} diff --git a/srs-stack/values.yaml b/srs-stack/values.yaml index aeb19df..1b142dd 100644 --- a/srs-stack/values.yaml +++ b/srs-stack/values.yaml @@ -59,6 +59,18 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 +## Persistence parameters +## ref: https://kubernetes.io/docs/concepts/storage/persistent-volumes/ +persistence: + ## @param persistence.enabled Enable persistence. + enabled: true + ## @param persistence.path The path of the hostPath. + path: /data + ## @param persistence.storage The size of the volume to allocate. + storage: 3000Gi + ## @param persistence.subPath The subdirectory of the volume to mount. + subPath: "0" + service: type: LoadBalancer rtmp: 1935