Skip to content

pattarinth/iot-data-platform-k8s-terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IoT Data Platform on Kubernetes (Local) + Terraform (Cloud IaC Example)

A small end-to-end IoT data pipeline demonstrating containerized microservices on Kubernetes with FastAPI ingestion, MongoDB storage, and a background telemetry processor.

Docker Kubernetes FastAPI MongoDB Terraform

This project demonstrates a containerized IoT data pipeline deployed on Kubernetes, including a FastAPI ingestion service, MongoDB storage, a background telemetry processor, and a Python-based device simulator.


🚀 Tech Stack

  • Python (FastAPI, PyMongo)
  • MongoDB
  • Docker
  • Kubernetes (kind)
  • Terraform (cloud IaC example)

📊 Architecture

flowchart LR

subgraph Local_Environment
    SIM[IoT Device Simulator]
end

subgraph Kubernetes_Cluster
    API[FastAPI Ingestion API]
    PROC[Telemetry Processor Service]
    DB[(MongoDB Database)]
end

SIM -->|HTTP Telemetry| API
API -->|Store Raw Telemetry| DB
PROC -->|Read Raw Telemetry| DB
PROC -->|Write Processed Telemetry| DB
Loading

📦 Project Structure

project-6-iot-k8s-platform/
  README.md
  terraform/
  k8s/
  services/
    api/
    processor/
  simulator/

⚙️ How to Run (Step-by-Step)

1️⃣ Start Kubernetes cluster

kind create cluster --name iot-local

2️⃣ Deploy namespace

kubectl apply -f k8s/namespace.yaml

3️⃣ Deploy MongoDB

kubectl apply -f k8s/mongodb.yaml

Verify:

kubectl -n iot-platform get pods

4️⃣ Build & deploy API service

docker build -t iot-api:0.1 ./services/api
kind load docker-image iot-api:0.1 --name iot-local
kubectl apply -f k8s/api.yaml

5️⃣ Build & deploy Processor service

docker build -t iot-processor:0.1 ./services/processor
kind load docker-image iot-processor:0.1 --name iot-local
kubectl apply -f k8s/processor.yaml

6️⃣ Port-forward API

kubectl -n iot-platform port-forward svc/iot-api 8000:8000

7️⃣ Run IoT Simulator

In another terminal:

python3 simulator/send_telemetry.py --devices 3 --interval 1 --rounds 5

📸 Execution Evidence

Kubernetes Services Running

Pods Running

Pods With Processor


API Health Check

API Health


Telemetry Ingestion

API Ingest


Processor Logs (Data Processing)

Processor Logs


Simulator Sending Telemetry

Simulator Output


🧠 Data Flow

  1. Simulator sends telemetry via HTTP
  2. FastAPI ingestion service stores raw telemetry in MongoDB
  3. Processor service reads new telemetry
  4. Processor classifies data (HOT, COLD, HUMID, NORMAL)
  5. Processed data stored in a separate MongoDB collection

☁️ Terraform (Cloud IaC Example)

The terraform/ folder contains an example Infrastructure as Code configuration for provisioning cloud infrastructure (e.g., VPC + networking skeleton).

This demonstrates:

  • Infrastructure as Code practices
  • Cloud-native thinking
  • Separation of local development and cloud deployment patterns

🎯 What This Project Demonstrates

  • Microservices architecture on Kubernetes
  • Docker image build & cluster loading
  • Kubernetes Deployments, Services, Secrets, PVC
  • NoSQL data storage with MongoDB
  • Background data processing service
  • End-to-end telemetry simulation
  • DevOps workflow using kind
  • Infrastructure as Code awareness (Terraform)

🧪 Future Improvements

  • Add Kafka for real message streaming
  • Add Prometheus + Grafana monitoring
  • Deploy to managed Kubernetes (EKS/GKE/AKS)
  • Add CI/CD pipeline (GitHub Actions)
  • Add Horizontal Pod Autoscaler

👩‍💻 Author

Pattarin Thunyapar
Master’s in Data Analytics
Focused on Data Engineering, Cloud, and AI Systems

About

End-to-end IoT data platform on Kubernetes (kind) using FastAPI, MongoDB, and a background processor with a telemetry simulator. Includes Terraform IaC example.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors