-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
v4_EN_K8S
Cloud+Docker+K8S enable everyone to build live video streaming cluster and service.
Why should you use k8s to build your SRS cluster?
- Simple: It's really simple and convenient, let's figure it out by QuickStart.
- Declarative deployment: We declare a desired SRS cluster and it'll always be there, without starting and migrating service, watchdog and SLB configuration.
- Expand easily: K8S allows you to expand infrastructure automatically, and you can expand your business cluster easily by change the number of Pods.
- XXX: Coming soon...
This tutorial highlights how to build SRS cluster for a variety of scenarios in ACK(AlibabaCloud Container Service for Kubernetes).
- Quick Start: Deployment a SRS origin server in ACK.
- SRS Shares Volume with Nginx: SRS is able to deliver simple HTTP content, or work with Nginx, SRS delivers RTMP/HTTP-FLV and write HLS to a share volume, then Nginx reads and delivers HLS.
- SRS Edge Cluster for High Concurrency Streaming: SRS edge cluster, which is configured and updated automatically, to provide services for huge players.
- SRS Origin Cluster for a Large Number of Streams: SRS origin cluster is designed to serve a large number of streams.
-
Useful Tips
- Create K8S Cluster in ACK: Create your own k8s cluster in ACK.
- Publish Demo Streams to SRS: Publish the demo streams to SRS.
- Cleanup For DVR/HLS Temporary Files: Remove the temporary files for DVR/HLS.
- Use One SLB and EIP for All Streaming Service: Use one SLB for RTMP/HTTP-FLV/HLS streaming service.
- XXX: Coming soon...
Assumes you have access to a k8s cluster, you can easily create one in Aliyun, say the following command should succeed:
kubectl cluster-info
Let's take a look at a single SRS origin server in k8s.
Step 1: Create a k8s deployment for SRS origin server:
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: srs-deployment
labels:
app: srs
spec:
replicas: 1
selector:
matchLabels:
app: srs
template:
metadata:
labels:
app: srs
spec:
containers:
- name: srs
image: ossrs/srs:3
ports:
- containerPort: 1935
- containerPort: 1985
- containerPort: 8080
EOF
Step 2: Create a k8s service which exposing live video streaming service by SLB with EIP:
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: srs-service
spec:
type: LoadBalancer
selector:
app: srs
ports:
- name: srs-service-1935-1935
port: 1935
protocol: TCP
targetPort: 1935
- name: srs-service-1985-1985
port: 1985
protocol: TCP
targetPort: 1985
- name: srs-service-8080-8080
port: 8080
protocol: TCP
targetPort: 8080
EOF
Here we create SLB and EIP automatically, you can also buy from AlibabaCloud to provide service, for example:
Then you can use your intranet SLB:
metadata:
annotations:
service.beta.kubernetes.io/alicloud-loadbalancer-address-type: intranet
service.beta.kubernetes.io/alicloud-loadbalancer-force-override-listeners: "true"
service.beta.kubernetes.io/alicloud-loadbalancer-id: lb-2xxyfvpao868wzfvcmx7b
Remark: The SLB should be in the same VPC with your K8S cluster.
Step 3: Done, you could get the EIP and play with SRS now.
Please use kubectl get svc/srs-service
to get the EIP:
NAME TYPE CLUSTER-IP EXTERNAL-IP
srs-service LoadBalancer 172.21.12.131 28.170.32.118
Then you can publish and play with 28.170.32.118
:
- Publish RTMP to
rtmp://28.170.32.118/live/livestream
- Play RTMP from rtmp://28.170.32.118/live/livestream
- Play HTTP-FLV from http://28.170.32.118:8080/live/livestream.flv
- Play HLS from http://28.170.32.118:8080/live/livestream.m3u8
Coming soon...
Coming soon...
Coming soon...
There are some useful tips for you.
- Create K8S Cluster in ACK: Create your own k8s cluster in ACK.
- Publish Demo Streams to SRS: Publish the demo streams to SRS.
- Use One SLB and EIP for All Streaming Service: Use one SLB for RTMP/HTTP-FLV/HLS streaming service.
Coming soon...
Coming soon...
Coming soon...
Winlin 2020.02
Welcome to SRS wiki!
Please select your language:
Please select your language:
Please select your language:
Please select your language:
Please select your language: