Configure the Generic Device Plugin
|
|
The Generic Device Plugin for MicroShift is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope. |
The Generic Device Plugin (GDP) is disabled by default in MicroShift. To use the GDP, you must enable it and specify which host devices your Kubernetes applications can access. To enable the GDP, you must modify the MicroShift config.yaml file or create a configuration snippet file. For example, /etc/microshift/config.d/10-gdp.yaml.
-
You installed MicroShift.
-
You created a custom
config.yamlfile in the/etc/microshiftdirectory. -
You installed the OpenShift CLI (
oc). -
You have
sudoprivileges on the MicroShift host. -
You have identified the specific host devices that you want to expose to your MicroShift node. For example,
/dev/video0,/dev/ttyUSB*, or USB Vendor/Product IDs.
-
From your CLI using
sudoprivileges, open/etc/microshift/config.yamlin a text editor. -
Locate the
genericDevicePluginsection. If it is not present, add it. -
Set the
statusparameter toEnabledand define thedevicesthat should be exposed. Each device definition needs anameand one or moregroups. Each group can specify devices usingpaths, for file-based devices, including glob patterns, orusbs, for USB devices using Vendor/Product IDs. You cannot mixpathsandusbswithin the same device group.GDP fields with default valuesapiServer: # ... genericDevicePlugin: devices: - groups: - paths: - path: /dev/ttyUSB*- path: /dev/ttyACM*
name: serial - groups: - paths: - path: /dev/fuse
name: fuse
- groups: - usbs:
- product: "0x7523"
serial: "" vendor: "0x1a86"
name: converter domain: device.microshift.io
status: Enabled
Exposes all the USB serial devices that are matched by this glob. Exposes all the ACM serial devices that are matched by this glob. For example, the file path for a fuse device. For example, the name of the device. Exposes a specific USB device by Vendor ID and Product ID. For example, the Product ID for a CH340 serial converter For example, the Vendor ID for a CH340 serial converter. Default domain for the GDP. -
The output of the
microshift show-configparameter might include pre-configured default paths for serial devices even if you have not explicitly configured them inconfig.yaml. These paths represent the default discovery settings if the Generic Device Plugin is enabled without specific user configuration. -
For consistency and precise device targeting, especially when dealing with multiple similar devices, consider using stable device paths like
/dev/serial/by-id/or specific USB Vendor, Product, or Serial IDs instead of broad glob patterns like/dev/ttyUSB*. -
The
countparameter in a device group allows a single device, or a set of devices matched by a glob, to be allocated multiple times concurrently to different pods. If omitted,countdefaults to1.
-
-
Save the
config.yamlfile. -
Restart the MicroShift service to apply the changes:
$ sudo systemctl restart microshiftAllow some time for MicroShift to restart and for the GDP to register its devices with the Kubelet.
-
You can check the available devices in your node by running the following command:
$ oc describe node <microshift_node_name> | grep "device.microshift.io"Replace <microshift_node_name> with your node name. -
Depending on your configuration, expect output that indicates that the devices are now discoverable and schedulable within your MicroShift node.
Example outputCapacity: cpu: 2 device.microshift.io/audio: 0 device.microshift.io/capture: 0 device.microshift.io/custom-device: 1 device.microshift.io/dummy-video: 0 device.microshift.io/fuse: 0 device.microshift.io/serial: 5 device.microshift.io/video: 0 Allocatable: cpu: 2 device.microshift.io/audio: 0 device.microshift.io/capture: 0 device.microshift.io/custom-device: 1 device.microshift.io/dummy-video: 0 device.microshift.io/fuse: 0 device.microshift.io/serial: 5 device.microshift.io/video: 0 Allocated resources: (Total limits may be over 100 percent, i.e., overcommitted.) Resource Requests Limits -------- -------- ------ cpu 450m (22%) 500m (25%) memory 1550Mi (42%) 500Mi (13%) ephemeral-storage 0 (0%) 0 (0%) hugepages-1Gi 0 (0%) 0 (0%) hugepages-2Mi 0 (0%) 0 (0%) device.microshift.io/audio 0 0 device.microshift.io/capture 0 0 device.microshift.io/custom-device 1 1 device.microshift.io/dummy-video 1 1 device.microshift.io/fuse 0 0 device.microshift.io/serial 0 0 device.microshift.io/video 0 0