Skip to content

Commit

Permalink
Support Kubernetes DaemonSet deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
pmundt committed May 30, 2020
1 parent 1d99077 commit 067ba7a
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Usage: edgetpu-exporter [flags]
-port int
Port to listen to (default 8080)
-sysfs string
Mountpoint of sysfs instance to scan (default "/sys")
```

By default, it will listen on port `8080`, but this can be changed via the `-port` argument.
Expand Down Expand Up @@ -54,6 +56,24 @@ edgetpu_temperature_celsius{name="apex_0"} 49.3

Multi-arch Docker images are available on Docker Hub at [adaptant/edgetpu-exporter].

## Deployment via Kubernetes

`edgetpu-exporter` can be installed directly as a `DaemonSet` on matching nodes:

```
$ kubectl apply -f https://raw.githubusercontent.com/adaptant-labs/edgetpu-exporter/edgetpu-daemonset.yaml
```

The node selection criteria depends on the existence of node labels designating the existence of an EdgeTPU within the
node. The list of node labels and their respective labelling sources are listed below:

| Node Label | Labelling Source | Supported Devices |
|------------|------------------|-------------------|
| kkohtaka.org/edgetpu | [EdgeTPU Device Plugin][edgetpu-device-plugin] | USB |
| feature.node.kubernetes.io/usb-fe_1a6e_089a.present | [node-feature-discovery] | USB |
| feature.node.kubernetes.io/pci-0880_1ac1.present | [node-feature-discovery] | PCIe, Coral Dev Board |
| beta.devicetree.org/fsl-imx8mq-phanbell | [k8s-dt-node-labeller] | Coral Dev Board |

## Features and bugs

Please file feature requests and bugs in the [issue tracker][tracker].
Expand All @@ -65,3 +85,6 @@ version of which can be found in the LICENSE file included in the distribution.

[tracker]: https://github.com/adaptant-labs/edgetpu-exporter/issues
[adaptant/edgetpu-exporter]: https://hub.docker.com/repository/docker/adaptant/edgetpu-exporter
[k8s-dt-node-labeller]: https://github.com/adaptant-labs/k8s-dt-node-labeller
[node-feature-discovery]: https://github.com/kubernetes-sigs/node-feature/discovery
[edgetpu-device-plugin]: https://github.com/kkohtaka/edgetpu-device-plugin
51 changes: 51 additions & 0 deletions edgetpu-daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: edgetpu-exporter
spec:
selector:
matchLabels:
name: edgetpu-exporter
template:
metadata:
labels:
name: edgetpu-exporter
spec:
containers:
- name: edgetpu-exporter
image: adaptant/edgetpu-exporter:latest
args:
- "-sysfs=/host-sys"
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /host-sys
name: sysfs
readOnly: true
volumes:
- name: sysfs
hostPath:
path: /sys
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
# EdgeTPU Device Plugin
- key: kkohtaka.org/edgetpu
operator: Exists
# USB-attached Coral AI Accelerator (using NFD discovery)
- key: feature.node.kubernetes.io/usb-fe_1a6e_089a.present
operator: In
values:
- "true"
# PCIe-attached Coral AI Accelerator (using NFD discovery)
- key: feature.node.kubernetes.io/pci-0880_1ac1.present
operator: In
values:
- "true"
# Coral Dev Board (using DT labelling)
- key: beta.devicetree.org/fsl-imx8mq-phanbell
operator: In
values:
- "1"
2 changes: 1 addition & 1 deletion edgetpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func FindEdgeTPUDevices() []EdgeTPUDevice {
devices := make([]EdgeTPUDevice, 0)

// Attempt to lookup Apex devices by device class
files, err := filepath.Glob("/sys/class/apex/apex_*")
files, err := filepath.Glob(sysfsRoot + "/class/apex/apex_*")
if err != nil {
return devices
}
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (

var (
labels = []string{"name"}
sysfsRoot = "/sys"
)

type EdgeTPUCollector struct {
Expand Down Expand Up @@ -78,6 +79,7 @@ func main() {
var port int

flag.IntVar(&port, "port", 8080, "Port to listen to")
flag.StringVar(&sysfsRoot, "sysfs", "/sys", "Mountpoint of sysfs instance to scan")

flag.Usage = func() {
fmt.Fprintf(os.Stderr, "EdgeTPU Prometheus Exporter\n")
Expand Down

0 comments on commit 067ba7a

Please sign in to comment.