Kubor is a tool to view and analyze resource usage metrics of Kubernetes cluster. It groups usage metrics on namespace level and calculates hourly usage averages from total resources available. It abstracts cluster resources into four core metrics (cpu, memory, network and storage) for which monthly costs can be set. This can be used to help generating invoices in multi-tenant environments.
Application consists of following components:
- Frontend (React) that displays cluster usage metrics and costs.
- Backend (Node.js) that serves static frontend assets, provides REST API for frontend, acts as a reverse proxy for Prometheus and handles metrics collection.
- Database (SQLite) that stores cluster cost data and usage metrics.
- Prometheus for resource usage metrics
- Configured Persistent Volume for database
Kubor requires access to Prometheus to get resource usage metrics. For local development a simple port forward to Prometheus is sufficient. Another option is to deploy the application container to (local minikube) cluster and then interact with it using tools like Telepresence.
Run frontend in development mode
cd client
yarn run start:local
Run backend that provides REST API for frontend, acts as reverse proxy for Protmetheus and collects cluster metrics.
cd server
yarn run start:local
Finally proxy traffic to Prometheus using kubectl
.
kubectl -n monitoring port-forward prometheus-k8s-0 9090
Backend will automatically initialize database and run migrations. You can seed cluster cost data by issuing following command in server
directory
./node_modules/knex/bin/cli.js seed:run
For this, we'll be using local container registry inside Kubernetes. I will follow steps mentioned in this great blog post that covers setting up the container registry. We also need to start minikube
with insecure registry flag to enable insecure communication between the docker engine and registries.
minikube start --insecure-regisry localhost:5000
Deploy container registry.
kubectl apply -f deploy/local-registry.yml
Access Docker daemon inside minikube
eval $(minikube docker-env)
Build Docker image.
./build.sh
Tag it and push it to our registry
docker tag kubor:<version> localhost:5000/kubor:<version>
docker push localhost:5000/kubor:<version>
Edit following lines in file deploy/kubor.yaml
:
- 45:
image
to match the image version - 53:
value
ofPROMETHEUS_URL
to match your Prometheus deployment
and finally deploy to Kubernetes cluster
kubectl apply -f deploy/kubor.yaml
Get URL to access the app
minikube service kubor --url
Build Docker image including server and static assets
./build.sh
Edit image
and PROMETHEUS_URL
in kubernetes/kubor.yaml
accordingly and then
kubectl apply -f kubernetes/kubor.yaml