Mediamtx webrtc stream is not accessible while running inside k8s cluster in minikube
I running a mediatmx server on minikube kubernetes cluster. I am passing a rtsp stream as input to the mediamtx server through mediamtx config file as path entry.
Now I am trying to access the corresponding Webrtc stream locally from my browser, by using kubectl port forward to forward mediamtx service to localhost. But I am not able to access the webrtc stream from the browser
Steps to recreate the Issue
- Create minikube cluster.
- Deploy mediamtx Deployment, Service and Config Map
The Config map include custom mediamtx.yml config
Mediamtx Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: mediamtx
labels:
app: mediamtx
spec:
replicas: 1
selector:
matchLabels:
app: mediamtx
template:
metadata:
labels:
app: mediamtx
spec:
containers:
-
name: mediamtx
image: bluenviron/mediamtx
args: [“/mediamtx.yml”] # Explicitly specify the config file location
volumeMounts: -
name: config
mountPath: /mediamtx.yml
subPath: mediamtx.yml
ports: -
containerPort: 8554
-
containerPort: 1935
-
containerPort: 8888
-
containerPort: 8889
-
containerPort: 8890
-
containerPort: 8189
env: -
name: MTX_PROTOCOLS
value: “tcp” -
name: MTX_WEBRTCADDITIONALHOSTS
value: “172.19.0.1”volumes:
- name: config
configMap:
name: mediamtx-config
defaultMode: 0644 # Ensure the file is readable
Mediamtx Service
apiVersion: v1
kind: Service
metadata:
name: mediamtx
spec:
type: ClusterIP
ports:
- name: config
name: rtsp
port: 8554
targetPort: 8554
protocol: TCP
name: rtmp
port: 1935
targetPort: 1935
protocol: TCP
name: web
port: 8888
targetPort: 8888
protocol: TCP
name: web-rtc
port: 8889
targetPort: 8889
protocol: TCP
name: rtsp-udp
port: 8890
targetPort: 8890
protocol: UDP
name: udp-extra
port: 8189
targetPort: 8189
protocol: UDP
selector:
app: mediamtx
mediamtx config map
apiVersion: v1
kind: ConfigMap
metadata:
name: mediamtx-config
data:
mediamtx.yml: |
Your custom MediaMTX configuration goes here
webrtcICEServers2:
– url: stun:stun2.1.google.com:19302
paths:
example:
mycamera:
source: rtsp://admin:[email protected]:554/unicaststream/1
all_others:
-
The Config map includes custom mediamtx configuration. I have added a default rtsp stream path entry to it, And trying to access the corresponding webrtc streams.
-
Apply all resources, wait for medamtx pod to start. Expose mediamtx service using kubectl port-forward
Now the webrtc stream should be accessible at http://localhost:8889/mycamera, But I am not able to access it
Sharan phadke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1