Giter VIP home page Giter VIP logo

node-flask-autoscaling-k8s's Introduction

k8s Http Autoscaling Service on Load Metrics Node/Flask

In that example you can find a simple way to deploy a service in node or flask that export self load metrics on prometheus. You can also find the way to use that metrics as target for the relative hpa controller. I'v also added the support of terraform for infrastracturing and HTTPS support.

The example is tested on GKE

Tecnologies

  • K8S
  • Helm
  • Terraform
  • PrometheusOperator
  • Grafana
  • Flask
  • Node
  • Go
  • Let's Encrypt

Project Structure:

  • Ingress Folder: ingress yaml and SSL config file
  • k8s Folder: yaml file for the 3: service, deployments and hpa
  • Monitoring Folder: conf for prometheus prometheus-adapter and grafana dashboard
  • rs Folder: source code for the 3 http service
  • Terraform Folder: terraform config file

Flask Metrics

For expose the prometheus load metrics i'v use the Prometheus Flask exporter starting a secondary web server that really collect the metrics and proxying the /metrics request from main server to metrics server.

Node Metrics

Expose prometheus metrics in node is more simple than flask, we can use the express-prometheus-bundle library and simple add some annotation on wich endpoint we won't expose.

Collect Metrics

Collect metrics with prometheus operator is simple we can just add a ServiceMonitor that target our metrics enpoint and the prometheus server will start collect data. You can find an exaple of a ServiceMonitor for product server in monitor folder. Make attention to matchLabels parameters and endpoint parameters.

Hpa on Custom Metrics

Dashboard

HTTPS

node-flask-autoscaling-k8s's People

Contributors

lucatiozzo91 avatar

Stargazers

 avatar  avatar  avatar  avatar

Forkers

swipswaps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.