When a serial port is created in a docker container mapped on a host with an operating system of Linux, this is done with the ‘—device’
flag;
e.g. docker run -dit --device=/dev/ttyUSB0 --name SerialTest <docker image>
We would like to know how PODs can be mapped serial ports in Kubernetes. The figure below shows the Pod configuration for the application to be deployed in Rancher 2.x.
(https://i.imgur.com/RHhlD4S.png)
In node scheduling, we have configured pods to be distributed to specific nodes with serial ports. Also, it is of course not possible to map the serial port with the volume mount. So, I would like to raise a question because I couldn't find anything related to ‘—device’
flag of docker in my Rancher 2.x configuration.
(https://imgur.com/wRe7Eds.png) "Application configuration in Rancher 2.x"
(https://imgur.com/Lwil7cz.png) "Serial port device connected to the HOST PC"
(https://imgur.com/oWeW0LZ.png) "Volume Mount Status of Containers in Deployed Pods"
(https://imgur.com/GKahqY0.png) "Error log when running a .NET application that uses a serial port"
Based on the goal of the first diagram: Kubernetes abstractions covering the communication between the pod and the outside world (for this matter, outside of the node) are meant to handle at least layer 2 communications (veth, as in inter-node/pod communication).
Is not detailed why is not possible to map the device volume in the pod, so I'm wondering if you have tried using privileged containers like in this reference:
containers:
- name: acm
securityContext:
privileged: true
volumeMounts:
- mountPath: /dev/ttyACM0
name: ttyacm
volumes:
- name: ttyacm
hostPath:
path: /dev/ttyACM0
It is possible for Rancher to start containers in privileged mode.