|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// microshift_configuring/microshift-gdp.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="microshift-configuring-generic-device-plugin_{context}"] |
| 7 | += Configuring the Generic Device Plugin |
| 8 | + |
| 9 | +:FeatureName: The Generic Device Plugin for {microshift-short} |
| 10 | + |
| 11 | +include::snippets/technology-preview.adoc[] |
| 12 | + |
| 13 | +The Generic Device Plugin (GDP) is disabled by default in {microshift-short}. 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-short} `config.yaml` file or create a configuration snippet file. For example, `/etc/microshift/config.d/10-gdp.yaml`. |
| 14 | + |
| 15 | +.Prerequisites |
| 16 | + |
| 17 | +* You installed {microshift-short}. |
| 18 | +* You created a custom `config.yaml` file in the `/etc/microshift` directory. |
| 19 | +* You installed the {oc-first}. |
| 20 | +* You have `sudo` privileges on the {microshift-short} host. |
| 21 | +* You have identified the specific host devices that you want to expose to your {microshift-short} cluster. For example, `/dev/video0`, `/dev/ttyUSB*`, or USB Vendor/Product IDs. |
| 22 | +
|
| 23 | +.Procedure |
| 24 | + |
| 25 | +. From your CLI using `sudo` privileges, open `/etc/microshift/config.yaml` in a text editor. |
| 26 | ++ |
| 27 | +. Locate the `genericDevicePlugin` section. If it is not present, add it. |
| 28 | ++ |
| 29 | +. 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. |
| 30 | ++ |
| 31 | +.GDP fields with default values |
| 32 | +[source,yaml] |
| 33 | +---- |
| 34 | +apiServer: |
| 35 | +# ... |
| 36 | +genericDevicePlugin: |
| 37 | + devices: |
| 38 | + - groups: |
| 39 | + - paths: |
| 40 | + - path: /dev/ttyUSB* <1> |
| 41 | + - path: /dev/ttyACM* <2> |
| 42 | + name: serial |
| 43 | + - groups: |
| 44 | + - paths: |
| 45 | + - path: /dev/fuse <3> |
| 46 | + name: fuse <4> |
| 47 | + - groups: |
| 48 | + - usbs: <5> |
| 49 | + - product: "0x7523" <6> |
| 50 | + serial: "" |
| 51 | + vendor: "0x1a86" <7> |
| 52 | + name: converter |
| 53 | + domain: device.microshift.io <8> |
| 54 | + status: Enabled |
| 55 | +---- |
| 56 | +<1> Exposes all the USB serial devices that are matched by this glob. |
| 57 | +<2> Exposes all the ACM serial devices that are matched by this glob. |
| 58 | +<3> For example, the file path for a fuse device. |
| 59 | +<4> For example, the name of the device. |
| 60 | +<5> Exposes a specific USB device by Vendor ID and Product ID. |
| 61 | +<6> For example, the Product ID for a CH340 serial converter |
| 62 | +<7> For example, the Vendor ID for a CH340 serial converter. |
| 63 | +<8> Default domain for the GDP. |
| 64 | ++ |
| 65 | +[IMPORTANT] |
| 66 | +==== |
| 67 | +* 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. |
| 68 | +
|
| 69 | +* 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*`. |
| 70 | +
|
| 71 | +* 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`. |
| 72 | +==== |
| 73 | ++ |
| 74 | +. Save the `config.yaml` file. |
| 75 | +
|
| 76 | +. Restart the {microshift-short} service to apply the changes: |
| 77 | ++ |
| 78 | +[source,terminal] |
| 79 | +---- |
| 80 | +$ sudo systemctl restart microshift |
| 81 | +---- |
| 82 | ++ |
| 83 | +Allow some time for {microshift-short} to restart and for the GDP to register its devices with the Kubelet. |
| 84 | + |
| 85 | +.Verification |
| 86 | + |
| 87 | +* You can check the available devices in your cluster by running the following command: |
| 88 | ++ |
| 89 | +[source,terminal,subs="+quotes"] |
| 90 | +---- |
| 91 | +$ oc describe node _<microshift_node_name>_ | grep "device.microshift.io" <1> |
| 92 | +---- |
| 93 | +<1> Replace _<microshift_node_name>_ with your node name. |
| 94 | ++ |
| 95 | +* Depending on your configuration, expect output that indicates that the devices are now discoverable and schedulable within your {microshift-short} cluster. |
| 96 | ++ |
| 97 | +.Example output |
| 98 | +[source,terminal] |
| 99 | +---- |
| 100 | +Capacity: |
| 101 | + cpu: 2 |
| 102 | + device.microshift.io/audio: 0 |
| 103 | + device.microshift.io/capture: 0 |
| 104 | + device.microshift.io/custom-device: 1 |
| 105 | + device.microshift.io/dummy-video: 0 |
| 106 | + device.microshift.io/fuse: 0 |
| 107 | + device.microshift.io/serial: 5 |
| 108 | + device.microshift.io/video: 0 |
| 109 | +Allocatable: |
| 110 | + cpu: 2 |
| 111 | + device.microshift.io/audio: 0 |
| 112 | + device.microshift.io/capture: 0 |
| 113 | + device.microshift.io/custom-device: 1 |
| 114 | + device.microshift.io/dummy-video: 0 |
| 115 | + device.microshift.io/fuse: 0 |
| 116 | + device.microshift.io/serial: 5 |
| 117 | + device.microshift.io/video: 0 |
| 118 | +Allocated resources: |
| 119 | + (Total limits may be over 100 percent, i.e., overcommitted.) |
| 120 | + Resource Requests Limits |
| 121 | + -------- -------- ------ |
| 122 | + cpu 450m (22%) 500m (25%) |
| 123 | + memory 1550Mi (42%) 500Mi (13%) |
| 124 | + ephemeral-storage 0 (0%) 0 (0%) |
| 125 | + hugepages-1Gi 0 (0%) 0 (0%) |
| 126 | + hugepages-2Mi 0 (0%) 0 (0%) |
| 127 | + device.microshift.io/audio 0 0 |
| 128 | + device.microshift.io/capture 0 0 |
| 129 | + device.microshift.io/custom-device 1 1 |
| 130 | + device.microshift.io/dummy-video 1 1 |
| 131 | + device.microshift.io/fuse 0 0 |
| 132 | + device.microshift.io/serial 0 0 |
| 133 | + device.microshift.io/video 0 0 |
| 134 | +---- |
0 commit comments