kubernetes 版本 v1.21.0
coturn部署yaml内容
Service.yaml
apiVersion: v1
kind: Service
metadata:
name: stun-turn
namespace: janus
labels:
app: stun-turn
spec:
selector:
app: stun-turn
ports:
- name: stun
protocol: TCP
port: 3478
targetPort: 3478
- name: stun-udp
protocol: UDP
port: 3478
targetPort: 3478
type: ClusterIP
DaemonSet.yaml文件内容
bash
apiVersion: v1
kind: Service
metadata:
name: stun-turn
namespace: janus
labels:
app: stun-turn
spec:
selector:
app: stun-turn
ports:
- name: stun
protocol: TCP
port: 3478
targetPort: 3478
- name: stun-udp
protocol: UDP
port: 3478
targetPort: 3478
type: ClusterIP
qinzhao@jumper02:~/janus/deployment/coturn$ cat DaemonSet.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: stun-turn
namespace: janus
spec:
selector:
matchLabels:
app: stun-turn
template:
metadata:
labels:
app: stun-turn
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: stun-turn
image: instrumentisto/coturn
imagePullPolicy: IfNotPresent
env:
- name: TZ
value: "UTC"
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 0
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 0
namespace yaml文件
bash
apiVersion: v1
kind: Namespace
metadata:
labels:
kubernetes.io/metadata.name: janus
name: janus
spec:
finalizers:
- kubernetes
janus
Service.yaml
bash
apiVersion: v1
kind: Service
metadata:
name: janus-svc
namespace: janus
spec:
selector:
app: janus
ports:
- name: http
port: 8088
targetPort: 8088
- name: websocket
port: 8188
targetPort: 8188
- name: webrtc
port: 7088
targetPort: 7088
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: janus-stream
namespace: janus
labels:
app: janus
spec:
selector:
app: janus
ports:
- name: stream1-video
protocol: UDP
port: 9000
targetPort: 9000
- name: stream1-data
protocol: UDP
port: 9001
targetPort: 9001
- name: stream1-audio
protocol: UDP
port: 9002
targetPort: 9002
- name: stream2-video
protocol: UDP
port: 9003
targetPort: 9003
- name: stream2-data
protocol: UDP
port: 9004
targetPort: 9004
- name: stream2-audio
protocol: UDP
port: 9005
targetPort: 9005
type: ClusterIP
ConfigMap.yaml
bash
kind: ConfigMap
metadata:
name: janus-config
namespace: janus
apiVersion: v1
data:
janus.jcfg: |-
general: {
configs_folder = "/usr/local/etc/janus"
plugins_folder = "/usr/local/lib/janus/plugins"
transports_folder = "/usr/local/lib/janus/transports"
events_folder = "/usr/local/lib/janus/events"
loggers_folder = "/usr/local/lib/janus/loggers"
debug_level = 4
protected_folders = [
"/bin",
"/boot",
"/dev",
"/etc",
"/initrd",
"/lib",
"/lib32",
"/lib64",
"/proc",
"/sbin",
"/sys",
"/usr",
"/var",
"/opt/janus/bin",
"/opt/janus/etc",
"/opt/janus/include",
"/opt/janus/lib",
"/opt/janus/lib32",
"/opt/janus/lib64",
"/opt/janus/sbin"
]
}
nat: {
stun_server = "stun-turn"
stun_port = 3478
}
janus.plugin.streaming.jcfg: |-
general: {
threads = 8
}
stream1: {
type = "rtp"
id = 1
description = "streamingroom-1"
audio = true
video = true
data = true
videopt = 100
videortpmap = "VP8/90000"
videoport = 9000
dataport = 9001
audioport = 9002
audiopt = 111
}
stream2: {
type = "rtp"
id = 2
description = "streamingroom2"
audio = true
video = true
data = true
videopt = 100
videortpmap = "VP8/90000"
videoport = 9003
dataport = 9004
audioport = 9005
audiopt = 111
}
DaemonSet.yaml文件
bash
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: janus
namespace: janus
spec:
selector:
matchLabels:
app: janus
template:
metadata:
labels:
app: janus
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
volumes:
- name: janus-config
configMap:
name: janus-config
containers:
- name: janus
image: canyan/janus-gateway:0.10.7
imagePullPolicy: IfNotPresent
env:
- name: TZ
value: "UTC"
volumeMounts:
- name: janus-config
mountPath: /usr/local/etc/janus/janus.jcfg
subPath: janus.jcfg
- name: janus-config
mountPath: /usr/local/etc/janus/janus.plugin.streaming.jcfg
subPath: janus.plugin.streaming.jcfg
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 0
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 0
nginx-janus
Service.yaml
bash
apiVersion: v1
kind: Service
metadata:
name: nginx-janus-svc
namespace: janus
spec:
selector:
app: nginx-janus
ports:
- name: http
port: 8088
targetPort: 8088
- name: websocket
port: 8188
targetPort: 8188
- name: webrtc
port: 7088
targetPort: 7088
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: nginx-janus-stats-svc
spec:
selector:
app: nginx-janus
ports:
- name: http
port: 3000
targetPort: 3000
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: nginx-janus-stream
labels:
app: nginx-janus
spec:
selector:
app: nginx-janus
ports:
- name: stream1-video
protocol: UDP
port: 9000
targetPort: 9000
- name: stream1-data
protocol: UDP
port: 9001
targetPort: 9001
- name: stream1-audio
protocol: UDP
port: 9002
targetPort: 9002
- name: stream2-video
protocol: UDP
port: 9003
targetPort: 9003
- name: stream2-data
protocol: UDP
port: 9004
targetPort: 9004
- name: stream2-audio
protocol: UDP
port: 9005
targetPort: 9005
type: ClusterIP
Configmap.yaml
bash
kind: ConfigMap
metadata:
name: nginx-janus-config
namespace: janus
apiVersion: v1
data:
nginx.conf: |-
worker_processes 10;
events {
worker_connections 1024;
}
http{
server {
listen 3000;
location /nginx_status {
stub_status on;
access_log off;
allow 0.0.0.0;
}
}
}
stream {
server {
listen 8188;
proxy_pass janus-ws;
}
upstream janus-ws{
server janus-svc:8188;
}
server {
listen 8088;
proxy_pass janus-http;
}
upstream janus-http{
server janus-svc:8088;
}
server {
listen 7088;
proxy_pass janus-webrtc;
}
upstream janus-webrtc{
server janus-svc:7088;
}
server {
listen 9000 udp;
proxy_pass streamingroom1v;
}
upstream streamingroom1v{
server janus-stream:9000;
}
server {
listen 9001 udp;
proxy_pass streamingroom1d;
}
upstream streamingroom1d{
server janus-stream:9001;
}
server {
listen 9002 udp;
proxy_pass streamingroom1a;
}
upstream streamingroom1a{
server janus-stream:9002;
}
server {
listen 9003 udp;
proxy_pass streamingroom2v;
}
upstream streamingroom2v{
server janus-stream:9003;
}
server {
listen 9004 udp;
proxy_pass streamingroom2d;
}
upstream streamingroom2d{
server janus-stream:9004;
}
server {
listen 9005 udp;
proxy_pass streamingroom2a;
}
upstream streamingroom2a{
server janus-stream:9005;
}
}
Deployment.yaml
bash
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-janus
namespace: janus
spec:
selector:
matchLabels:
app: nginx-janus
replicas: 1
template:
metadata:
labels:
app: nginx-janus
spec:
volumes:
- name: nginx-janus-config
configMap:
name: nginx-janus-config
containers:
- name: janus
image: nginx
imagePullPolicy: IfNotPresent
env:
- name: TZ
value: "UTC"
volumeMounts:
- name: nginx-janus-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 0
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 0
janus-ingress.yaml
bash
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: janus
namespace: janus
spec:
ingressClassName: kong
rules:
- host: janus-webrtc.domain.com
http:
paths:
- backend:
service:
name: nginx-janus-svc
port:
number: 7088
path: /
pathType: ImplementationSpecific
- host: janus-websocket.domain.com
http:
paths:
- backend:
service:
name: nginx-janus-svc
port:
number: 8188
path: /
pathType: ImplementationSpecific
- host: janus-http.domain.com
http:
paths:
- backend:
service:
name: nginx-janus-svc
port:
number: 8088
path: /
pathType: ImplementationSpecific
通过以上文件 使用kubectl 进行apply 就可以部署成功了
参考: