Skip to content

qba73/inspector

Repository files navigation

Inspector

Go Reference GitHub go.mod Go version Go Report Card GitHub Tests OpenSSF Best Practices

Magical gopher logo

Before using inspector you need to have kubectl binary installed and configured (config file ${HOME}/.kube/config).

inspector is a CLI tool and a Kubernetes plugin for running Cluster and Ingress Conroller diagnostics, collecting Cluster and Ingress Controller logs and generating reports.

How to install inspector

How to install it and use as a CLI tool

  1. Install Go binary

    go install github.com/qba73/inspector/cmd/inspector@latest
  2. Get help:

    inspector -h
    Usage:
    
       inspector [-v] [-h] [-n] <namespace>
    
    Collect K8s and NIC diagnostics in the given namespace
    
    In verbose mode (-v), prints out progess, steps and all data points to stdout.
  3. Collect data points from default namespace

    inspector -n default > default.json
  4. Collect data points from nginx-ingress namespace

    inspector -n nginx-ingress > nginx-ingress.json

How to install it and use as a kubectl plugin

  1. Clone the repo.

  2. Build inspector.

    go build -o kubectl-inspector ./cmd/inspector/main.go
  3. Copy the binary to a dir in your $HOME, for example:

    cp kubectl-inspector /usr/local/bin/
  4. Verify if the kubectl discovers the plugin:

    kubectl plugin list
    [...]
    /usr/local/bin/kubectl-inspector
  5. Verify inspector can be run using kubectl:

    kubectl inspector -h
    
    Usage:
    
       inspector [-h] [-v] [-n] namespace
    
    Collect K8s and Ingress Controller diagnostics in the given namespace.
    
    In verbose mode (-v), prints out progess, steps and all data points to stdout.
  6. Collect data points from default namespace

    Note that inspector's default namespace is default.

    kubectl inspector > default.json
  7. Collect data points from nginx-ingress namespace

    kubectl inspector -n nginx-ingress > nginx-ingress.json

How it works

The program collects K8s cluster and NGINX Ingress Controller diagnostics data. It prints out data in the JSON format to the stdout. This allows the output to be piped to other tools (for example jq) for further parsing and processing.

Collected data points

Currently inspector collects following data points:

  • K8s version
  • K8s cluster id
  • Number of nodes in the cluster
  • K8s platform name
  • Pods
  • Logs from pods
  • Events
  • ConfigMaps
  • Services
  • Deployments
  • StatefulSets
  • ReplicaSets
  • Leases
  • CRDs
  • IngressClasses
  • Ingresses
  • IngressAnnotations

Planned:

  • Nodes metrics
  • Ingress Controller stats, options and configuration

Future releases will add support for collecting K8s Gateway API diagnostics.

Contributing

If you'd like to contribute to Inspector, please read the Contributing guide.

Gopher image by Gopherize.me