fake-k8s-device is a minimal Kubernetes device plugin for registering configurable fake devices with kubelet. Each configured resource becomes its own device plugin endpoint, and the number of allocatable resources is the number of fake device IDs listed for that resource.
- Registers one device plugin per configured resource name.
- Reports all configured devices as healthy through
ListAndWatch. - Returns selected fake device IDs to containers via environment variables.
- Optionally writes an allocation annotation on each container response.
See examples/config.yaml:
pluginDirectory: /var/lib/kubelet/device-plugins
socketPrefix: fake-k8s-device
resources:
- name: devices.example.com/fake-gpu
devices:
- fake-gpu-0
- fake-gpu-1Important constraints:
resources[].namemust be a qualified extended resource name such asexample.com/fake-gpu.- A resource can use either
devicesordeviceNamePrefixwithcount. - The resolved device count determines allocatable capacity. Three fake device IDs means allocatable count
3. - Each resource name and device ID must be unique within its resource block.
go run ./cmd/fake-k8s-device -config examples/config.yamlPrint the embedded build version:
go run ./cmd/fake-k8s-device -versionLocal builds use the most recent Git tag as a base and append commit state when the checkout is not an exact release tag. With no tags present, the base defaults to v0.0.0, so a local build looks like v0.0.0-dev+<commit> or v0.0.0-dev+<commit>.dirty.
The kubelet device plugin socket directory usually needs the process to run on a node with access to /var/lib/kubelet/device-plugins.
This repo includes GitHub Actions for CI, release tagging, and image publishing:
.github/workflows/ci.ymlbuilds the binary and container image on pushes tomainand on pull requests..github/workflows/tag-release.ymlcreates the nextvMAJOR.MINOR.PATCHtag from the latest existing tag. If no tags exist, it starts fromv0.0.0..github/workflows/publish-image.ymlpublishesdboslee/fake-k8s-deviceforlinux/amd64andlinux/arm64when av*tag is pushed.
The publish workflow expects these repository secrets:
DOCKERHUB_USERNAMEDOCKERHUB_TOKEN
This is intentionally small. It implements registration, ListAndWatch, and Allocate, but does not yet support:
- dynamic config reloads
- health transitions
- checkpoint recovery
- re-registration after kubelet restart