From 6e914554ae1959de8236db99e52be76b46a4638f Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Tue, 17 Nov 2020 03:24:27 +0100 Subject: [PATCH] Add Dockerfile and Kubernetes DaemonSet deployment --- Dockerfile | 9 +++++++++ README.md | 17 +++++++++++++++++ prometheus-ncs2-exporter.yaml | 35 +++++++++++++++++++++++++++++++++++ setup.py | 8 ++++++-- 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 prometheus-ncs2-exporter.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a805003 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM acceleratorbase/openvino-base + +ADD . /app/ +WORKDIR /app +RUN python3 setup.py install + +EXPOSE 8084 + +CMD [ "prometheus_ncs2_exporter" ] diff --git a/README.md b/README.md index ba8c6fd..f4ddd17 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,26 @@ # Intel NCS2 Prometheus Exporter [![PyPI](https://img.shields.io/pypi/v/prometheus-ncs2-exporter.svg)](https://pypi.python.org/pypi/prometheus-ncs2-exporter) +[![PyPI](https://img.shields.io/pypi/pyversions/prometheus-ncs2-exporter.svg)](https://pypi.python.org/pypi/prometheus-ncs2-exporter) +[![Docker Pulls](https://img.shields.io/docker/pulls/adaptant/prometheus-ncs2-exporter.svg)](https://hub.docker.com/repository/docker/adaptant/prometheus-ncs2-exporter) A Prometheus exporter for the Intel Neural Compute Stick 2 (NCS2) / Intel Movidius MyriadX +## Quick Start + +To directly install `prometheus_ncs2_exporter` as a `DaemonSet` into the Kubernetes cluster: + +``` +$ kubectl apply -f https://raw.githubusercontent.com/adaptant-labs/prometheus_ncs2_exporter/prometheus-ncs2-exporter.yaml +``` + +Pods will be scheduled on any node with a `feature.node.kubernetes.io/usb-ff_03e7_2485.present` (provided by [NFD]) or +`accelerators/ncs2` (provided by [k8s-auto-labeller], in combination with NFD-based discovery) label set. These labels +can also be set manually on NCS2-capable nodes for simple deployments in order to enqueue the Pod. + +[NFD]: https://github.com/kubernetes-sigs/node-feature-discovery +[k8s-auto-labeller]: https://github.com/adaptant-labs/k8s-auto-labeller + ## Usage `prometheus_ncs2_exporter` can be run as-is without any additional configuration. A number of configuration and diff --git a/prometheus-ncs2-exporter.yaml b/prometheus-ncs2-exporter.yaml new file mode 100644 index 0000000..de4c913 --- /dev/null +++ b/prometheus-ncs2-exporter.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: ncs2-exporter + namespace: kube-system +spec: + selector: + matchLabels: + name: ncs2-exporter + template: + metadata: + labels: + name: ncs2-exporter + annotations: + prometheus.io/scrape: "true" + spec: + containers: + - name: ncs2-exporter + image: adaptant/prometheus-ncs2-exporter:latest + ports: + - containerPort: 8084 + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + # k8s-auto-labeller + - key: accelerators/ncs2 + operator: Exists + - matchExpressions: + # USB-attached NCS2 (using NFD discovery) + - key: feature.node.kubernetes.io/usb-ff_03e7_2485.present + operator: In + values: + - "true" diff --git a/setup.py b/setup.py index 085617c..b702823 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='prometheus_ncs2_exporter', - version='0.0.1', + version='0.1.0', packages=['prometheus_ncs2_exporter'], url='https://github.com/adaptant-labs/prometheus_ncs2_exporter', license='Apache 2.0', @@ -17,12 +17,16 @@ description='Prometheus Exporter for Intel NCS2 Metrics', long_description=long_description, long_description_content_type='text/markdown', - keywords=['prometheus', 'movidius', 'ncs2', 'myriadx', 'monitoring', 'exporter'], + keywords=['prometheus', 'movidius', 'ncs2', 'myriad', 'myriadx', 'monitoring', 'exporter'], classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', + 'Topic :: System :: Hardware', 'Topic :: System :: Monitoring', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: Apache Software License', ], install_requires=requirements,