blinkt-k8s-controller

module
v0.0.0-...-6947048 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2019 License: Apache-2.0

README

A Kubernetes Controller for the Pimoroni Blinkt on a Raspberry Pi

A simple way to physically/visually display the number of Pods running on Raspberry Pi-based Kubernetes worker nodes by using a Pimoroni Blinkt.

The Blinkt is a low-profile strip of eight super-bright, color LED indicators that plugs directly onto the Raspberry Pi's GPIO header. Several available software libraries make it easy to control the color and brightness of each LED independently.

How It Works

This controller is designed to be deployed as a DaemonSet to control Blinkt devices connected to Raspberry Pi Kubernetes worker nodes. Once deployed, every Pod with a label of blinkt: show that lands on a node will cause an LED indicator on that node's Blinkt to turn on (only the first 8 Pods can be displayed). As new Pods get created or deleted the light display will adjust accordingly. The color of the indicator can be customized by editing the COLOR environment variable in the included sample deployment file. Optionally, each Pod can define it's own color by having the label blinktColor: "FF0000" (an Hex, CSS-like color value without the hash # sign).

Acknowledgements

This project draws inspiration and borrows heavily from the work done by @alexellis on Docker on Raspberry Pis and his Blinkt Go libraries, themselves based on work by @gamaral for using the /sys/ fs interface instead of special libraries or elevated privileges to /dev/mem on the Raspberry Pi.

Requirements

A Raspberry Pi-based Kubernetes cluster. Hypriot has a good blog post that describes a good way to set this up.

Physically install a Pimoroni Blinkt on all the Raspberry Pi worker nodes you want to use for display. No additional sofware or setup is required for the Blinkt.

Note: For greater control, every node equiped with a Blinkt should be labeled with deviceType: blinkt. A nodeSelector can then be used to insure that only labeled nodes run the Controller Pod. For example:

kubectl label node <nodename> deviceType=blinkt

If you want to run the Pod on all nodes you can skip this step and remove the nodeSelector from the DaemonSet Descriptor

Usage

If you're running on a Kubernetes v1.6 cluster or above and have RBAC enabled, you can use the sample RBAC Descriptor to run the DaemonSet with the proper permissions:

kubectl create -f kubernetes/blinkt-k8s-controller-rbac.yaml

Create the DaemonSet using the included Resource Descriptor:

kubectl create -f kubernetes/blinkt-k8s-controller-ds.yaml

Label Pods with blinkt: show to have them show up in the Blinkt. For example:

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  ...
spec:
  template:
    metadata:
      labels:
        ...
        blinkt: show
    spec:
      ...

Building Your Own

You need a properly configured Go environment and the Glide vendoring command. Just edit the main.go file and run:

glide update --strip-vendor
./build.sh

to cross-compile to a local binary named main. You can then edit and run the dockerize.sh script to create your own Docker Image repository and tags. You then have to upload it to your container registry of choice and modify the DaemonSet Descriptor to use your new Image Repo instead.

License

This software is made available under an Apache License, Version 2.0. See LICENSE.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL