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

[🐛 Bug]: Not being able to record session using selenium ffmpeg4 in kubernetes #2644

Open
rgeko opened this issue Feb 6, 2025 · 6 comments

Comments

@rgeko
Copy link

rgeko commented Feb 6, 2025

What happened?

I'm trying to record a session using selenium ffmpeg4 in kubernetes but the video pod fails to record (output is in logs below).

The Kubernetes deployment and services files are the following
`
apiVersion: v1
kind: PersistentVolume
metadata:
name: selenium-outputs-pv
spec:
capacity:
storage: 5Gi # Combined storage
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: selenium-storage
hostPath:
path: /mnt/data/selenium-outputs # Single storage location


apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: selenium-outputs-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
storageClassName: selenium-storage


apiVersion: apps/v1
kind: Deployment
metadata:
name: selenium-node-chrome
labels:
app: selenium
spec:
replicas: 1
selector:
matchLabels:
app: selenium-node-chrome
template:
metadata:
labels:
app: selenium-node-chrome
spec:
containers:
- name: selenium-node-chrome
image: selenium/node-chrome:120.0.6099.62-chromedriver-120.0.6099.62
ports:
- containerPort: 5555
name: bind
- containerPort: 5900
name: vnc
- containerPort: 7900
name: no-vnc
env:
- name: SE_NODE_HOST
value: "selenium-node-chrome"
- name: SE_EVENT_BUS_HOST
value: "selenium-hub"
- name: SE_EVENT_BUS_PUBLISH_PORT
value: "4442"
- name: SE_EVENT_BUS_SUBSCRIBE_PORT
value: "4443"
volumeMounts:
- mountPath: /dev/shm
name: dshm
- mountPath: /home/seluser/Downloads
name: selenium-outputs
subPath: downloads
volumes:
- name: dshm
emptyDir: {}
- name: selenium-outputs
persistentVolumeClaim:
claimName: selenium-outputs-pvc


apiVersion: apps/v1
kind: Deployment
metadata:
name: chrome-video
labels:
app: selenium
spec:
replicas: 1
selector:
matchLabels:
app: chrome-video
template:
metadata:
labels:
app: chrome-video
spec:
containers:
- name: chrome-video
image: selenium/video:ffmpeg-4.3.1-20230421
env:
- name: DISPLAY_CONTAINER_NAME
value: "selenium-node-chrome"
- name: FILE_NAME
value: "chrome_video.mp4"
- name: SE_SCREEN_WIDTH
value: "1920"
- name: SE_SCREEN_HEIGHT
value: "1080"
volumeMounts:
- name: selenium-outputs
mountPath: /videos
subPath: videos
volumes:
- name: selenium-outputs
persistentVolumeClaim:
claimName: selenium-outputs-pvc


apiVersion: apps/v1
kind: Deployment
metadata:
name: selenium-hub
labels:
app: selenium
spec:
replicas: 1
selector:
matchLabels:
app: selenium-hub
template:
metadata:
labels:
app: selenium-hub
spec:
containers:
- name: selenium-hub
image: selenium/hub:4.19.0
ports:
- containerPort: 4442
- containerPort: 4443
- containerPort: 4444
livenessProbe:
httpGet:
path: /status
port: 4444
initialDelaySeconds: 10
periodSeconds: 15
timeoutSeconds: 30
readinessProbe:
httpGet:
path: /status
port: 4444
initialDelaySeconds: 5
periodSeconds: 10

apiVersion: v1
kind: Service
metadata:
name: selenium-hub
spec:
selector:
app: selenium-hub
ports:
- name: event-bus-publish
port: 4442
- name: event-bus-subscribe
port: 4443
- name: webdriver
port: 4444
type: ClusterIP


apiVersion: v1
kind: Service
metadata:
name: selenium-node-chrome
spec:
selector:
app: selenium-node-chrome
ports:
- name: bind
port: 5555
targetPort: 5555
- name: vnc
protocol: TCP
port: 5900 # Internal service port
targetPort: 5900 # Container port
- name: no-vnc
port: 7900
type: ClusterIP
`

Command used to start Selenium Grid with Docker (or Kubernetes)

kubectl apply -f selenium

Relevant log output

Waiting before next display check...
Waiting before next display check...
Waiting before next display check...
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[x11grab @ 0x558641e60b80] Cannot open display selenium-node-chrome:99.0, error 1.
selenium-node-chrome:99.0: Input/output error
2025-02-06 16:03:31,421 INFO exited: video-recording (exit status 1; not expected)

Operating System

Kubernetes

Docker Selenium version (image tag)

selenium/video:ffmpeg-4.3.1-20230421

Selenium Grid chart version (chart version)

No response

Copy link

github-actions bot commented Feb 6, 2025

@rgeko, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@VietND96
Copy link
Member

VietND96 commented Feb 6, 2025

I see you are deploy video and node in separate pod, and video connect to node using service name
Ensure that in deployment of Node, it expose container port 99, and Node service also expose port 99

@rgeko
Copy link
Author

rgeko commented Feb 7, 2025

It did not work, unfortunately, still getting the same error.

added port to both depl and service
apiVersion: apps/v1
kind: Deployment
metadata:
name: selenium-node-chrome
labels:
app: selenium
spec:
replicas: 1
selector:
matchLabels:
app: selenium-node-chrome
template:
metadata:
labels:
app: selenium-node-chrome
spec:
containers:
- name: selenium-node-chrome
image: selenium/node-chrome:120.0.6099.62-chromedriver-120.0.6099.62
ports:
- containerPort: 5555
name: bind
- containerPort: 5900
name: vnc
- containerPort: 7900
name: no-vnc
- containerPort: 99
name: streaming
env:
- name: SE_NODE_HOST
value: "selenium-node-chrome"
- name: SE_EVENT_BUS_HOST
value: "selenium-hub"
- name: SE_EVENT_BUS_PUBLISH_PORT
value: "4442"
- name: SE_EVENT_BUS_SUBSCRIBE_PORT
value: "4443"
volumeMounts:
- mountPath: /dev/shm
name: dshm
- mountPath: /home/seluser/Downloads
name: selenium-outputs
subPath: downloads
volumes:
- name: dshm
emptyDir: {}
- name: selenium-outputs
persistentVolumeClaim:
claimName: selenium-outputs-pvc


apiVersion: v1
kind: Service
metadata:
name: selenium-node-chrome
spec:
selector:
app: selenium-node-chrome
ports:
- name: bind
port: 5555
targetPort: 5555
- name: vnc
protocol: TCP
port: 5900 # Internal service port
targetPort: 5900 # Container port
- name: no-vnc
port: 7900
targetPort: 7900
- name: streaming
port: 99
targetPort: 99
type: ClusterIP

Out of curiosity, what is port 99 needed for?

@VietND96
Copy link
Member

VietND96 commented Feb 7, 2025

Actually, it is xvfb display port (default is 99) which started in this https://github.com/SeleniumHQ/docker-selenium/blob/trunk/NodeBase/start-xvfb.sh
What if you define both node and video containers in the same deployment yaml (Pod)? Then those communicate internally. If it works, the network at cluster level does not allow streaming protocol

@rgeko
Copy link
Author

rgeko commented Feb 7, 2025

Also this does not work.. I've added video container to node pod, and also exposed port 99, but i'm getting the same error.

apiVersion: apps/v1
kind: Deployment
metadata:
name: selenium-node-chrome
labels:
app: selenium
spec:
replicas: 1
selector:
matchLabels:
app: selenium-node-chrome
template:
metadata:
labels:
app: selenium-node-chrome
spec:
containers:
- name: selenium-node-chrome
image: selenium/node-chrome:120.0.6099.62-chromedriver-120.0.6099.62
ports:
- containerPort: 5555
name: bind
- containerPort: 5900
name: vnc
- containerPort: 7900
name: no-vnc
- containerPort: 99
name: xvfb
env:
- name: SE_NODE_HOST
value: "selenium-node-chrome"
- name: SE_EVENT_BUS_HOST
value: "selenium-hub"
- name: SE_EVENT_BUS_PUBLISH_PORT
value: "4442"
- name: SE_EVENT_BUS_SUBSCRIBE_PORT
value: "4443"
volumeMounts:
- mountPath: /dev/shm
name: dshm
- mountPath: /home/seluser/Downloads
name: selenium-outputs
subPath: downloads
- name: chrome-video
image: selenium/video:ffmpeg-4.3.1-20230421
env:
- name: DISPLAY_CONTAINER_NAME
value: "selenium-node-chrome"
- name: FILE_NAME
value: "chrome_video.mp4"
- name: SE_SCREEN_WIDTH
value: "1920"
- name: SE_SCREEN_HEIGHT
value: "1080"
volumeMounts:
- name: selenium-outputs
mountPath: /videos
subPath: videos
volumes:
- name: dshm
emptyDir: {}
- name: selenium-outputs
persistentVolumeClaim:
claimName: selenium-outputs-pvc

@rgeko
Copy link
Author

rgeko commented Feb 7, 2025

is there some example around of using selenium video with k8? I could not find any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants