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
- K8S
- Helm
- Terraform
- PrometheusOperator
- Grafana
- Flask
- Node
- Go
- Let's Encrypt
- 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
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.
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 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.