A Cloud-Native validator for Kubernetes Secret references.
Project description
Kuberef
Kuberef is a lightweight, cloud-native CLI tool designed to validate Kubernetes Secret references before you deploy. It bridges the gap between static YAML manifests and your live cluster state, preventing "silent failures" caused by missing secrets or incorrect data keys.
Features
-
Batch & Recursive Spec Discovery: Automatically scans single files or entire directories for Kubernetes resources including
Deployments,StatefulSets,Jobs, andCronJobsto find nested Pod specifications. -
Deep-Key Validation: Verifies not only that a Secret exists, but that the specific keys required are present in the Secret's data, preventing runtime container crashes.
-
Comprehensive Pattern Matching: Audits all common Secret reference patterns, including
env.valueFrom, bulkenvFromloads,volumes(Secret mounts), andimagePullSecrets. -
Live Cluster Auditing: Performs real-time cross-referencing against the live Kubernetes API using your active
kubeconfigcontext. -
Pre-Flight Environment Checks: Validates cluster connectivity and ensures the target namespace exists before executing the audit to prevent false positives.
-
Global Automation Reporting: Built with
Typerto provide aggregate summary statistics accross multiple files and standard exit codes (0 for success, 1 for failures/warnings) to automatically break pipeline builds on misconfigurations. -
Rich Terminal UI: Utilizes the
Richlibrary to deliver a clean, color-coded terminal interface with clear PASS/FAIL/WARNING status tables for every file scanned.
Installation
From TestPyPI (Current Release)
⚠️ Note: Since this is a TestPyPI release, please use the installation command below to ensure all dependencies (PyYAML, Typer, etc.) are pulled correctly from the main PyPI registry:
pip install --no-cache-dir --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ kuberef
From Source (Development)
If you want to run the tool from source or contribute:
git clone https://github.com/hudazaan/kuberef.git
cd kuberef
poetry install
poetry run kuberef path/to/your/k8s-manifest.yaml
Using Docker (Containerized)
If you don't want to install Python locally, you can run Kuberef as a container. You must mount your local kubeconfig and the directory containing your manifests:
git clone https://github.com/hudazaan/kuberef.git
cd kuberef
# Build Image
docker build -t kuberef .
# Run the audit
docker run -it --rm \
--network="host" \
-v ~/.kube/config:/root/.kube/config \
-v $(pwd):/app \
kuberef /app/test-manifests --namespace default
Verification Commands (For Debugging):
# Inspect package
pip show kuberef
# Run as a module
python -m kuberef --help
Usage
Audit a single manifest against the default namespace:
kuberef deployment.yaml
Audit an entire directory of manifests:
kuberef ./k8s-manifests/
Audit a specific namespace by using -n or --namespace flag to validate secrets:
kuberef deployment.yaml --namespace production
General Syntax to add path to your Kubernetes manifest:
kuberef <YOUR_FILE>.yaml --namespace <YOUR_NAMESPACE>
Example Output:

Technical Architecture
- Recursive Discovery Engine: Implements a depth-first search to locate Pod specifications across all resource types (
Deployments,Jobs,CronJobs, etc). - Live Validation: Interfaces with the
kubernetesPython client to perform real-timeread_namespaced_secretcalls for existence and key-level verification. - Stream Parser: Leverages
PyYAMLandsafe_load_allto parse multi-document manifests in a single pass. - Directory Processing Engine: Implements a file-system crawler that identifies and filters YAML manifests for batch processing across directories.
- CLI Framework: Built on
Typerto provide a high-performance interface with accumulated state counters for global multi-file reporting and standard Unix exit codes for automation. - CI/CD Pipeline: Integrated with GitHub Actions to automatically build and test the tool on every code push, ensuring production readiness on Cloud-hosted runners.
- Containerization: Multi-stage Docker build optimized for minimal image size.
Testing
Kuberef includes a suite of unit tests to ensure the recursive discovery engine and parser remain stable. These tests use pytest and mock data to verify logic without requiring a live cluster.
To run the tests:
poetry run pytest
Verification Results:
- Recursive Discovery: Confirms secrets are found deep within nested controllers.
- Resilience: Ensures the tool handles empty or non-Kubernetes YAML gracefully.
🤝 Contributing
Contributions are welcome!
- Fork the Project
- Create your Feature Branch (
git checkout -b YOUR-BRANCH-NAME) - Run tests (
poetry run pytest) - Commit your Changes (
git commit -m 'your message') - Push to the Branch (
git push origin YOUR-BRANCH-NAME) - Open a Pull Request
Author
Built with ❤️ by Huda Naaz
📄 License
Distributed under the MIT License. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kuberef-0.1.9.tar.gz.
File metadata
- Download URL: kuberef-0.1.9.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.14.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03e17c45a7d8921b962e99a3e1f27d4cd4883abed74a319e2865fc100d4fb8b9
|
|
| MD5 |
26c4153f59a57b2e5d2d2e6cacf65d53
|
|
| BLAKE2b-256 |
a049ef929eb85c0dc7eace582e7be149b407ad5cd2ff51610b98e39f4fae66e5
|
File details
Details for the file kuberef-0.1.9-py3-none-any.whl.
File metadata
- Download URL: kuberef-0.1.9-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.14.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82448b3125c34356aa11ffdae03189ed8921439f0e06c9f127cd3ee1240f63e7
|
|
| MD5 |
4dc5e68d6fb76804270ea19d230b2657
|
|
| BLAKE2b-256 |
fe4403a537c384a1405998f8872936fc65469e786698444d3e0d9842120e5851
|