<p>I have a docker container used to convert the flux of my webcam into rtsp (docker image: <code>ullaakut/rtspatt</code>). It work well when I use <code>--device /dev/video0:/dev/video0</code>.</p>

<p>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 ?</p>

<p>Currently there is no configuration option which would enable to use <code>--device</code> in Kubernetes.</p>
<p>See these discussions for more details:
<a href="https://github.com/kubernetes/kubernetes/issues/5607" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/5607</a>
<a href="https://github.com/kubernetes/kubernetes/issues/60748" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/60748</a></p>
<p>However, you might be able to use host devices if you enable the privileged mode for the pod.</p>
<p><a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/#privileged" rel="noreferrer">https://kubernetes.io/docs/concepts/policy/pod-security-policy/#privileged</a></p>
<blockquote>
<p>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.</p>
</blockquote>
<pre><code>containers:
- name: foo
  volumeMounts:
  - mountPath: /dev/video0
    name: dev-video0
  securityContext:
    privileged: true
volumes:
- name: dev-video0
  hostPath:
    path: /dev/video0
</code></pre>
<p>Not sure though if you really need the <code>volumeMounts</code> and <code>volumes</code>. Just try and see if it works without them.</p>
<p><strong>Using <code>privileged: true</code> is not really ideal from a security point of view.</strong></p>
<p>You should also set the <code>nodeName</code> property on the pod, so it'll always run on one specific node (this node will have the camera attached).</p>
<hr />
<p>An alternative solution might be to use plugins: <a href="https://github.com/bluebeach/k8s-hostdev-plugin" rel="noreferrer">https://github.com/bluebeach/k8s-hostdev-plugin</a>.</p>
