• Stars
    star
    162
  • Rank 231,728 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Kubernetes device plugin to schedule generic Linux devices

Kubernetes Generic Device Plugin

The generic-device-plugin enables allocating generic Linux devices, such as serial devices, the FUSE device, or video cameras, to Kubernetes Pods. This allows devices that don't require special drivers to be advertised to the cluster and scheduled, enabling various use-cases, e.g.:

  • accessing video and sound devices;
  • running IoT applications, which often require access to hardware devices; and
  • mounting FUSE filesysems without privileged.

Build Status Go Report Card

Overview

The generic-device-plugin can be configured to discover and allocate any desired device using the --device flag. For example, to advertise all video devices to the cluster, the following flag could be given:

--device='{"name": "video", "groups": [{"paths": [{"path": "/dev/video0"}]}]}'

Now, Pods that require a video capture device, such as an object detection service, could request to be allocated one using the Kubernetes Pod resources field:

resources:
  limits:
    squat.ai/video: 1

The --device flag can be provided multiple times to allow the plugin to discover and allocate different types of resources.

Getting Started

To install the generic-device-plugin, choose what devices should be discovered and deploy the included DaemonSet:

kubectl apply -f https://raw.githubusercontent.com/squat/generic-device-plugin/main/manifests/generic-device-plugin.yaml

Note: the example manifest included in this repository discovers serial devices, the /dev/video0 device, the /dev/fuse device, sound devices, and sound capture devices.

Now, deploy a workload that requests one of the newly discovered resources. For example, the following script could be used to run a Pod that creates an MJPEG stream from a video device on the node:

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: mjpeg
  labels:
    app.kubernetes.io/name: mjpeg
spec:
  containers:
  - name: kceu
    image: squat/kubeconeu2019
    command:
    - /cam2ip
    args:
    - --bind-addr=:8080
    ports:
    - containerPort: 8080
      name: http
    resources:
      limits:
        squat.ai/video: 1
EOF

This application could then be accessed by port-forwarding to the Pod:

kubectl port-forward mjpeg http

Now, the MJPEG stream could be opened by pointing a browser to http://localhost:8080/mjpeg.

Usage

Usage of bin/amd64/generic-device-plugin:
      --config string             Path to the config file.
      --device stringArray        The devices to expose. This flag can be repeated to specify multiple device types.
                                  Multiple paths can be given for each type. Paths can be globs.
                                  Should be provided in the form:
                                  {"name": "<name>", "groups": [(device definitions)], "count": <count>}]}
                                  The device definition can be either a path to a device file or a USB device. You cannot define both in the same group.
                                  For device files, use something like: {"paths": [{"path": "<path-1>", "mountPath": "<mount-path-1>"},{"path": "<path-2>", "mountPath": "<mount-path-2>"}]}
                                  For USB devices, use something like: {"usb": [{"vendor": "1209", "product": "000F"}]}
                                  For example, to expose serial devices with different names: {"name": "serial", "groups": [{"paths": [{"path": "/dev/ttyUSB*"}]}, {"paths": [{"path": "/dev/ttyACM*"}]}]}
                                  The device flag can specify lists of devices that should be grouped and mounted into a container together as one single meta-device.
                                  For example, to allocate and mount an audio capture device: {"name": "capture", "groups": [{"paths": [{"path": "/dev/snd/pcmC0D0c"}, {"path": "/dev/snd/controlC0"}]}]}
                                  For example, to expose a CH340 serial converter: {"name": "ch340", "groups": [{"usb": [{"vendor": "1a86", "product": "7523"}]}]}
                                  A "count" can be specified to allow a discovered device group to be scheduled multiple times.
                                  For example, to permit allocation of the FUSE device 10 times: {"name": "fuse", "groups": [{"count": 10, "paths": [{"path": "/dev/fuse"}]}]}
                                  Note: if omitted, "count" is assumed to be 1
      --domain string             The domain to use when when declaring devices. (default "squat.ai")
      --listen string             The address at which to listen for health and metrics. (default ":8080")
      --log-level string          Log level to use. Possible values: all, debug, info, warn, error, none (default "info")
      --plugin-directory string   The directory in which to create plugin sockets. (default "/var/lib/kubelet/device-plugins/")
      --version                   Print version and exit

More Repositories

1

kilo

Kilo is a multi-cloud network overlay built on WireGuard and designed for Kubernetes (k8s + wg = kg)
Go
1,990
star
2

terraform-provider-vultr

Terraform Vultr Provider
Go
168
star
3

drae

A RESTful API for el Diccionario de la Real Academia Española
Go
62
star
4

postpone

Postpone your resources and save some bandwidth
JavaScript
60
star
5

modulus

Automatically compile kernel modules for Flatcar Linux / CoreOS Container Linux
Shell
33
star
6

service-reflector

Service-Reflector mirrors Kubernetes Services so that Pods in one cluster can natively access Services in another
Go
22
star
7

kubeconeu2019

KubeCon EU 2019 talk on building multi-cloud clusters with WireGuard
HCL
11
star
8

kubeconeu2020

KubeCon EU 2020 talk on scaling metrics ingestion with Thanos receive
10
star
9

kilo-wg-gen-web

Use Wg Gen Web to manage Kilo peers
Go
10
star
10

fluxcdbot

A Telegram bot for Flux CD
Go
6
star
11

onseu2019

ONS EU 2019 talk on connecting Kubernetes clusters with Kilo
HCL
6
star
12

darkapi

An API for Darknet image detection neural networks like YOLO
C
5
star
13

typhoon-vultr

Vultr fork of Typhoon, a minimal and free Kubernetes distribution
HCL
5
star
14

node-jp2a

A node wrapper for the jp2a CLI tool
JavaScript
5
star
15

kilosubspace

Use Subspace to manage Kilo peers
Makefile
5
star
16

jupyter-operator

A Kubernetes operator for Jupyter Notebooks
Go
5
star
17

configmap-to-disk

configmap-to-disk synchronizes a ConfigMap from the Kubernetes API to disk
Go
4
star
18

hetzner-cloud-flatcar-linux

Terraform module for creating Flatcar Linux servers in Hetzner Cloud
HCL
2
star
19

onboard

Easily connect IoT devices to your fleet
Go
2
star
20

coreos-ovh

Install CoreOS Linux on OVH VPS
Shell
2
star
21

acatiris

An ASCII Art Middleware for Express
JavaScript
2
star
22

kubeconeu2018

KubeCon EU 2018 talk on automating GPU infrastructure for Kubernetes on Container Linux
HCL
2
star
23

keewee

Deploy self-hosted KeeWeb
Makefile
2
star
24

berlinstrength

an RFID scanner application for Berlin Strength
TypeScript
2
star
25

hetzner-cloud-kubeadm

Terraform module for creating creating a kubeadm cluster in Hetzner Cloud
HCL
1
star
26

servor

a tiny HTTP API for controlling servos via GPIO
Go
1
star
27

fileckr

Upload files to Flickr and make use of your 1TB of free storage
Go
1
star
28

pre-commit-sops

A pre-commit hook that detects SOPS secrets that are unencrypted or encrypted with the wrong key(s)
1
star
29

terraform-provider-saladcloud

Terraform Provider for SaladCloud
Go
1
star
30

drivefs

Use Google Drive as a static file server
Go
1
star