repository
0.0.0-20250216012303-85908fc167ee
Repository: https://github.com/mbergo/k8s-microlens.git
Documentation: pkg.go.dev
# README
k8s-microlens π
A lightweight, fast, and efficient Kubernetes resource visualization tool that provides a clear and hierarchical view of your cluster resources and their relationships.
Features β¨
- Resource Discovery: Automatically maps relationships between different Kubernetes resources
- Clear Visualization: Presents resources in a clear, hierarchical tree structure
- Color-Coded Output: Uses colors and symbols for better readability
- Comprehensive Resource Coverage:
- Ingresses (with TLS details)
- Services (with endpoint information)
- Deployments (with replica details)
- Pods (with status and node assignment)
- ConfigMaps (with usage tracking)
- Secrets (with secure usage information)
- HPAs (with scaling metrics)
Installation π¦
Prerequisites
- Go 1.19 or later
- Access to a Kubernetes cluster
- Valid kubeconfig file
From Source
# Clone the repository
git clone https://github.com/mbergo/k8s-microlens.git
cd k8s-microlens
# Build the binary
go build -o k8s-microlens cmd/mapper/main.go
# (Optional) Move to PATH
sudo mv k8s-microlens /usr/local/bin/
Using Go Install
go install github.com/mbergo/k8s-microlens@latest
Usage π
Basic Usage
# Show resources in all namespaces
k8s-microlens
# Show resources in a specific namespace
k8s-microlens -n default
# Exclude specific namespaces
k8s-microlens --exclude-ns kube-system --exclude-ns kube-public
Command Line Options
Flags:
-n, --namespace string Process only the specified namespace
--exclude-ns string Exclude specified namespaces (can be specified multiple times)
-h, --help Show help message
-v, --version Show version information
Example Output π
Kubernetes MicroLens
----------------------------------------
Generated at: 2024-11-18 15:04:05
External Traffic
β
[Ingress Layer]
βββ β Ingress/frontend-ingress
β β TLS Enabled
β β Service/frontend-svc via host: example.com
βββ β Ingress/api-ingress
β Service/api-svc via host: api.example.com
[Service Layer]
βββ β Service/frontend-svc
β βΉ Type: ClusterIP
β βΉ Ports: 80β8080/TCP
β β Pod/frontend-pod-1
β β Running
βββ β Service/api-svc
βΉ Type: ClusterIP
βΉ Ports: 8080β8080/TCP
β Pod/api-pod-1
β Running
Output Legend π
β
Resource indicatorβ
Success/Enabled statusβ
Error/Disabled statusβΉ
Informationβ
Relationship/Connectionβββ
Tree branchβββ
Last tree branch
Project Structure π
.
βββ cmd/
β βββ mapper/
β βββ main.go # Application entry point
βββ internal/
β βββ common/
β βββ formatting.go # Output formatting utilities
β βββ resources.go # Resource processing logic
βββ .gitignore
βββ go.mod
βββ go.sum
βββ LICENSE
βββ README.md
Development π οΈ
Running Tests
go test ./...
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Coding Style
Follow Go best practices and conventions:
- Use
gofmt
for code formatting - Follow Effective Go guidelines
- Write tests for new functionality
- Document exported functions and types
Troubleshooting π§
Common Issues
-
Permission Errors
Error getting resources: forbidden
Solution: Ensure your kubeconfig has sufficient permissions
-
Kubeconfig Not Found
Error building kubeconfig
Solution: Set KUBECONFIG environment variable or ensure config exists in
~/.kube/config
-
Connection Issues
Error connecting to cluster
Solution: Verify cluster access and network connectivity
Roadmap πΊοΈ
- Support for Custom Resource Definitions (CRDs)
- Export functionality (JSON, YAML, DOT formats)
- Interactive mode with real-time updates
- Resource metrics integration
- Custom output formatting templates
- WebUI interface
License π
This project is licensed under the MIT License - see the LICENSE file for details.
Support β€οΈ
If you find this project useful, please consider:
- Starring the repository
- Reporting issues
- Contributing to the code
- Sharing with others
Author βοΈ
Marcus Bergo
- Twitter: @mbergo
- LinkedIn: Marcus Bergo
Acknowledgments π
- The Kubernetes community
- Contributors to the project
- Users who provide feedback and suggestions
Made with β€οΈ by Marcus Bergo and contributors