Smarter Device Manager
Relevant source files
The following files were used as context for generating this wiki page:
Smarter Device Manager is a Kubernetes-native resource management component used in the swimctl project to facilitate access to hardware devices, specifically I2C interfaces on a Raspberry Pi. It functions as a device plugin that allows the containerized swimming pool automation controller to interact with physical hardware by exposing host devices to Kubernetes pods through a resource allocation mechanism.
The system operates within the device-manager namespace and is deployed as a DaemonSet to ensure hardware management capabilities are available on the relevant nodes of the cluster. It bridges the gap between the host Linux device files (under /dev) and the Kubernetes scheduling system, enabling workloads like Node-RED to request specific hardware resources such as i2c-1.
Sources: smarter-device-manager.yaml:1-10, 00-namespaces.yaml:1-6, README.md:1-10
Architecture and Deployment
The Smarter Device Manager is deployed as an apps/v1 DaemonSet, which ensures that an instance of the manager runs on nodes where hardware access is required. It uses the system-node-critical priority class to ensure high availability and is configured with hostNetwork: true to interact directly with the host's networking and device stack.
Deployment Configuration
The following table describes the deployment parameters for the manager:
| Component | Value | Source |
|---|---|---|
| Namespace | device-manager | 00-namespaces.yaml:5 |
| Image | registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2 | smarter-device-manager.yaml:41 |
| Update Strategy | RollingUpdate | smarter-device-manager.yaml:18 |
| Priority Class | system-node-critical | smarter-device-manager.yaml:37 |
| Hostname | smarter-device-management | smarter-device-manager.yaml:38 |
Sources: smarter-device-manager.yaml:1-45
Hardware Integration Flow
The manager requires specific host-level configuration before it can successfully manage I2C devices. This includes enabling cgroups and the I2C interface on the Raspberry Pi host.
The diagram shows the prerequisite host configuration and how the manager mounts host directories to expose resources to the cluster.
Sources: README.md:9-25, smarter-device-manager.yaml:63-74
Device Mapping and Configuration
Device discovery and exposure are controlled via a ConfigMap named smarter-device-manager. This configuration defines which host devices should be matched and how many virtual instances of those devices should be made available to the Kubernetes scheduler.
Regex Matching
The manager uses regular expressions to identify devices. In this implementation, it targets I2C buses.
data:
conf.yaml: |
- devicematch: ^i2c-[0-9]+$
nummaxdevices: 1
Sources: configMaps.yaml:7-10
Resource Requests and Limits
Workloads (such as the main swimctl application) request these devices using specific resource strings. The values.yml file defines how the application requests access to the hardware managed by Smarter Device Manager.
| Resource Name | Request/Limit | Purpose |
|---|---|---|
smarter-devices/i2c-1 | 1 | Access to primary I2C bus |
smarter-devices/i2c-20 | 1 | Access to I2C bus 20 |
smarter-devices/i2c-21 | 1 | Access to I2C bus 21 |
Sources: values.yml:10-18
Security and Permissions
To allow pods to interact with the hardware exposed by the manager, the project configures specific security contexts and group memberships.
I2C Group Access
The application pod is configured to run with supplementalGroups that include the host's I2C group (GID 994). This ensures that once Smarter Device Manager maps the device into the container, the process has the necessary Linux permissions to read/write to the device file.
podSecurityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
supplementalGroups:
- 994 # Add i2c group membership
Sources: values.yml:21-28
Volume Mounts
The Smarter Device Manager pod itself requires extensive access to the host to function as a device plugin:
- /var/lib/kubelet/device-plugins: Used to register the plugin with the Kubelet.
- /dev: Used to access the raw hardware device nodes.
- /sys: Used for device discovery and status monitoring.
Sources: smarter-device-manager.yaml:63-82
Summary
The Smarter Device Manager acts as the hardware abstraction layer for the swimctl automation system. By matching host /dev/i2c-* devices via regex and registering them as Kubernetes resources, it allows the swimming pool controller to safely and predictably access low-level hardware. Its configuration is tightly coupled with host-level preparations (cgroups and I2C activation) and application-level security settings (supplemental GID 994).