Automatización de la lectura de medidores analógicos de agua basada en AIoT para asegurar la normativa ambiental de la Universidad ICESI
Actualmente, el personal de Planta Física de la Universidad Icesi realiza registros manuales periódicos de los medidores de agua analógicos en la propiedad universitaria. La institución alberga diez aljibes, según la información proporcionada por la oficina de Planta Física y Gestión Ambiental. De estos, siete aljibes tienen acceso a la red de internet pública de la universidad, mientras que los otros tres, ubicados en zonas alejadas, no permiten la recolección automatizada de datos debido a la falta de acceso a esta red.
Desarrollar y validar un sistema tele-informático que permita automatizar el proceso de registro de lecturas de medidores analógicos de agua de los aljibes en la Universidad Icesi, para asegurar el cumplimiento de la normativa ambiental.
- Validar el funcionamiento del sistema AIoT de medición implementado previamente.
- Proponer una arquitectura que permita escalar el sistema AIoT en todo el campus de la Universidad Icesi.
- Implementar una infraestructura de comunicación y almacenamiento de datos para la medición de los nodos de AIoT.
- Desarrollar un módulo de reportes, alertas y descarga de datos basados en el consumo de agua de los aljibes.
-
Install Minikube
-
Starting Minikube
minikube start --memory 6144
-
Enable Metrics k8s api
minikube addons enable metrics-server
-
Install ingress controller (nginx), for accesing to cluster from single point (Security).
minikube addons enable ingress
-
Creation of namespaces
kubectl create namespace kafka kubectl create namespace monitoring kubectl create namespace apps
-
Set up the ingress to route traffic to the following services (Mqtt broker Bridge and Web App)
kubectl apply -f ./ingress/ingress-configmap.yaml -n ingress-nginx kubectl apply -f ./ingress/ingress-app-rules.yaml -n apps # Add the port to nginx service (Edit yaml) Node Port #- name: mqtt # port: 1883 # protocol: TCP # targetPort: 1883
-
Deploy mongo database rs cluster with its mongo express web ui
# Using Percona Server for MongoDB Operator # kubectl apply --server-side -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/v1.15.0/deploy/bundle.yaml --namespace apps # Using helm bitnami chart # helm upgrade --install mongodb -f ./storage/mongo-values.yaml oci://registry-1.docker.io/bitnamicharts/mongodb --namespace apps # kubectl apply -f ./storage/mongo-crd.yaml --namespace apps # helm uninstall mongodb --namespace apps # Using kubedb operator (https://appscode.com/issue-license/) Ask for a license txt free # helm install kubedb oci://ghcr.io/appscode-charts/kubedb \ # --version v2023.12.11 \ # --namespace apps --create-namespace \ # --set-file global.license=./license/kubedb.txt \ # --wait --burst-limit=10000 --debug # helm uninstall kubedb --namespace apps # kubectl create -f ./storage/mongo-operator.yaml --namespace apps # kubectl delete -f ./storage/mongo-operator.yaml --namespace apps # Using local mongo db - Move to storage folder ./generate.sh ./configure.sh admin kubectl apply -f ./storage/mongo-ui.yaml --namespace apps # Creation of cisterns db and measurements colleciton from ui
-
Create configmap for jmx metrics:
kubectl apply -f ./message-broker/kafka-metrics-config.yaml -n kafka kubectl apply -f ./message-broker/zookeeper-metrics-config.yaml -n kafka
-
Deploy Strimzi Kafka Operator (including ClusterRole, ClusterRoleBinding and CRDs):
kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka
-
Add our custom kafka resource and wait for it to be ready:
kubectl apply -f ./message-broker/kafka.yaml -n kafka
kubectl wait kafka/my-cluster --for=condition=Ready --timeout=300s -n kafka
- Topics Creation:
kubectl apply -f message-broker/topic.yaml -n kafka
- Create the kafka mongo connect (optional)
kubectl apply -f ./message-broker/kafka-mongo-connect.yaml -n kafka
- Create the kafka mongo sink (optional)
kubectl apply -f ./message-broker/kafka-mongo-sink.yaml -n kafka
- Create mqtt bridge
kubectl apply -f ./mqtt-broker -n kafka
- Create web tier and app tier
kubectl apply -f ./compute/client/cluster/app.yaml -n apps
kubectl apply -f ./compute/server/cluster/app.yaml -n apps
- Test our mqtt bridge
# pip install paho-mqtt
python3 ./testing/mqtt_test.py
- Deploy Prometheus Operator (including ClusterRole, ClusterRoleBinding and CRDs):
kubectl apply -f ./monitoring/prometheus/prometheus-operator-deployment.yaml -n monitoring --force-conflicts=true --server-side
- Deploy Prometheus
kubectl apply -f ./monitoring/prometheus/prometheus.yaml -n monitoring
- Deploy Pod monitor
kubectl apply -f ./monitoring/strimzi-pod-monitor.yaml -n monitoring
- Deploy grafana Enter in grafana app port forwarding 3000 to 3000 and the add prometheus datasource with the url http://prometheus-operated:9090 and also add dashboards from the folder ./dashboard (Exporter and kafka)
kubectl apply -f ./monitoring/grafana/grafana.yaml -n monitoring
- Kafka UI
helm repo add kafka-ui https://provectus.github.io/kafka-ui-charts
helm install kafka-ui kafka-ui/kafka-ui \
--set envs.config.KAFKA_CLUSTERS_0_NAME=my-cluster \
--set envs.config.KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=my-cluster-kafka-bootstrap:9092 \
--namespace kafka
- Port forward to grafana and prometheus
kubectl port-forward svc/grafana 3000:3000 -n monitoring
kubectl port-forward svc/prometheus-operated 9090:9090 -n monitoring
#App
kubectl -n apps delete -f ./compute/cluster/client/app.yaml
kubectl -n apps delete -f ./compute/cluster/server/app.yaml
#Broker
kubectl -n kafka delete -f ./mqtt-broker
kubectl -n kafka delete -f ./message-broker/topic.yaml
kubectl -n kafka delete -f ./message-broker/kafka-mongo-connect.yaml
kubectl -n kafka delete -f ./message-broker/kafka-mongo-sink.yaml
kubectl -n kafka delete -f ./message-broker/kafka.yaml
kubectl -n kafka delete -f 'https://strimzi.io/install/latest?namespace=kafka'
#Storage
kubectl -n apps delete -f ./storage/mongo-ui.yaml
kubectl -n apps delete -f ./storage/mongo.yaml
kubectl delete -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/v1.15.0/deploy/bundle.yaml --namespace apps
#Networking
kubectl -n apps delete -f ./ingress/ingress-app-rules.yaml
kubectl -n ingress-nginx delete -f ./ingress/ingress-configmap.yaml
#Isolation
kubectl delete namespace kafka
kubectl delete namespace monitoring
kubectl delete namespace apps
#Minikube
minikube addons disable ingress
minikube addons disable metrics-server
minikube stop
# Monitoring
helm uninstall kafka-ui -n kafka
kubectl -n monitoring delete -f ./monitoring/grafana/grafana.yaml
kubectl -n monitoring delete -f ./monitoring/strimzi-pod-monitor.yaml
kubectl -n monitoring delete -f ./monitoring/prometheus/prometheus.yaml
kubectl -n kafka delete -f ./message-broker/kafka-metrics-config.yaml
kubectl -n kafka delete -f ./message-broker/zookeeper-metrics-config.yaml
kubectl -n monitoring delete -f ./monitoring/prometheus/prometheus-operator-deployment.yaml