Categorygithub.com/mbergo/k8s-microlens
repository
0.0.0-20250216012303-85908fc167ee
Repository: https://github.com/mbergo/k8s-microlens.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# 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.

Go Report Card License: MIT Build Status CodeFactor

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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

  1. Permission Errors

    Error getting resources: forbidden
    

    Solution: Ensure your kubeconfig has sufficient permissions

  2. Kubeconfig Not Found

    Error building kubeconfig
    

    Solution: Set KUBECONFIG environment variable or ensure config exists in ~/.kube/config

  3. 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

Acknowledgments πŸ™

  • The Kubernetes community
  • Contributors to the project
  • Users who provide feedback and suggestions

Made with ❀️ by Marcus Bergo and contributors