Skip to main content

A lightweight CLI cluster health diagnostic tool for Kubernetes.

Project description

kdoctor 🩺

PyPI version License: MIT

kdoctor is a lightweight, terminal-based CLI diagnostic and inspection tool for Kubernetes clusters built with Python, Typer and Rich.

It provides instant visibility into cluster resources (Nodes, Deployments, Pods, Events) and runs automated diagnostic checks to detect cluster issues and surface actionable recommendations.


⚡ Features

  • Automated Diagnostics (diagnose) – Executes a 5-point cluster health check covering:

    • Kubernetes API connectivity
    • Node readiness
    • Deployment replica health
    • Pod execution phases
    • Warning event detection
  • Targeted Resource Inspection

    • Inspect a specific deployment
    • Inspect a specific pod
    • Automatically fetch recent pod logs
  • Rich Cluster Tables

    • Nodes
    • Deployments
    • Pods
    • Events
  • Actionable Recommendations

    • Aggregates detected issues
    • Suggests the next troubleshooting commands

📋 Prerequisites

Before using kdoctor, ensure you have:

  1. Python 3.9+
  2. Access to a Kubernetes cluster
  3. A valid Kubernetes configuration:
~/.kube/config

or the KUBECONFIG environment variable configured.

Supported clusters include:

  • Minikube
  • Amazon EKS
  • Google GKE
  • Azure AKS
  • Any CNCF-compliant Kubernetes cluster

📦 Installation

Option 1 – Install from PyPI (Recommended)

pip install kdoctor

Windows Users

If kdoctor is not recognized after installation, add Python's Scripts directory to your PATH.

Example:

C:\Users\<User>\AppData\Local\Programs\Python\Python3x\Scripts

Option 2 – Install with pipx

Install as an isolated CLI application:

pipx install kdoctor

🚀 Commands

Diagnose Cluster

Runs a complete health scan.

kdoctor diagnose

Example output:

Running cluster diagnostics...

✔ Kubernetes API reachable
✔ Nodes Healthy
❌ 1 Deployment(s) Not Ready
✔ All Pods Running
❌ 10 Warning Events detected

Diagnosis:
• 1 deployment(s) have unavailable replicas.

Recent Warning Events suggest:
Back-off restarting failed container storage-provisioner

Recommendation:
Inspect deployment status:

kdoctor deployment argocd-applicationset-controller -n argocd

Inspect a Deployment

Shows deployment health and replica status.

kdoctor deployment <DEPLOYMENT_NAME> -n <NAMESPACE>

Example:

kdoctor deployment argocd-applicationset-controller -n argocd

Example output:

Deployment Details

Name: argocd-applicationset-controller
Namespace: argocd

Replicas:
0/1 Ready
1 Updated

Status:
⚠ Degraded (Unavailable Replicas)

Inspect a Pod

Displays pod information and fetches the latest logs.

kdoctor pod <POD_NAME> -n <NAMESPACE>

Example:

kdoctor pod coredns-7d764666f9-8p2xl -n kube-system

Example output:

Pod Details

Name: coredns-7d764666f9-8p2xl
Namespace: kube-system

Phase:
Running

Node:
minikube

Fetching last 20 log lines...

[INFO] plugin/ready: Still waiting on: "kubernetes"
[INFO] CoreDNS-1.10.1
[INFO] plugin/kubernetes: CoreDNS is running

List Deployments

Lists deployments across every namespace.

kdoctor deployments

Example:

Kubernetes Deployments

Namespace      Deployment                              Replicas
---------------------------------------------------------------
argocd         argocd-applicationset-controller        0/1
argocd         argocd-server                           1/1
default        my-release-local-demo-app               2/2
kube-system    coredns                                 1/1

List Pods

Lists all pods and their execution phase.

kdoctor pods

Example:

Kubernetes Pod Registry

Namespace      Pod Name                                Status
--------------------------------------------------------------
argocd         argocd-server-xxxx                      Running
default        my-release-local-demo-app-xxxx          Running
kube-system    coredns-xxxx                            Running
kube-system    storage-provisioner                     CrashLoopBackOff

List Nodes

Displays node information.

kdoctor nodes

Example:

Cluster Nodes

Name        Status    Role            Internal IP      Version
---------------------------------------------------------------
minikube    Ready     control-plane   192.xxx.xx.2     v1.28.3

View Cluster Events

Displays recent Kubernetes events.

kdoctor events

Example:

Cluster Events

Namespace     Type      Reason      Message
----------------------------------------------
kube-system   Warning   BackOff     Back-off restarting...
default       Normal    Scheduled   Successfully assigned...

Show Version

Displays the connected Kubernetes API version.

kdoctor version

Example:

Kubernetes API Server Version: v1.28.3

📄 License

Distributed under the MIT License.

See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kdoctor-0.3.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kdoctor-0.3.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file kdoctor-0.3.0.tar.gz.

File metadata

  • Download URL: kdoctor-0.3.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for kdoctor-0.3.0.tar.gz
Algorithm Hash digest
SHA256 57a001860a9d65109aa47ba92b9dac25bc015ca69773caa8a0174e0a315e7c1d
MD5 7fcab07f91511fae75a8b03f70646b85
BLAKE2b-256 6f9d48964ff7fcccb4d7cb635775e16c162d786ff49e0193ba7ef62875fe545c

See more details on using hashes here.

File details

Details for the file kdoctor-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: kdoctor-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for kdoctor-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14adaf2719bb571cfaabd29fd043d76071d89b7f8009d6fe691fda55afc64b38
MD5 af8ed681d4345ea61c2e68e50ebee878
BLAKE2b-256 936c8124e15cb40990c6943fcd05a98c658341625791c19c7f30abd5b6b3e8da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page