kube-secrets-exporter is a Prometheus exporter written in Go that retrieves information about Kubernetes secrets and exposes metrics for monitoring. It allows you to track the last modification time of secrets, scan duration, and the number of modifications detected in secrets.
To build kube-secrets-exporter from source, you need to have Go installed. Follow these steps:
Clone the Repository:
git clone https://github.com/dcristobalhMad/kube-secrets-exporter.git
Build the Binary:
cd kube-secrets-exporter
go build -o kube-secrets-exporter cmd/main.go
If you have a .kube/config file to access a Kubernetes cluster, you can run kube-secrets-exporter directly without building the Docker image. Follow these steps:
Ensure you have kubectl Installed:
If you don’t have kubectl installed, follow the instructions here to install it.
Set Up Kubernetes Configuration:
Ensure that your .kube/config file is correctly configured to access your Kubernetes cluster.
Run the Binary:
./kube-secrets-exporter
Once kube-secrets-exporter is running, you can access the Prometheus metrics by opening a web browser and navigating to http://localhost:8080/metrics.
kube-secrets-exporter uses the Kubernetes client to communicate with the cluster. It automatically detects whether it is running inside a Kubernetes cluster or uses the kubeconfig file if running outside the cluster.
The following Prometheus metrics are exposed by kube-secrets-exporter:
kube_secret_last_modified_time: The Unix timestamp of the last modification time of the secret.kube_secret_scan_duration_seconds: Duration of the last scan for checking secret modifications in seconds.kube_secret_modifications_total: Total number of modifications detected in secrets.kube_secret_last_scan_success: Indicates if the last scan was successful (1 for success, 0 for failure).Contributions to kube-secrets-exporter are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.