问题描述
我有一个docker容器,用于将网络摄像头的流量转换为rtsp(docker图像: ullaakut / rtspatt
)。当我使用-device / dev / video0:/ dev / video0
时效果很好。
I have a docker container used to convert the flux of my webcam into rtsp (docker image: ullaakut/rtspatt
). It work well when I use --device /dev/video0:/dev/video0
.
但是我确实找不到任何帮助我使用Kubernetes进行相同操作的东西。我只想要一种从容器访问网络摄像头的方法...有人可以帮助我吗?
But I did not found anything helping me to do the same using Kubernetes. I just want a way to access the webcam from the container... Anyone can help me ?
推荐答案
当前没有任何配置选项,可以在Kubernetes中使用-device
。
Currently there is no configuration option which would enable to use --device
in Kubernetes.
有关更多详细信息,请参见以下讨论:
See these discussions for more details:https://github.com/kubernetes/kubernetes/issues/5607https://github.com/kubernetes/kubernetes/issues/60748
但是,如果为pod启用了特权模式,则可以使用主机设备。
However, you might be able to use host devices if you enable the privileged mode for the pod.
containers:
- name: foo
volumeMounts:
- mountPath: /dev/video0
name: dev-video0
securityContext:
privileged: true
volumes:
- name: dev-video0
hostPath:
path: /dev/video0
不确定是否确实需要 volumeMounts
和 volumes
。只是尝试看看如果没有它们,它是否有效。
Not sure though if you really need the volumeMounts
and volumes
. Just try and see if it works without them.
从安全角度考虑,使用 privileged:正确
并不理想。
Using privileged: true
is not really ideal from a security point of view.
您还应该在Pod上设置 nodeName
属性,以便它始终在一个特定节点上运行(
You should also set the nodeName
property on the pod, so it'll always run on one specific node (this node will have the camera attached).
另一种解决方案可能是使用插件:。
An alternative solution might be to use plugins: https://github.com/honkiko/k8s-hostdev-plugin.
这篇关于如何在Kubernetes上使用--device / dev / video0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!