Configure the Generic Device Plugin

Important

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.

Prerequisites
  • You installed MicroShift.

  • You created a custom config.yaml file in the /etc/microshift directory.

  • You installed the OpenShift CLI (oc).

  • You have sudo privileges 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.

Procedure
  1. From your CLI using sudo privileges, open /etc/microshift/config.yaml in a text editor.

  2. Locate the genericDevicePlugin section. If it is not present, add it.

  3. Set the status parameter to Enabled and define the devices that should be exposed. Each device definition needs a name and one or more groups. Each group can specify devices using paths, for file-based devices, including glob patterns, or usbs, for USB devices using Vendor/Product IDs. You cannot mix paths and usbs within the same device group.

    GDP fields with default values
    apiServer:
    # ...
    genericDevicePlugin:
      devices:
      - groups:
        - paths:
          - path: /dev/ttyUSB* 1
          - path: /dev/ttyACM* 2
        name: serial
      - groups:
        - paths:
          - path: /dev/fuse 3
        name: fuse 4
      - groups:
        - usbs: 5
          - product: "0x7523" 6
            serial: ""
            vendor: "0x1a86" 7
        name: converter
      domain: device.microshift.io 8
      status: Enabled
    1 Exposes all the USB serial devices that are matched by this glob.
    2 Exposes all the ACM serial devices that are matched by this glob.
    3 For example, the file path for a fuse device.
    4 For example, the name of the device.
    5 Exposes a specific USB device by Vendor ID and Product ID.
    6 For example, the Product ID for a CH340 serial converter
    7 For example, the Vendor ID for a CH340 serial converter.
    8 Default domain for the GDP.
    Important
    • The output of the microshift show-config parameter might include pre-configured default paths for serial devices even if you have not explicitly configured them in config.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 count parameter 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, count defaults to 1.

  4. Save the config.yaml file.

  5. Restart the MicroShift service to apply the changes:

    $ sudo systemctl restart microshift

    Allow some time for MicroShift to restart and for the GDP to register its devices with the Kubelet.

Verification
  • You can check the available devices in your node by running the following command:

    $ oc describe node <microshift_node_name> | grep "device.microshift.io" 1
    1 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 output
    Capacity:
     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