Packet Labs IoT workshop
This workshop deploys compute, storage, networking, and an IoT application to Packet.com.
- Kubernetes - provisioned with Terraform
- TLS termination - via cert-manager
- MQTT Connector - openfaas-incubator/mqtt-connector
- Database/storage - Postgresql
- Docker registry - deployed externally, i.e. the Docker Hub.
Components exposed with TLS / Ingress or NodePort:
- Ingress Controller - Traefik v1 (HostPort 80/443)
- Serverless compute platform - OpenFaaS
- MQTT Broker - emitter.io (NodePort) - 30080/30443
- Business intelligence - Metabase (Ingress/TLS)
- Metrics visualization - Grafana (Ingress/TLS)
Before you begin using this repo you will need a Packet account.
Everything else you need to deploy this workshop is available in this repository.
Note: This repository is designed to be used with your own domain name and a number of DNS records. This enables TLS termination (HTTPS) to be used for exposed services. If you are working in development, you can skip the domain and TLS steps.
1) Clone the repo
git clone https://github.com/packet-labs/iot
2) Create a bare-metal Kubernetes cluster
You will need to install Terraform for this step.
Set your Packet API and project ID in a terraform.tfvar file in
k8sfolder and apply the terraform plan.
Find the IP of one of the nodes in the cluster from your Packet dashboard or the state file in /k8s/
Create four DNS A records (replace
example.com with your domain):
Some commands will be run from your laptop, so make sure you install Kubectl
3) Install Postgres via KubeDB and helm
You will need to install helm for this step.
- Install postgresql
4) Install OpenFaaS
You will also deploy the schema.sql at this time for
65 TLS for OpenFaaS
k3sup app install cert-manager
Install an Ingress record for your OpenFaaS gateway
k3sup app install openfaas-ingress \ --domain gateway.example.com \ --email email@example.com \ --ingress-class traefik
Add TLS for Grafana
example.comwith your domain.
kubectl apply -f ./openfaas/grafana-ingress.yaml
6) Add the MQTT Broker (Emitter.io)
- Install emitter
7) Add the OpenFaaS MQTT-Connector
The MQTT-Connector is used to trigger functions and services in response to messages generated by the event source. It runs inside the Kubernetes cluster and is private with no ingress.
- Install OpenFaaS MQTT-Connector
8) Add Grafana for function/service visualization
Grafana packages a pre-compiled dashboard for OpenFaaS to show metrics like throughput and latency.
9) Send Drone Data
You can now send data to emitter from your drone clients. Use the drone simulator to generate realistic data for use with visualization tools.