Skip to content

Commit

Permalink
srs-stack: Support SRS Stack HELM. v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 29, 2023
1 parent a1f217d commit b154202
Show file tree
Hide file tree
Showing 19 changed files with 673 additions and 12 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ For detailed information on using SRS, please refer to [https://ossrs.io](https:

> Note: If you are in China, please refer to [https://ossrs.net](https://ossrs.net).
## Features
## Features: srs-server

Note all features of SRS and SRS Stack are supported by the HELM charts, however, we're working to
migrate them to HELM.
Expand All @@ -51,6 +51,10 @@ migrate them to HELM.
- [ ] Support HTTPS server and API for WebRTC publisher.
- [ ] Integrate Prometheus and grafana dashboard.

## Features: srs-stack

- [x] v1.0.0: Support RTMP, HTTP, HTTPS, SRT, and WebRTC in SRS Stack.

## Local Repository

You can also set up the local HELM repository by executing the following command:
Expand Down Expand Up @@ -117,6 +121,12 @@ file by following command:
./auto/srs-server.sh -target v1.0.6
```

And, maybe also release a new version of srs-stack v1.0.7, run:

```bash
./auto/srs-stack.sh -target v1.0.7
```

Then, release the chart web server image and refresh official website by:

```bash
Expand Down
8 changes: 5 additions & 3 deletions auto/srs-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ echo "RELEASE=$RELEASE, VERSION=$VERSION, TAG=$TAG, REVISION=$REVISION, NEXT=$NE

if [[ $(grep -q "version: $VERSION" srs-server/Chart.yaml || echo no) == no ]]; then
VERSION0="sed -i '' 's/^version:.*/version: $VERSION/g' srs-server/Chart.yaml"
VERSION1="sed -i '' 's|v1.*/srs-server|$TAG/srs-server|g' srs-server/Chart.yaml"
fi
if [[ ! -z $VERSION0 ]]; then
if [[ ! -z $VERSION0 || ! -z $VERSION1 ]]; then
echo "Please update version to $VERSION"
if [[ ! -z $VERSION0 ]]; then echo " $VERSION0 &&"; fi
if [[ ! -z $VERSION1 ]]; then echo " $VERSION1 &&"; fi
echo " echo ok"
exit 1
fi
Expand Down Expand Up @@ -87,5 +89,5 @@ git tag $TAG && git push origin $TAG
echo "Publish OK: $TAG"

echo -e "\n\n"
echo "Publication ok, please visit"
echo " Please test it after https://github.com/ossrs/srs-helm/actions/workflows/docker.yml done"
echo "Chart srs-server $VERSION ok, please release to official website by:"
echo " ./auto/pub.sh"
93 changes: 93 additions & 0 deletions auto/srs-stack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

# Execute by: bash xxx.sh or bash zzz/yyy/xxx.sh or ./xxx.sh or ./zzz/yyy/xxx.sh source xxx.sh
REALPATH=$(realpath ${BASH_SOURCE[0]})
SCRIPT_DIR=$(cd $(dirname ${REALPATH}) && pwd)
WORK_DIR=$(cd $(dirname ${REALPATH})/.. && pwd)
echo "BASH_SOURCE=${BASH_SOURCE}, REALPATH=${REALPATH}, SCRIPT_DIR=${SCRIPT_DIR}, WORK_DIR=${WORK_DIR}"
cd ${WORK_DIR}

help=false
refresh=false
target=

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) help=true; shift ;;
-refresh|--refresh) refresh=true; shift ;;
-target|--target) target="$2"; shift 2;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
done

if [ "$help" = true ]; then
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -h, --help Show this help message and exit"
echo " -refresh, --refresh Refresh current tag. Default: false"
echo " -target, --target The target version to release, for example, v5.7.28"
exit 0
fi

if [[ ! -z $target ]]; then
RELEASE=$target
refresh=yes
else
RELEASE=$(git describe --tags --abbrev=0 --match srs-stack-v* |sed 's/srs-stack-//g')
fi
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

REVISION=$(echo $RELEASE |awk -F . '{print $3}')
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

let NEXT=$REVISION+1
if [[ $refresh == yes ]]; then
let NEXT=$REVISION
fi
VERSION=$(echo $RELEASE |sed 's/v//g')
TAG=$RELEASE
echo "RELEASE=$RELEASE, VERSION=$VERSION, TAG=$TAG, REVISION=$REVISION, NEXT=$NEXT"

if [[ $(grep -q "version: $VERSION" srs-stack/Chart.yaml || echo no) == no ]]; then
VERSION0="sed -i '' 's/^version:.*/version: $VERSION/g' srs-stack/Chart.yaml"
VERSION1="sed -i '' 's|v1.*/srs-stack|$TAG/srs-stack|g' srs-stack/Chart.yaml"
fi
if [[ ! -z $VERSION0 || ! -z $VERSION1 ]]; then
echo "Please update version to $VERSION"
if [[ ! -z $VERSION0 ]]; then echo " $VERSION0 &&"; fi
if [[ ! -z $VERSION1 ]]; then echo " $VERSION1 &&"; fi
echo " echo ok"
exit 1
fi

if [[ ! -f stable/srs-stack-$VERSION.tgz ]]; then
echo "Failed: No package at stable/srs-stack-$VERSION.tgz"
echo "Please run:"
echo " helm package srs-stack -d stable && \\"
echo " helm repo index stable"
exit 1
fi

git st |grep -q 'nothing to commit'
if [[ $? -ne 0 ]]; then
echo "Failed: Please commit before release";
exit 1
fi

git fetch origin
if [[ $(git status |grep -q 'Your branch is up to date' || echo 'no') == no ]]; then
git status
echo "Failed: Please sync before release";
exit 1
fi
echo "Sync OK"

git tag -d $TAG 2>/dev/null; git push origin :$TAG 2>/dev/null
echo "Delete tag OK: $TAG"

git tag $TAG && git push origin $TAG
echo "Publish OK: $TAG"

echo -e "\n\n"
echo "Chart srs-stack $VERSION ok, please release to official website by:"
echo " ./auto/pub.sh"
2 changes: 1 addition & 1 deletion srs-server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords:
- webrtc
- srt
sources:
- https://github.com/ossrs/srs-helm/tree/v1.0.0/srs-server
- https://github.com/ossrs/srs-helm/tree/v1.0.5/srs-server
maintainers:
- name: Winlin
email: [email protected]
Expand Down
23 changes: 23 additions & 0 deletions srs-stack/.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/
28 changes: 28 additions & 0 deletions srs-stack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v2
name: srs-stack
appVersion: "5.11.5"
version: 1.0.1
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.
home: https://helm.ossrs.io/stable
icon: https://ossrs.io/lts/en-us/img/srs-220x234.png
keywords:
- srs
- media
- video
- rtmp
- hls
- webrtc
- srt
sources:
- https://github.com/ossrs/srs-helm/tree/v1.0.1/srs-stack
maintainers:
- name: Winlin
email: [email protected]
url: https://github.com/ossrs/srs-helm
type: application
annotations:
category: Infrastructure
licenses: MIT
Empty file added srs-stack/charts/.gitkeep
Empty file.
22 changes: 22 additions & 0 deletions srs-stack/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 "srs.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 "srs.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "srs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.http }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "srs.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 srs-stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "srs.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 "srs.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 "srs.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "srs.labels" -}}
helm.sh/chart: {{ include "srs.chart" . }}
{{ include "srs.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "srs.selectorLabels" -}}
app.kubernetes.io/name: {{ include "srs.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "srs.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "srs.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Loading

0 comments on commit b154202

Please sign in to comment.