Coder Social home page Coder Social logo

jmoscato / blinkt-k8s-controller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elafargue/blinkt-k8s-controller

0.0 1.0 0.0 21.76 MB

A Kubernetes Controller for the Pimoroni Blinkt on a Raspberry Pi

License: Apache License 2.0

Shell 10.49% Go 88.74% Dockerfile 0.78%

blinkt-k8s-controller's Introduction

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 blinktShow: true 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).

You can also define blinktColor: "cpu" in order to adjust the color of each pod based on CPU usage. This requires Heapster to be running on the cluster.

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 blinktImage: pods or blinktImage: nodes. A nodeSelector can then be used to insure that only labeled nodes run the Controller Pod. For example:

kubectl label node <nodename> blinktImage=pods

The pods image will add a Blinkt LED per pod that is running on a given node. The nodes image will light up a LED for each node that is in the cluster and ready - it makes sense to run the node image on the master node, typically.

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-pods.yaml
kubectl create -f kubernetes/blinkt-k8s-contorller-nodes.yaml

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

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  ...
spec:
  template:
    metadata:
      labels:
        ...
        blinktShow: true
    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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.