Skip to main content

A powerful CLI tool to scan Kubernetes clusters for health issues, misconfigurations, and security risks.

Project description

๐Ÿฅ k8s-health-checker

CI Python 3.9+ License: MIT

A powerful CLI tool to scan Kubernetes clusters for health issues, misconfigurations, and security risks.

Run one command. Get a complete health report with severity ratings, fix suggestions, and a health score โ€” right in your terminal.

$ k8s-health scan

k8s-health-checker demo


โœจ Features

Feature Description
๐Ÿซ› Pod Health CrashLoopBackOff, Pending, Failed, OOMKilled, high restarts
๐Ÿ–ฅ๏ธ Node Health NotReady, DiskPressure, MemoryPressure, PIDPressure, cordoned
๐Ÿ“Š Resource Limits Missing CPU/memory requests and limits
๐Ÿฉบ Health Probes Missing readiness and liveness probes
๐Ÿ”’ Security NetworkPolicies, privileged containers, service accounts
โš™๏ธ Workloads Deployment/StatefulSet/DaemonSet replicas, stuck rollouts
๐Ÿ“ˆ Autoscaling HPA at max, min=max (disabled autoscaling)
๐ŸŽฏ Health Score 0-100 score with letter grade (A-F)
๐ŸŽจ Beautiful Output Rich terminal tables with colors and icons
๐Ÿ“„ JSON Export Pipe results to other tools or dashboards
๐ŸŽฎ Demo Mode Try instantly โ€” no cluster needed

๐Ÿš€ Quick Start

Install

pip install k8s-health-checker

Or install from source:

git clone https://github.com/SanjaySundarMurthy/k8s-health-checker.git
cd k8s-health-checker
pip install -e .

Try It (No Cluster Needed)

k8s-health scan --demo

This runs a full scan with realistic demo data โ€” perfect for trying the tool before connecting to a real cluster.

Scan Your Cluster

# Full cluster scan
k8s-health scan

# Scan a specific namespace
k8s-health scan -n production

# Scan specific categories only
k8s-health scan -c pods -c nodes

# JSON output (pipe to jq, file, or API)
k8s-health scan -o json
k8s-health scan -o json > report.json

# Just the health score
k8s-health score

๐Ÿ“‹ Prerequisites

Requirement Details
Python 3.9 or higher
kubectl Configured with access to your cluster
RBAC Cluster-wide read access (or namespace-scoped)

For demo mode, only Python is needed โ€” no cluster, no kubectl, no credentials.


๐Ÿ” What It Checks

๐Ÿซ› Pods

  • CrashLoopBackOff โ€” containers crash-looping (CRITICAL)
  • OOMKilled โ€” containers killed by OOM killer (CRITICAL)
  • Failed state โ€” pods in Failed phase (CRITICAL)
  • Excessive restarts โ€” containers with 20+ restarts (CRITICAL)
  • Elevated restarts โ€” containers with 5+ restarts (WARNING)
  • Pending โ€” pods stuck in Pending phase (WARNING)

๐Ÿ–ฅ๏ธ Nodes

  • NotReady โ€” nodes not accepting workloads (CRITICAL)
  • DiskPressure โ€” nodes running out of disk (CRITICAL)
  • MemoryPressure โ€” nodes running out of memory (CRITICAL)
  • PIDPressure โ€” too many processes on node (WARNING)
  • Cordoned โ€” nodes marked unschedulable (INFO)

๐Ÿ“Š Resources

  • Missing requests โ€” containers without CPU/memory requests (WARNING)
  • Missing limits โ€” containers without CPU/memory limits (WARNING)

๐Ÿฉบ Probes

  • Missing readiness probe โ€” traffic may hit unready containers (WARNING)
  • Missing liveness probe โ€” hung containers won't restart (INFO)

๐Ÿ”’ Security

  • Privileged containers โ€” full host access (CRITICAL)
  • Running as root โ€” UID 0 containers (WARNING)
  • No NetworkPolicies โ€” unrestricted pod communication (WARNING)
  • Default ServiceAccount โ€” pods using default SA (INFO)

โš™๏ธ Workloads

  • No ready replicas โ€” deployment completely down (CRITICAL)
  • Partial readiness โ€” not all replicas ready (WARNING)
  • Stuck rollout โ€” rollout not progressing (WARNING)
  • Single replica โ€” no high availability (INFO)
  • Scaled to zero โ€” intentionally or accidentally (INFO)

๐Ÿ“ˆ Autoscaling

  • HPA at max โ€” autoscaler can't add more replicas (WARNING)
  • HPA min = max โ€” autoscaling effectively disabled (INFO)
  • No HPAs โ€” no autoscaling configured (INFO)

๐Ÿ“Š Health Score

The tool calculates a health score from 0 to 100:

Severity Points Deducted
๐Ÿ”ด CRITICAL -8 per issue
๐ŸŸก WARNING -3 per issue
๐Ÿ”ต INFO -1 per issue
๐ŸŸข PASS 0
Score Grade Meaning
90-100 A Excellent โ€” minimal issues
75-89 B Good โ€” some improvements needed
60-74 C Fair โ€” several issues to address
40-59 D Poor โ€” significant problems
0-39 F Critical โ€” immediate attention needed

๐Ÿ”ง CLI Reference

Usage: k8s-health [OPTIONS] COMMAND [ARGS]...

๐Ÿฅ k8s-health-checker โ€” Scan Kubernetes clusters for health issues.

Commands:
  scan     Run a full health scan on your Kubernetes cluster.
  score    Show just the cluster health score (0-100).

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

k8s-health scan

Options:
  -n, --namespace TEXT        Scan a specific namespace only.
  -c, --category [pods|nodes|resources|probes|security|workloads|autoscaling]
                              Run only specific categories (repeatable).
  -o, --output [terminal|json]
                              Output format (default: terminal).
  --demo                      Run with demo data (no cluster needed).
  --help                      Show this message and exit.

k8s-health score

Options:
  -n, --namespace TEXT  Scan a specific namespace.
  --demo                Use demo data.
  --help                Show this message and exit.

๐Ÿค Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

# Clone and set up dev environment
git clone https://github.com/SanjaySundarMurthy/k8s-health-checker.git
cd k8s-health-checker
pip install -e ".[dev]"

# Run tests
pytest

# Lint
ruff check .

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


๐Ÿ‘ค Author

Sanjay S โ€” Senior DevOps Engineer


โญ If this tool helps you, give it a star on GitHub!

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

k8s_health_checker-1.0.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

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

k8s_health_checker-1.0.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file k8s_health_checker-1.0.0.tar.gz.

File metadata

  • Download URL: k8s_health_checker-1.0.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for k8s_health_checker-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bd5291abfa24b667cab1ae2984269f976aef4c8587627aa6a0cbad1158572b24
MD5 88e107d4bdfb0af8afdc4ba46b846910
BLAKE2b-256 384fb4338245294f5f024e45753571d5a85162a56c70a851e0b4e25549d2b0d8

See more details on using hashes here.

File details

Details for the file k8s_health_checker-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for k8s_health_checker-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1282945df1e09492b592197bec0d1227a861a10c67dd44b332630fe8c83e2892
MD5 b171f7cebe61c0d9ab49aca87ea849db
BLAKE2b-256 cf4881d2d6397b97738492b1fd5a85565b89dabd673845de852889a5549ce1ba

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