This commit is contained in:
zeaslity
2024-10-30 16:30:51 +08:00
commit 437acbeb63
3363 changed files with 653948 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
- Make sure exported ports and origin nodes are corresponding to which defined in configuration files.
- 1 origin + 3edge cluster may work for 300 input and 3000 output concurrence.
- Api services are inconsistent between multiple origin in one cluster.
- srsog, srsrtc is the headless svc for get pod's ip which were created by stateful set.

View File

@@ -0,0 +1,208 @@
{{- define "srs.config.apilist" -}}
{{- range $i, $e := int .Values.apps.srs.replicas.origin | until }} {{ $.Values.deploy.name }}-og-{{ $i }}.{{ $.Values.apps.srs.service.headless.og }}:{{ $.Values.apps.srs.ports.api }}
{{- end -}}
{{- end -}}
{{- define "srs.config.rtmplist" -}}
{{- range $i, $e := int .Values.apps.srs.replicas.origin | until }} {{ $.Values.deploy.name }}-og-{{ $i }}.{{ $.Values.apps.srs.service.headless.og }}:{{ $.Values.apps.srs.ports.rtmp }}
{{- end -}}
{{- end -}}
{{- define "srs.config.hooks" -}}
{{ if .Values.enabled.hook }}
http_hooks {
enabled on;
on_publish http://{{ $.Values.deploy.name }}-op-svc:8080/hooks/on_publish;
}
{{- end }}
{{- end -}}
{{- define "srs.config.origin" -}}
listen {{ .Values.apps.srs.ports.rtmp }};
max_connections 4096;
srs_log_tank console;
srs_log_file /home/srs.log;
daemon off;
http_api {
enabled on;
listen {{ .Values.apps.srs.ports.api }};
crossdomain on;
raw_api {
enabled on;
allow_reload on;
allow_query on;
allow_update on;
}
}
http_server {
enabled on;
listen {{ .Values.apps.srs.ports.flv }};
dir /home/hls;
}
stats {
network 0;
}
{{- if lt .Values.apps.srs.replicas.origin 2.0 }}
rtc_server {
enabled on;
listen {{ .Values.apps.srs.ports.rtc }};
candidate $CANDIDATE;
}
{{- end }}
vhost __defaultVhost__ {
cluster {
origin_cluster on;
coworkers {{ include "srs.config.apilist" . }};
}
http_hooks {
enabled off;
}
{{- if lt .Values.apps.srs.replicas.origin 2.0 }}
rtc {
enabled on;
rtmp_to_rtc on;
rtc_to_rtmp on;
keep_bframe off;
}
{{- end }}
tcp_nodelay on;
min_latency on;
play {
gop_cache off;
mw_latency 0;
mw_msgs 0;
}
publish {
firstpkt_timeout 4000;
normal_timeout 2000;
mr off;
}
dvr {
enabled off;
dvr_path /home/dvr/[app]/[stream]/[2006][01]/[timestamp].mp4;
dvr_plan session;
}
hls {
enabled on;
hls_path /home/hls;
hls_fragment 10;
hls_window 60;
hls_m3u8_file [app]/[stream].m3u8;
hls_ts_file [app]/[stream]/[2006][01][02]/[timestamp]-[duration].ts;
hls_cleanup on;
}
}
{{- end -}}
{{- define "srs.config.edge" -}}
listen {{ .Values.apps.srs.ports.rtmp }};
max_connections 4096;
srs_log_tank file;
srs_log_file /home/srs.log;
daemon on;
http_api {
enabled on;
listen {{ .Values.apps.srs.ports.api }};
crossdomain on;
raw_api {
enabled on;
allow_reload on;
allow_query on;
allow_update on;
}
}
http_server {
enabled on;
listen {{ .Values.apps.srs.ports.flv }};
dir /home/hls;
}
stats {
network 0;
}
vhost __defaultVhost__ {
cluster {
mode remote;
origin {{ include "srs.config.rtmplist" . }};
}
{{- include "srs.config.hooks" . }}
http_remux {
enabled on;
}
tcp_nodelay on;
min_latency on;
play {
gop_cache off;
mw_latency 0;
mw_msgs 0;
}
publish {
firstpkt_timeout 4000;
normal_timeout 2000;
mr off;
}
}
{{- end -}}
{{- define "srs.config.rtc" -}}
listen {{ .Values.apps.srs.ports.rtmp }};
max_connections 4096;
srs_log_tank console;
srs_log_file /home/srs.log;
daemon off;
http_api {
enabled on;
listen {{ .Values.apps.srs.ports.api }};
crossdomain on;
}
stats {
network 0;
}
http_server {
enabled on;
listen {{ .Values.apps.srs.ports.flv }};
dir /home/hls;
}
rtc_server {
enabled on;
listen {{ .Values.apps.srs.ports.rtc }};
candidate $CANDIDATE;
}
vhost __defaultVhost__ {
{{- include "srs.config.hooks" . }}
http_remux {
enabled on;
}
rtc {
enabled on;
rtmp_to_rtc on;
rtc_to_rtmp on;
keep_bframe off;
}
tcp_nodelay on;
min_latency on;
play {
gop_cache off;
mw_latency 0;
mw_msgs 0;
}
publish {
firstpkt_timeout 4000;
normal_timeout 2000;
mr off;
}
dvr {
enabled off;
dvr_path /home/dvr/[app]/[stream]/[2006][01]/[timestamp].mp4;
dvr_plan session;
}
hls {
enabled on;
hls_path /home/hls;
hls_fragment 10;
hls_window 60;
hls_m3u8_file [app]/[stream].m3u8;
hls_ts_file [app]/[stream]/[2006][01][02]/[timestamp]-[duration].ts;
hls_cleanup on;
}
}
{{- end -}}

View File

@@ -0,0 +1,22 @@
{{- define "srs.affinity" -}} {{/* */}}
{{- with .Values.deploy.k8s.affinity }}
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: uavcloud.affinity
operator: In
values:
- {{ .node }}
{{- end }}
{{- end }}
{{- define "srs.vol.main" -}}
{{- if eq .Values.apps.srs.storage.class "emptyDir" }}
emptyDir:
sizeLimit: {{ .Values.apps.srs.storage.size }}
{{- else if eq .Values.apps.srs.storage.class "gfs" }}
persistentVolumeClaim:
claimName: {{ .Values.apps.srs.storage.pvc }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,58 @@
{{/* vim: set filetype=mustache: */}}
{{- define "srs.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 }}
{{- end }}
{{- define "srs.labels.standard" -}}
cmii.app: video-live-srs
cmii.type: middleware
helm.sh/chart: {{ include "srs.chart" . }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
{{- if $.Chart.AppVersion }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
{{- end }}
{{- end -}}
{{- define "srs.labels.origin" -}}
srs-role: origin
{{ include "srs.labels.standard" . }}
{{- end -}}
{{- define "srs.labels.edge" -}}
srs-role: edge
{{ include "srs.labels.standard" . }}
{{- end -}}
{{- define "srs.labels.nginx" -}}
srs-role: nginx
{{ include "srs.labels.standard" . }}
{{- end -}}
{{- define "srs.labels.webrtc" -}}
srs-role: webrtc
{{ include "srs.labels.standard" . }}
{{- end -}}
{{- define "srs.labels.op" -}}
srs-role: op
{{ include "srs.labels.standard" . }}
{{- end -}}
{{/*
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
*/}}
{{- define "srs.matchLabels.origin" -}}
srs-role: origin
{{- end -}}
{{- define "srs.matchLabels.edge" -}}
srs-role: edge
{{- end -}}
{{- define "srs.matchLabels.nginx" -}}
srs-role: nginx
{{- end -}}
{{- define "srs.matchLabels.webrtc" -}}
srs-role: webrtc
{{- end -}}
{{- define "srs.matchLabels.op" -}}
srs-role: op
{{- end -}}

View File

@@ -0,0 +1,114 @@
{{- if .Values.enabled.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $deployName := .Values.deploy.name -}}
{{- $domain := ternary (first (regexSplit ":" .Values.global.domain.DeployDomainName -1)) ( .Values.global.domain.DeployDomainName ) (contains ":" .Values.global.domain.DeployDomainName) -}}
{{- $httpPort := ternary (last (regexSplit ":" .Values.global.domain.DeployDomainName -1)) ( 80 ) (contains ":" .Values.global.domain.DeployDomainName) -}}
{{- $rtmpPort := .Values.apps.srs.ports.rtmp }}
{{- $scheme := .Values.global.ingress.tls_enabled | ternary "https" "http" }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $deployName }}-cm
namespace: {{ $namespace }}
labels:
{{ include "srs.labels.standard" . | nindent 4 }}
data:
{{- if .Values.enabled.cluster }}
srs.origin.conf: |-
{{- include "srs.config.origin" . | nindent 4 }}
srs.edge.conf: |-
{{- include "srs.config.edge" . | nindent 4 }}
{{- else }}
srs.rtc.conf: |-
{{- include "srs.config.rtc" . | nindent 4 }}
{{- end }}
{{- if .Values.enabled.nginx }}
srs.nginx.conf: "empty"
{{- end }}
srs.op.conf: |-
debug: false
server:
port: 8080
spring:
application:
name: cmii-srs-operator
platform:
info:
name: cmii-live-srs-operator
description: cmii-live-srs-operator
version: 1.2.0
scanPackage: com.cmii.live
datasource:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://{{ .Values.apps.mysql.endpoint }}/cmii_live_srs_op?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: {{ .Values.apps.mysql.username }}
password: {{ .Values.apps.mysql.password }}
driver-class-name: com.mysql.cj.jdbc.Driver
boot:
admin:
client:
enabled: false
url: http://127.0.0.1:8888
instance:
service-url: http://127.0.0.1:8080
druid:
mysql:
usePingMethod: false
management:
endpoints:
enabled-by-default: true
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
live:
srs:
rtmp-base: "rtmp://{{ $domain }}:{{ $rtmpPort }}"
rtsp-base: "rtsp://{{ $domain }}:{{ .Values.apps.rtsp.ports.rtsp }}"
srt-base: "srt://{{ $domain }}:23333"
flv-base: "{{ $scheme }}://{{ $domain }}:{{ $httpPort }}"
rtc-base: "webrtc://{{ $domain }}:{{ $httpPort }}"
{{- if .Values.enabled.cluster }}
api-base: "http://{{ $deployName }}-origin-svc:{{ .Values.apps.srs.ports.api }}"
{{- else }}
api-base: "http://{{ $deployName }}-rtc-svc:{{ .Values.apps.srs.ports.api }}"
{{- end }}
hls:
max-ts: 200
interval-ms: 6000
minio:
endpoint: {{ .Values.apps.srs.oss.endpoint }}
access-key: {{ .Values.apps.srs.oss.ak }}
secret-key: {{ .Values.apps.srs.oss.sk }}
bucket: {{ .Values.apps.srs.oss.bucket }}
sync:
onStart: false
pool:
core: 8
max: 12
queue: 0
keepalive: 20
interval:
sync: 150
elect: 8
keepalive: 20
heartbeat: 8
logging:
level:
com.cmii.live.srs.mapper: info
---
{{- end}}

View File

@@ -0,0 +1,61 @@
{{- /*
{{- if .Values.enabled.cluster }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.deploy.name -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $applicationName }}-eg
namespace: {{ $namespace }}
labels:
{{- include "srs.labels.edge" . | nindent 4 }}
spec:
replicas: {{ .Values.apps.srs.replicas.edge }}
selector:
matchLabels:
{{- include "srs.matchLabels.edge" . | nindent 6 }}
template:
metadata:
labels:
{{- include "srs.labels.edge" . | nindent 8 }}
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
affinity:
{{- include "srs.affinity" . | nindent 8 }}
containers:
- name: srs
image: {{ .Values.apps.srs.image.srs.name }}:{{ .Values.apps.srs.image.srs.tag }}
resources:
limits:
memory: 4Gi
cpu: 1200m
requests:
memory: 256Mi
cpu: 100m
ports:
- name: srs-rtmp
containerPort: {{ .Values.apps.srs.ports.rtmp }}
protocol: TCP
- name: srs-api
containerPort: {{ .Values.apps.srs.ports.api }}
protocol: TCP
- name: srs-flv
containerPort: {{ .Values.apps.srs.ports.flv }}
protocol: TCP
volumeMounts:
- name: srs-conf-file
mountPath: /usr/local/srs/conf/docker.conf
subPath: docker.conf
volumes:
- name: srs-conf-file
configMap:
name: {{ $applicationName }}-cm
items:
- key: "srs.edge.conf"
path: "docker.conf"
---
{{- end -}}*/}}

View File

@@ -0,0 +1,98 @@
{{- /*
{{- if .Values.enabled.ingress }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.deploy.name -}}
{{- $domain := ternary (first (regexSplit ":" .Values.global.domain.DeployDomainName -1)) ( .Values.global.domain.DeployDomainName ) (contains ":" .Values.global.domain.DeployDomainName) -}}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $applicationName }}-ingress
namespace: {{ $namespace }}
labels:
{{- include "srs.labels.standard" . | nindent 4 }}
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($request_uri ~* ^/console){
return 403;
}
spec:
{{- if .Values.deploy.k8s.ingress.tls.enabled }}
tls:
- hosts:
- live.{{ $domain }}
- live-op.{{ $domain }}
- live-api.{{ $domain }}
{{- if .Values.enabled.nginx }}
- live-hls.{{ $domain }}
{{- end }}
secretName: x.{{ $domain }}-tls
{{- end }}
rules:
- host: live.{{ $domain }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
{{- if .Values.enabled.cluster }}
serviceName: {{ $applicationName }}-edge-svc
{{- else }}
serviceName: {{ $applicationName }}-rtc-svc
{{- end }}
servicePort: {{ .Values.apps.srs.ports.flv }}
- path: /rtc/v1
pathType: ImplementationSpecific
backend:
{{- if .Values.enabled.cluster }}
serviceName: {{ $applicationName }}-origin-svc
{{- else }}
serviceName: {{ $applicationName }}-rtc-svc
{{- end }}
servicePort: {{ .Values.apps.srs.ports.api }}
- host: live-op.{{ $domain }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: {{ $applicationName }}-op-svc
servicePort: 8080
- host: live-api.{{ $domain }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
{{- if .Values.enabled.cluster }}
serviceName: {{ $applicationName }}-origin-svc
{{- else }}
serviceName: {{ $applicationName }}-rtc-svc
{{- end }}
servicePort: {{ .Values.apps.srs.ports.api }}
{{- if .Values.enabled.nginx }}
- host: live-hls.{{ $domain }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
{{- if .Values.enabled.cluster }}
serviceName: {{ .Values.apps.srs.service.headless.og }}
{{- else }}
serviceName: {{ .Values.apps.srs.service.headless.rtc }}
{{- end }}
servicePort: {{ .Values.apps.srs.ports.flv }}
{{- end }}
---
{{- end }}*/}}

View File

@@ -0,0 +1,54 @@
{{- if .Values.enabled.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.deploy.name -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $applicationName }}-op
namespace: {{ $namespace }}
labels:
{{- include "srs.labels.op" . | nindent 4 }}
spec:
replicas: {{ .Values.apps.srs.replicas.op }}
selector:
matchLabels:
{{- include "srs.matchLabels.op" . | nindent 6 }}
template:
metadata:
labels:
{{- include "srs.labels.op" . | nindent 8 }}
spec:
imagePullSecrets:
- name: {{ .Values.deploy.harbor.secret }}
affinity:
{}
containers:
- name: operator
image: "{{ .Values.global.image.repository }}/{{ .Values.apps.srs.image.op }}"
imagePullPolicy: Always
resources:
limits:
memory: 4Gi
cpu: 4800m
requests:
memory: 256Mi
cpu: 100m
ports:
- name: operator
containerPort: 8080
protocol: TCP
volumeMounts:
- name: srs-conf-file
mountPath: /cmii/application.yaml
subPath: application.yaml
volumes:
- name: srs-conf-file
configMap:
name: "{{ $applicationName }}-cm"
items:
- key: "srs.op.conf"
path: "application.yaml"
---
{{- end }}

View File

@@ -0,0 +1,109 @@
{{- if and .Values.enabled.enabled .Values.enabled.cluster }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.deploy.name -}}
{{- $domain := ternary (first (regexSplit ":" .Values.global.domain.DeployDomainName -1)) ( .Values.global.domain.DeployDomainName ) (contains ":" .Values.global.domain.DeployDomainName) -}}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ $applicationName }}-og
namespace: {{ $namespace }}
labels:
{{- include "srs.labels.origin" . | nindent 4 }}
spec:
serviceName: srsog
replicas: {{ .Values.apps.srs.replicas.origin }}
selector:
matchLabels:
{{- include "srs.matchLabels.origin" . | nindent 6 }}
template:
metadata:
labels:
{{- include "srs.labels.origin" . | nindent 8 }}
spec:
imagePullSecrets:
- name: {{ .Values.deploy.harbor.secret }}
{{- /* affinity:*/}}
{{- /* {{- include "srs.affinity" . | nindent 8 }}*/}}
containers:
- name: srs
image: {{ .Values.apps.srs.image.srs }}
resources:
limits:
memory: 4Gi
cpu: 1200m
requests:
memory: 256Mi
cpu: 100m
ports:
- containerPort: {{ .Values.apps.srs.ports.rtmp }}
name: srs-rtmp
protocol: TCP
- containerPort: {{ .Values.apps.srs.ports.api }}
name: srs-api
protocol: TCP
{{- if lt .Values.apps.srs.replicas.origin 2.0 }}
- containerPort: {{ .Values.apps.srs.ports.rtc }}
name: srs-webrtc
protocol: UDP
{{- end }}
env:
- name: CANDIDATE
value: {{ $domain }}
volumeMounts:
- name: srs-conf-file
mountPath: /usr/local/srs/conf/docker.conf
subPath: docker.conf
- name: srs-vol
mountPath: /home/dvr
subPath: {{ $namespace }}/{{ $applicationName }}/dvr
- name: srs-vol
mountPath: /home/hls
subPath: {{ $namespace }}/{{ $applicationName }}/hls
- name: oss-adaptor
{{/* image: {{ .Values.apps.srs.image.oss }}*/}}
image: "{{ .Values.global.image.repository }}/{{ .Values.apps.srs.image.oss }}"
imagePullPolicy: Always
resources:
limits:
memory: 4Gi
cpu: 1200m
requests:
memory: 256Mi
cpu: 100m
env:
- name: OSS_ENDPOINT
value: {{ .Values.apps.srs.oss.endpoint }}
- name: OSS_AK
value: {{ .Values.apps.srs.oss.ak }}
- name: OSS_SK
value: {{ .Values.apps.srs.oss.sk }}
- name: OSS_BUCKET
value: {{ .Values.apps.srs.oss.bucket }}
- name: SRS_OP
value: "http://{{ $applicationName }}-op-svc:8080"
- name: MYSQL_ENDPOINT
value: {{ .Values.apps.mysql.endpoint }}
- name: MYSQL_USERNAME
value: {{ .Values.apps.mysql.username }}
- name: MYSQL_PASSWORD
value: {{ .Values.apps.mysql.password }}
volumeMounts:
- name: srs-vol
mountPath: /cmii/share/hls
subPath: "{{ $namespace }}/{{ $applicationName }}/hls"
volumes:
- name: srs-conf-file
configMap:
name: "{{ $applicationName }}-cm"
items:
- key: "srs.origin.conf"
path: "docker.conf"
- name: srs-vol
{{- include "srs.vol.main" . | nindent 10 }}
---
{{- end }}

View File

@@ -0,0 +1,151 @@
{{- if .Values.enabled.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.deploy.name -}}
{{- if and .Values.enabled.cluster ( not .Values.enabled.webrtc )}}
{{- /*
开启集群模式的情况
*/}}
---
{{/*
srsog: used to get srs-og stateful-set's ip.
*/}}
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.apps.srs.service.headless.og }}
namespace: {{ $namespace }}
spec:
type: ClusterIP
clusterIP: None
selector:
{{- include "srs.matchLabels.origin" . | nindent 4 }}
ports:
- name: srsog-rtmp
port: {{ .Values.apps.srs.ports.rtmp }}
targetPort: {{ .Values.apps.srs.ports.rtmp }}
- name: srsog-hls
port: {{ .Values.apps.srs.ports.flv }}
targetPort: {{ .Values.apps.srs.ports.flv }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $applicationName }}-origin-svc
namespace: {{ $namespace }}
spec:
type: NodePort
selector:
{{- include "srs.matchLabels.origin" . | nindent 4 }}
ports:
- name: srsog-api
port: {{ .Values.apps.srs.ports.api }}
targetPort: {{ .Values.apps.srs.ports.api }}
nodePort: {{ .Values.apps.srs.ports.api }}
{{- if lt .Values.apps.srs.replicas.origin 2.0 }}
- name: srsog-rtc
port: {{ .Values.apps.srs.ports.rtc }}
targetPort: {{ .Values.apps.srs.ports.rtc }}
nodePort: {{ .Values.apps.srs.ports.rtc }}
protocol: UDP
{{- end }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $applicationName }}-edge-svc
namespace: {{ $namespace }}
spec:
type: NodePort
selector:
{{- include "srs.matchLabels.edge" . | nindent 4 }}
ports:
- name: srseg-rtmp
port: {{ .Values.apps.srs.ports.rtmp }}
targetPort: {{ .Values.apps.srs.ports.rtmp }}
nodePort: {{ .Values.apps.srs.ports.rtmp }}
- name: srseg-flv
port: {{ .Values.apps.srs.ports.flv }}
targetPort: {{ .Values.apps.srs.ports.flv }}
nodePort: {{ .Values.apps.srs.ports.flv }}
{{- end }}
---
{{- if and .Values.enabled.webrtc (not .Values.enabled.cluster) }}
{{- /*
默认的模式! web-rtc
*/}}
---
{{/*
srsrtc: used to get srs-rtc stateful-set's ip.
*/}}
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.apps.srs.service.headless.rtc }}
namespace: {{ $namespace }}
spec:
type: ClusterIP
clusterIP: None
selector:
{{- include "srs.matchLabels.webrtc" . | nindent 4 }}
ports:
- name: srsrtc-rtmp
port: {{ .Values.apps.srs.ports.rtmp }}
targetPort: {{ .Values.apps.srs.ports.rtmp }}
- name: srsrtc-hls
port: {{ .Values.apps.srs.ports.flv }}
targetPort: {{ .Values.apps.srs.ports.flv }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $applicationName }}-rtc-svc
namespace: {{ $namespace }}
spec:
type: NodePort
selector:
{{- include "srs.matchLabels.webrtc" . | nindent 4 }}
ports:
- name: srs-rtmp
port: {{ .Values.apps.srs.ports.rtmp }}
targetPort: {{ .Values.apps.srs.ports.rtmp }}
nodePort: {{ .Values.apps.srs.ports.rtmp }}
- name: srs-api
port: {{ .Values.apps.srs.ports.api }}
targetPort: {{ .Values.apps.srs.ports.api }}
nodePort: {{ .Values.apps.srs.ports.api }}
- name: srs-rtc
port: {{ .Values.apps.srs.ports.rtc }}
targetPort: {{ .Values.apps.srs.ports.rtc }}
nodePort: {{ .Values.apps.srs.ports.rtc }}
protocol: UDP
- name: srs-flv
port: {{ .Values.apps.srs.ports.flv }}
targetPort: {{ .Values.apps.srs.ports.flv }}
nodePort: {{ .Values.apps.srs.ports.flv }}
{{- end }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $applicationName }}-op-svc
namespace: {{ $namespace }}
spec:
type: ClusterIP
selector:
{{- include "srs.matchLabels.op" . | nindent 4 }}
ports:
- port: 8080
targetPort: 8080
---
{{- end }}

View File

@@ -0,0 +1,105 @@
{{- if and .Values.enabled.enabled .Values.enabled.webrtc }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.deploy.name -}}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ $applicationName }}-rtc
namespace: {{ $namespace }}
labels:
{{- include "srs.labels.webrtc" . | nindent 4 }}
spec:
serviceName: srsrtc
replicas: {{ .Values.apps.srs.replicas.rtc }}
selector:
matchLabels:
{{- include "srs.matchLabels.webrtc" . | nindent 6 }}
template:
metadata:
labels:
{{- include "srs.labels.webrtc" . | nindent 8 }}
spec:
imagePullSecrets:
- name: {{ .Values.deploy.harbor.secret }}
affinity:
{{- /* nodeAffinity: {{- include "common.affinities.nodes" (dict "type" $.Values.global.nodeAffinityPreset.type "key" $.Values.global.nodeAffinityPreset.key "values" $.Values.global.nodeAffinityPreset.values) | nindent 10 -}}*/}}
containers:
- name: {{ $applicationName }}
image: "{{ .Values.global.image.repository }}/{{ .Values.apps.srs.image.srs }}"
resources:
limits:
memory: 4Gi
cpu: 1200m
requests:
memory: 256Mi
cpu: 100m
ports:
- name: srs-rtmp
containerPort: {{ .Values.apps.srs.ports.rtmp }}
protocol: TCP
- name: srs-api
containerPort: {{ .Values.apps.srs.ports.api }}
protocol: TCP
- name: srs-flv
containerPort: {{ .Values.apps.srs.ports.flv }}
protocol: TCP
- name: srs-webrtc
containerPort: {{ .Values.apps.srs.ports.rtc }}
protocol: UDP
env:
- name: CANDIDATE
value: "{{ .Values.deploy.domain }}"
volumeMounts:
- name: srs-conf-file
mountPath: /usr/local/srs/conf/docker.conf
subPath: docker.conf
- name: srs-vol
mountPath: /home/dvr
subPath: "{{ $namespace }}/{{ $applicationName }}/dvr"
- name: srs-vol
mountPath: /home/hls
subPath: "{{ $namespace }}/{{ $applicationName }}/hls"
- name: oss-adaptor
image: "{{ .Values.global.image.repository }}/{{ .Values.apps.srs.image.oss }}"
imagePullPolicy: Always
resources:
limits:
memory: 4Gi
cpu: 1200m
requests:
memory: 256Mi
cpu: 100m
env:
- name: OSS_ENDPOINT
value: {{ .Values.apps.srs.oss.endpoint }}
- name: OSS_AK
value: {{ .Values.apps.srs.oss.ak }}
- name: OSS_SK
value: {{ .Values.apps.srs.oss.sk }}
- name: OSS_BUCKET
value: {{ .Values.apps.srs.oss.bucket }}
- name: SRS_OP
value: "http://{{ $applicationName }}-op-svc:8080"
- name: MYSQL_ENDPOINT
value: {{ .Values.apps.mysql.endpoint }}
- name: MYSQL_USERNAME
value: {{ .Values.apps.mysql.username }}
- name: MYSQL_PASSWORD
value: {{ .Values.apps.mysql.password }}
volumeMounts:
- name: srs-vol
mountPath: /cmii/share/hls
subPath: {{ $namespace }}/{{ $applicationName }}/hls
volumes:
- name: srs-conf-file
configMap:
name: "{{ $applicationName }}-cm"
items:
- key: "srs.rtc.conf"
path: "docker.conf"
- name: srs-vol
{{- include "srs.vol.main" . | nindent 10 }}
---
{{- end }}