Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let oryx app running in three containers. #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions oryx/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: oryx
appVersion: "5.14.19"
version: 1.0.7
appVersion: "5.15.20"
version: 1.0.8
description: Oryx(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
Expand Down
2 changes: 2 additions & 0 deletions oryx/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.multiContainers.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -123,3 +124,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
302 changes: 302 additions & 0 deletions oryx/templates/multi-containers-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
{{- if .Values.multiContainers.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "srs.fullname" . }}
labels:
{{- include "srs.labels" . | nindent 4 }}
spec:
restartPolicy: Always
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "srs.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "srs.selectorLabels" . | nindent 8 }}
spec:
volumes:
- name: srs-pv-storage
persistentVolumeClaim:
claimName: srs-pv-claim
- name: cache-volume
emptyDir: {}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "srs.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
# redis sidcar container
# TODO support external redis service, disable redis container if external one is defined.
- name: redis
volumeMounts:
- mountPath: "/data"
name: srs-pv-storage
{{- if .Values.persistence.subPath }}
subPath: {{ .Values.persistence.subPath | quote }}
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
restartPolicy: Always
command:
- bash
- -c
- |-
./auto/start_redis

stop_services() {
./auto/before_stop
./auto/stop_redis
}

handle_signals() {
echo "Platform: Signal $1 received. Cleaning up and exiting..."
stop_services
exit 0
}
trap 'handle_signals SIGTERM' SIGTERM
trap 'handle_signals SIGINT' SIGINT

while true; do
sleep 3
if [[ $(ps aux |grep redis |grep -q server || echo no) == no ]]; then
echo "Redis server stopped, exit."
break
fi
done

stop_services
exit 1
ports:
- name: redis
containerPort: 6379 # the redis default port
protocol: TCP
livenessProbe:
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 5
periodSeconds: 10
# srs sidecar container
- name: srs
volumeMounts:
- mountPath: "/data"
name: srs-pv-storage
{{- if .Values.persistence.subPath }}
subPath: {{ .Values.persistence.subPath | quote }}
{{- end }}
- mountPath: "/usr/local/oryx/platform/containers/objs/nginx/html"
name: cache-volume
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
restartPolicy: Always
command: # ["./auto/start_srs"]
- bash
- -c
- |-
./auto/start_srs

stop_services() {
./auto/stop_srs
}

handle_signals() {
echo "Signal $1 received. Cleaning up and exiting..."
stop_services
exit 0
}

trap 'handle_signals SIGTERM' SIGTERM
trap 'handle_signals SIGINT' SIGINT

while true; do
sleep 3
if [[ $(ps aux |grep srs |grep -q conf || echo no) == no ]]; then
echo "SRS server stopped, exit."
break
fi
done
stop_services
exit 1
ports:
- name: rtmp
containerPort: 1935
protocol: TCP
- name: api
containerPort: 1985
protocol: TCP
- name: http
containerPort: 8080
protocol: TCP
- name: srt
containerPort: 10080
protocol: UDP
- name: rtc
containerPort: 8000
protocol: UDP
env:
# The general default config.
- name: SRS_PLATFORM
value: "helm"
# Overwrite the config by conf.
{{- range $key, $value := .Values.conf }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
# Overwrite the config by env.
{{- range .Values.env }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
# Overwrite by special item.
{{- if .Values.candidate }}
- name: SRS_RTC_SERVER_CANDIDATE
value: {{ .Values.candidate | quote }}
{{- end }}
# For Oryx, we resolve the ip in platform.
- name: SRS_RTC_SERVER_API_AS_CANDIDATES
value: "off"
# For Oryx, never detect network ip, because it runs in docker, and the ip is private.
- name: SRS_RTC_SERVER_USE_AUTO_DETECT_NETWORK_IP
value: "off"
# For Oryx, should always enable daemon.
- name: SRS_DAEMON
value: "on"
- name: SRS_HTTP_API_LISTEN
value: "1985"
livenessProbe:
httpGet:
path: /api/v1/versions
port: api
periodSeconds: 10
readinessProbe:
httpGet:
path: /api/v1/versions
port: api
periodSeconds: 10
startupProbe:
httpGet:
path: /api/v1/versions
port: api
initialDelaySeconds: 2
failureThreshold: 3
periodSeconds: 10
containers:
# oryx main application container
- name: oryx
volumeMounts:
- mountPath: "/data"
name: srs-pv-storage
{{- if .Values.persistence.subPath }}
subPath: {{ .Values.persistence.subPath | quote }}
{{- end }}
- mountPath: "/usr/local/oryx/platform/containers/objs/nginx/html"
name: cache-volume
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: # ["./platform"]
- bash
- -c
- |-
echo "--- oryx container entry ---"
echo "start oryx platform"
./platform &
if [[ $? -ne 0 ]]; then echo "Start platform failed"; exit 1; fi
handle_signals() {
echo "Platform: Signal $1 received. Cleaning up and exiting..."
exit 0
}
trap 'handle_signals SIGTERM' SIGTERM
trap 'handle_signals SIGINT' SIGINT

while true; do
sleep 3

if [[ $(ps aux |grep platform |grep -v grep |grep -v usr |grep -q platform || echo no) == no ]]; then
echo "Platform stopped, exit."
break
fi
done

exit 1
ports:
- name: http
containerPort: 2022
protocol: TCP
- name: https
containerPort: 2443
protocol: TCP
env:
# The general default config.
- name: SRS_PLATFORM
value: "helm"
# Overwrite the config by conf.
{{- range $key, $value := .Values.conf }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
# Overwrite the config by env.
{{- range .Values.env }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
# For multiple instances expose different ports.
- name: RTMP_PORT
value: {{ .Values.service.rtmp | quote }}
- name: SRT_PORT
value: {{ .Values.service.srt | quote }}
- name: RTC_PORT
value: {{ .Values.service.rtc | quote }}
# Enable self-sign certificate by default.
- name: AUTO_SELF_SIGNED_CERTIFICATE
value: "on"
# Enable dns name lookup.
- name: NAME_LOOKUP
value: "on"
livenessProbe:
httpGet:
path: /terraform/v1/host/versions
port: http
readinessProbe:
httpGet:
path: /terraform/v1/host/versions
port: http
startupProbe:
httpGet:
path: /terraform/v1/host/versions
port: http
initialDelaySeconds: 2
failureThreshold: 3
periodSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
7 changes: 7 additions & 0 deletions oryx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ image:
tag: ""
pullPolicy: IfNotPresent

# simple set replicaCount more than one don't make sense, because oryx is stateful app.
replicaCount: 1

# muti containers mean the oryx platform, redis, and srs in its own container.
multiContainers:
# Specifies whether deploy oryx as single container or multi containers in a pod.
enabled: false

# The configuration for SRS can be overridden by environment variables.
# See https://github.com/ossrs/srs/blob/develop/trunk/conf/full.conf
conf:
Expand Down Expand Up @@ -107,6 +113,7 @@ resources: {}
# cpu: 100m
# memory: 128Mi

# simple open autoscaling don't make sense, because oryx is stateful app.
autoscaling:
enabled: false
minReplicas: 1
Expand Down