VOOZH about

URL: https://thenewstack.io/design-an-edge-system-for-the-cloud-native-edge-infrastructure/

⇱ Design an Edge System for the Cloud Native Edge Infrastructure - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2020-10-02 10:54:17
Design an Edge System for the Cloud Native Edge Infrastructure
feature,tutorial,
Kubernetes / Networking / Storage

Design an Edge System for the Cloud Native Edge Infrastructure

Oct 2nd, 2020 10:54am by Janakiram MSV
👁 Featued image for: Design an Edge System for the Cloud Native Edge Infrastructure

In the previous article, I discussed how Rancher’s K3s lightweight Kubernetes distribution, Calico networking software, and the Portworx open source cloud native storage platform become the foundation for modern artificial intelligence (AI) and IoT systems that run at the edge. Let’s design and deploy a solution that runs on this infrastructure.

Based on a hypothetical scenario of monitoring fans belonging to turbines, we will build a predictive maintenance solution that will detect anomalies in fans. This acts as a reference architecture for designing and architecting an IoT/edge solution that leverages various open source and the cloud native technologies.

Problem Statement

We are expected to design and deploy a solution that can ingest telemetry data from multiple fans and use the real-time stream to predict failures before they occur. The solution runs on the edge infrastructure running on low-end machines such as Intel NUCs. The infrastructure is based on K3s, Calico, and Portworx that provide the core building blocks of the Kubernetes cluster.

Solution Architecture

The sensors attached to the fans of the turbine provide the current rotational speed, vibration, temperature, and noise level. This telemetry data stream along with the deviceID from each fan acts as the input to the predictive maintenance solution.

👁 Image

Mosquitto, a popular open source MQTT broker acts as the gateway for the sensors and a centralized message broker for the platform. The sensors ingest the telemetry data into the fan/messages topic of the Mosquitto broker.

Below is the payload published by each fan to the MQTT topic.

👁 Image

The predictor microservice is a subscriber to the same telemetry channel to which the fans are publishing. For each inbound data point, it invokes the anomaly detection service and publishes the result into a separate MQTT topic, fan/anomaly.

import time
import requests
import random
import datetime
import json
import os
import paho.mqtt.client as mqtt
 
broker_address = os.getenv('MQTT_HOST')
dev_topic = os.getenv('MQTT_DEV_TOPIC')
pred_topic = os.getenv('MQTT_PREDICT_TOPIC')
scoring_url=os.getenv('SCORING_URL')
d={}

client = mqtt.Client("pdm")
client.connect(broker_address)

def on_message(mosq, obj, msg):
 rotation=json.loads(msg.payload)["rotation"]
 temperature=json.loads(msg.payload)["temperature"]
 vibration=json.loads(msg.payload)["vibration"]
 sound=json.loads(msg.payload)["sound"]
 telemetry=[rotation,temperature,vibration,sound]
 data={"params":telemetry}
 
 response = requests.post(scoring_url, json=data)
 fault=json.loads(response.text)["fault"]

 d["deviceID"]=json.loads(msg.payload)["deviceID"]
 d["fault"]=fault

 payload = json.dumps(d, ensure_ascii=False)
 print(payload)
 client.publish(pred_topic,payload)
 
def on_subscribe(mosq, obj, mid, granted_qos):
 print("Subscribed: " + str(mid) + " " + str(granted_qos))

client.on_message = on_message
client.on_subscribe = on_subscribe
client.connect(broker_address)
client.subscribe(dev_topic, 0)

while True:
 client.loop()

The SCORING_URL is an endpoint of the anomaly detection inference service. A deep learning model trained in TensorFlow is exposed through a Flask web service.

Below is the payload published to the MQTT topic by the predictor service:

👁 Image

Training the Anomaly Detection Model

A historical dataset with over 20,000 data points is used to train the anomaly detection model.

👁 Image

From the dataset, it is observed that a fan’s rotation decreases hours before failing. Along with that, the vibration, sound, and temperature values increase indicating impending failure.

A scatter plot of the rotation data shows this visually. The RPM of a fan falls to 400 from the normal average of 600.

👁 Image

Based on this, we can easily train a simple TensorFlow logistic regression model to predict the faulty fan. We start by getting rid of the timestamp and the deviceID column.

dataframe = pandas.read_csv("../data/fan.csv", header=None,skiprows=1)
del dataframe[0]
del dataframe[1]

The dataset is then split into train and test data after separating the features and label.

dataset = dataframe.values
X = dataset[:,0:4].astype(float)
y = dataset[:,4]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)

We then create a neural network with 4 layers that does logistic regression.

model = Sequential()
model.add(Dense(60, input_dim=4, activation='relu'))
model.add(Dense(30, activation='relu'))
model.add(Dense(10, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X_train, y_train, epochs=250, batch_size=32, verbose=0)

Finally, the model is saved and evaluated.

model.save("../model")
loss, acc = model.evaluate(X_test, y_test, verbose=0)
print('Test Accuracy: %.3f' % acc)

The TensorFlow model saved to the disk is loaded by the inference service to perform predictions on the data sent by the predictor microservice.

Time-Series Data and Visualization

An instance of InfluxDB is connected to Mosquitto via Telegraf. This configuration gives us an elegant mechanism of ingesting time-series data into InfluxDB without writing a line of code.

Below is the Telegraf configuration that bridges Mosquitto with InfluxDB.

 [agent]
 interval = "10s"
 round_interval = true
 metric_batch_size = 1000
 metric_buffer_limit = 10000
 collection_jitter = "0s"
 flush_jitter = "0s"
 debug = false
 quiet = false
 hostname = ""
 omit_hostname = true

 [[outputs.influxdb]]

 urls = ["http://influxdb:8086"]
 database = "fan"
 retention_policy = "autogen"
 precision = "s"
 timeout = "5s"

 [[outputs.file]]
 files = ["stdout"]
 data_format = "influx"

 [[inputs.mqtt_consumer]]
 servers = ["tcp://mosquitto:1883"]
 qos = 0

 topics = [
 "fan/#"
 ]

 insecure_skip_verify = true
 client_id = ""
 data_format = "json"
 name_override = "fan"
 tag_keys = ["deviceID"]
 json_string_fields = ["rotation","temperature","vibration","sound","fault"]

The time-series data can be now queried from InfluxDB.

👁 Image

Finally, we connect a Grafana dashboard to InfluxDB to build a beautiful visualization for our AIoT solution.

👁 Image

In the next part of this tutorial, I will discuss the deployment architecture along with the storage and network considerations based on K3s, Calico, and Portworx. Stay tuned.

Janakiram MSV’s Webinar series, “Machine Intelligence and Modern Infrastructure (MI2)” offers informative and insightful sessions covering cutting-edge technologies. Sign up for the upcoming MI2 webinar at http://mi2.live.

TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Statement.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.