A lightweight, efficient Kubernetes monitoring solution that provides real-time insights into cluster resource utilization.
- Real-time monitoring of Kubernetes cluster resources
- Node-level metrics collection (CPU, Memory)
- Pod-level metrics collection (CPU, Memory per container)
- Automatic metrics collection every 30 seconds
- In-cluster deployment using Kubernetes DaemonSet
- RBAC-compliant with minimal required permissions
- Kubernetes cluster (v1.28+)
- Metrics Server installed and running
- Docker (for building the image)
- Go 1.21+ (for development)
- kubectl configured with cluster access
# Start Minikube with metrics-server enabled
minikube start
minikube addons enable metrics-server
# Deploy K-Monitor
./deploy-minikube.ps1 # For Windows
# OR
./deploy-minikube.sh # For Linux/Mac- Build the Docker image:
docker build -t k-monitor:latest .- Apply the RBAC configuration:
kubectl apply -f k8s/rbac.yaml- Deploy the application:
kubectl apply -f k8s/deployment.yamlK-Monitor consists of the following components:
- Metrics Collector: Core component that interfaces with the Kubernetes Metrics API
- RBAC Configuration: ServiceAccount, ClusterRole, and ClusterRoleBinding for secure access
- Deployment: Kubernetes deployment configuration for running the monitor
k-monitor/
├── Dockerfile
├── go.mod
├── go.sum
├── main.go
├── pkg/
│ └── collector/
│ └── metrics.go
└── k8s/
├── deployment.yaml
└── rbac.yaml
The application can be configured through the following methods:
- In-Cluster Configuration: Automatically used when deployed inside Kubernetes
- Kubeconfig: Falls back to local kubeconfig when running outside the cluster
K-Monitor collects the following metrics:
- CPU Usage
- Memory Usage
- Per-container CPU Usage
- Per-container Memory Usage
- Clone the repository:
git clone https://github.com/prathameshrr/k-monitor.git
cd k-monitor- Install dependencies:
go mod download- Run locally:
go run main.goBuild the Docker image:
docker build -t k-monitor:latest .- Apply RBAC configuration:
kubectl apply -f k8s/rbac.yaml- Deploy the application:
kubectl apply -f k8s/deployment.yamlView the metrics:
kubectl logs -f deployment/k-monitor-
Pod in CrashLoopBackOff:
- Check if metrics-server is running
- Verify RBAC permissions
- Check pod logs for errors
-
No Metrics Data:
- Ensure metrics-server is properly configured
- Check network policies
- Verify API server access
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
- Kubernetes Metrics API
- client-go library
- metrics-server project
