Skip to content

Microservice architecture - A gas company requires retrieving the information from its tank sensors and creating a report.

Notifications You must be signed in to change notification settings

tlacuilose/gas-sensores

Repository files navigation

About

Microservice architecture

A gas company requires retrieving the information from its tank sensors and creating a report.

Two microservices

  • sensores-service: A flask API that using a proxy retrieves the information of all tanks gas contents. /data
  • reportes-service: A flask API that using a builder pattern, generates a report that requires fetching the sensores-serivice through http, retrieving previous data from a db, generating the report and sending it. /reporte

Built using

  • Flask: for both API
  • minikube: for simulating a local kubernetes cluster
  • kubectl: for managing services and pods
  • docker: for creating images

Repository includes .yml k8s deployement files and Dockerfiles for the images

Steps

For reportes-service/sensores-connection.py, set environment variable SENSORES_SERVICE_URL=http://localhost:8000/data

in secrets.yml encode all values to base64

echo -n <url> | base64

Before building images always run eval, otherwise images from minikube will not be affected.

eval $(minikube docker-env)
docker build -t reportes-service reportes-service/.
docker build -t sensores-service sensores-service/.
kubectl delete -f reportes-deployment.yml
kubectl apply -f secrets.yml
kubectl apply -f reportes-deployment.yml
kubectl apply -f sensores-deployment.yml
minikube service reportes-service 

Info de kubernetes

Obtener la ip publica del servicio

kubectl get svc

Todos los servicios en k8s

kubectl get all

Describir un servicio

kubectl describe svc <nombre>

Revisar los pods activos

kubectl get pods -o wide

Abrir un pod en bash

kubectl exec --stdin --tty <nombre-del-pod> -- /bin/bash

Eliminar un pod revisar orchestration, se crea un pod con ip diferente

kubectl delete pod <nombre>

Monitoring

View all installed and available metrics

minikube addons list

Enable metrics-server for monitoring pods resources.

minikube addons enable metrics-server

View in dashboard with

minikube dashboard --url

View in command line

kubectl top pods

Install logviewer

minikube addons enable logviewer

Logs can be visualized using

kubectl logs service/reportes-service --all-containers

Orchestration

A set of independent, composable control processes that continuously drive the current state towards the provided desired state.

Monitoring

Using metrics-server to see resources consumption. Using logviewer to see services logs.

About

Microservice architecture - A gas company requires retrieving the information from its tank sensors and creating a report.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published