Git Product home page Git Product logo

icc-services's Introduction

Iot Control Center

A local area network kubernetes cluster for managing and controlling IoT devices.

Installation

1. Flash an SD card with Ubuntu Server OS Arm64 Architecture

  • Raspberry Pi Imager
  • Connect the Pi to your network
    • Can be configured from Raspberry Pi Imager in options
    • Alternatively this can be done manually by editing the /etc/netplan/50-cloud-init.yaml found in Ubuntu
      • Remember to netplan apply

2. Boot up the Raspberry Pi and SSH into it

3. Docker and docker-compose Installation

4. Login to a dockerhub account

  • If you do not already have a dockerhub account, create one since it is needed
  • Log in with the sudo docker login command
  • In the dockerhub portal, create a project called iot-control-center

5. Install Kubernetes

  • Rancher Docs
    • Default installation can be done with the following command:
      • curl -sfL https://get.k3s.io | sh -
  • Enable cgroups
  • Install linux-modules-extra-raspi with:
    • sudo apt install linux-modules-extra-raspi
  • Configure DNS
    • Use a text editor to add the following to /etc/resolv.conf:
       namespace 8.8.8.8
       namespace 8.8.4.4
    • Then, restart daemon and docker systemctl services
       sudo systemctl daemon-reload
       sudo systemctl restart docker
    • Purge the DNS pod in the kube-system namespace
      • Get the DNS pod name with kubectl get pods --all-namespaces, e.g. coredns-b96499967-ggsj5
      • Delete it
        • kubectl delete pods coredns-b96499967-ggsj5 --namespace="kube-system"

6. Set up your environment variables

  • There are 4 environment variables needed for the build script to work:

    1. MONGO_DB_USERNAME
      • Your chosen database username
    2. MONGO_DB_PASSWORD
      • Your chosen database password
    3. MONGO_DB_IP
      • The IP address of the raspberry pi (which hosts the database)
      • This IP address can be found by running ifconfig
    4. DOCKERHUB_USERNAME
      • The username of the dockerhub account logged into in step 4
  • These environment variables can be set by appending the following to your /etc/environment file:

    MONGO_DB_USERNAME="<your chosen database username>"
    MONGO_DB_PASSWORD="<your chosen database password>"
    MONGO_DB_IP="<the IP of the pi>"
    DOCKERHUB_USERNAME="<your dockerhub username>"

7. Clone this Repository

8. Build and push the local docker containers to dockerhub

  • cd into the /Kubernetes folder of this repo
  • Execute the update_cluster.sh script to build and push all containers with sudo permissions
    • This may take quite some time on the first go. Depending on your RPi specs, could take anywhere from 5-20 minutes

9. Configure your cluster secrets

  • Copy the secrets.yaml found under /Kubernetes/Secrets. Rename it to secrets.yaml or another name of your choosing
  • Edit the file with a text editor to add the secrets. You'll need to add:
    • A Mongo Database Username and Password
    • The address of the Mongo Database (i.e. the address of the current Raspberry Pi. This can be found using ifconfig)
  • Apply the secrets to your cluster using kubernetes apply -f secrets.yaml

10. Deploy the Mongo Database

  • Build and bring up the docker container for the database
    • cd into /MongoDb
    • Run sudo docker compose up --build -d
  • To validate, visit the IP address at port 8081 to validate the mongo express UI appears
    • e.g. http://10.0.0.4:8081

11. Deploy the cluster

  • cd into /Kubernetes
  • Run deploy_cluster.sh to deploy the cluster
  • Check your device IP from anywhere on your LAN, you should see the IoT Control Center Home page!

icc-services's People

Contributors

adrian-patterson avatar julian-patterson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

icc-services's Issues

Make sliders better

  • reduce brightness slider step size to 1
  • make both sliders on change instead of on commit change

Implement the addition of new bulbs and LED strips for each controller

New/Modified bulbs:

  • Lighting service sends update request to bulb controller
  • Lighting service sends add request to bulb controller

New Custom LED controller:

  • Lighting service needs to keep track of IP address for custom led controllers
    • Lighting service needs to use custom LEd controller ObjectId to get IP address, send requests to this address
    • Instead of having it hard coded (as is today)

Create only 1 service for bulbs

Instead of 2 services for bulbs, only one service which sends commands to both.

2 services creates a lot of unnecessary overhead.

Move from microk8s to K3S for ARMv7 support

Currently, the raspberry pi zero W controlling the led strip is unable to run MicroK8s since microk8s is only available for ubuntu server 64-bit

To have all nodes run within the same kube cluster, it is worth to attempt deploying our cluster using K3S instead of microk8s.

Add Scene feature

Add scene feature to create different lighting effects using all the lighting devices

Add additional pages

Add additional pages to the website in order to organize functions and different lighting effects

Create a settings page

Create a settings page to update and control new devices on the network. This would also work with updating the Ui from the database to create live components

Change IoT protocol from MQTT to HTTP

We would like to start receiving information about the devices with GET calls, and with MQTT this is a hassle.

With COAP implemented, we can make lightweight REST calls to devices to retrieve states and other data.

Add color temperature feature for LED strip

Using an algorithm it's possible to get RGB values from kelvin temperature.

This gist contains the python function to do so, should be an easy implementation.

Front and back end would need to be adapted and tested.

NestJS

To try out NestJS, the lighting-api will be converted from Flask to a NestJs service.

Identity Service

  • Already in the works
    • Provides an API to allow configuration of user settings
      • CRUD for devices (IP addresses and other config)
      • CRUD for personalized settings
        • Pages visible
        • Server setup
        • Username and password
      • Authentication
        • Username & hashed password service

Color Temperature

Need to have a feature to control the color temperature of the light bulbs.

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.