如何在Kubernetes上使用--device / dev / video0? [英] How to use --device /dev/video0 with kubernetes?

查看:684
本文介绍了如何在Kubernetes上使用--device / dev / video0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

有关更多详细信息,请参见以下讨论:
https://github.com/kubernetes/kubernetes/issues/5607
https://github.com/kubernetes/kubernetes/issues/60748

See these discussions for more details: https://github.com/kubernetes/kubernetes/issues/5607 https://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.

https://kubernetes.io/docs/concepts/policy/pod-security-policy/#privileged


容器几乎与主机上运行的进程具有相同的访问权限。这对于想要使用Linux功能(如操纵网络堆栈和访问设备)的容器很有用。

This allows the container nearly all the same access as processes running on the host. This is useful for containers that want to use linux capabilities like manipulating the network stack and accessing devices.



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).

另一种解决方案可能是使用插件: https://github.com/honkiko/k8s-hostdev-plugin

An alternative solution might be to use plugins: https://github.com/honkiko/k8s-hostdev-plugin.

这篇关于如何在Kubernetes上使用--device / dev / video0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆