https://github.com/leonnicolas/nudl
Kubernetes node labeler for usb devices
https://github.com/leonnicolas/nudl
kubernetes labels
Last synced: 7 months ago
JSON representation
Kubernetes node labeler for usb devices
- Host: GitHub
- URL: https://github.com/leonnicolas/nudl
- Owner: leonnicolas
- License: mit
- Created: 2020-12-21T18:31:31.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-14T09:30:33.000Z (8 months ago)
- Last Synced: 2025-03-01T18:01:46.334Z (8 months ago)
- Topics: kubernetes, labels
- Language: Go
- Homepage:
- Size: 9.93 MB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nudl
Node Usb Device Labeler - label Kubernetes nodes according to their USB devices.
[](https://github.com/leonnicolas/nudl/actions/workflows/push.yaml)
[](https://hub.docker.com/r/leonnicolas/nudl)## Usage
Apply the example configuration
```bash
kubectl apply -f https://raw.githubusercontent.com/leonnicolas/nudl/main/example.yaml
```### Configure the Labeler
```
Usage of ./nudl:
--hostname string Hostname of the node on which this process is running
--human-readable use human readable label names instead of hex codes, possibly not all codes can be translated (default true)
--kubeconfig string path to kubeconfig
--label-prefix string prefix for labels (default "nudl.squat.ai")
--listen-address string listen address for prometheus metrics server (default ":8080")
--log-level string Log level to use. Possible values: all, debug, info, warn, error, none (default "info")
--no-contain strings list of strings, usb devices containing these case-insensitive strings will not be considered for labeling
--update-time duration renewal time for labels in seconds (default 10s)
--usb-debug int libusb debug level (0..3)
```### Label USB devices
If __--human-readable=false__, vendor and device codes will be four hex characters each. The generated label will be of the form:
```
/_=true
```
for example:
```
nudl.squat.ai/04f2_b420=true
```
Otherwise __nudl__ will try to translate the vendor and device codes into human readable strings using the [usbid](https://godoc.org/github.com/google/gousb/usbid) package, which uses [http://www.linux-usb.org/usb.ids](http://www.linux-usb.org/usb.ids). If the codes are not found, the name defaults to _Unknown_. Since some characters are not allowed in Kubernetes labels, forbidden characters are converted into "-".The above example would look like:
```
nudl.squat.ai/Chicony-Electronics-Co.--Ltd_Unknown:true
```Check out [http://www.linux-usb.org/usb-ids.html](http://www.linux-usb.org/usb-ids.html) for more information about what devices are known.
### Exclude USB devices
Use the `--no-contain` flag to exclude USB devices that can be ignored, e.g. USB hubs.### Outside the cluster
```bash
docker run --rm -v ~/.kube:/mnt leonnicolas/nudl --kubeconfig /mnt/k3s.yaml --hostname example_host
```## Images
Images can be found on [Docker Hub](https://hub.docker.com/r/leonnicolas/nudl) `leonnicolas/nudl` and [GitHub Container Registry](https://ghcr.io) `ghcr.io/leonnicolas/nudl`.