# README
k8sres
Create custom metrics from Kubernetes Resources.
Kubernetes Resource Metrics Server
This project implements a simple HTTP server that exposes Kubernetes resource metrics via a Prometheus-compatible endpoint. It utilizes Prometheus client libraries along with custom Kubernetes metric collection to facilitate monitoring in Kubernetes environments.
Features
- JSON Logging: Structured logging using Logrus.
- Environment-Based Debugging: Debug level logging can be enabled through an environment variable.
- Prometheus Metrics Endpoint: Exposes Kubernetes resource metrics at
/metrics
. - Kubernetes Configuration: Dynamically loads Kubernetes configuration for accessing the cluster.
Getting Started
Prerequisites
- Go 1.15 or higher
- Access to a Kubernetes cluster
- Prometheus server (for scraping metrics from this service)
Installation
-
Clone the repository:
git clone https://github.com/your-repo/kubernetes-metrics-server.git cd kubernetes-metrics-server
-
Build the application:
go build -o metrics-server
Set Environment Variables:Optionally, you can enable detailed debug logs by setting the DEBUG environment variable.
export DEBUG=true
- Running the Server Execute the binary to start the server:
./metrics-server
The server will start listening on the default port 9805. You can access the metrics at http://localhost:9805/metrics.
-
Configuration The service uses the K8sResourceMetricYaml file for setting up resource metric collectors. Ensure this file is correctly configured with the metrics you want to collect.
-
Deployment
To deploy this service in a Kubernetes cluster, you can use the provided Dockerfile to containerize the application and then deploy it using Kubernetes resources like Deployment, Service, and potentially an Ingress.
- Contributing
Contributions are welcome. Please open an issue to discuss proposed changes or open a pull request with your updates.