A powerful CLI tool to scan Kubernetes clusters for health issues, misconfigurations, and security risks.
Project description
๐ฅ k8s-health-checker
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
โจ 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
- Portfolio: sanjaysundarmurthy-portfolio.vercel.app
- GitHub: @SanjaySundarMurthy
- LinkedIn: Sanjay S
โญ If this tool helps you, give it a star on GitHub!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd5291abfa24b667cab1ae2984269f976aef4c8587627aa6a0cbad1158572b24
|
|
| MD5 |
88e107d4bdfb0af8afdc4ba46b846910
|
|
| BLAKE2b-256 |
384fb4338245294f5f024e45753571d5a85162a56c70a851e0b4e25549d2b0d8
|
File details
Details for the file k8s_health_checker-1.0.0-py3-none-any.whl.
File metadata
- Download URL: k8s_health_checker-1.0.0-py3-none-any.whl
- Upload date:
- Size: 28.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1282945df1e09492b592197bec0d1227a861a10c67dd44b332630fe8c83e2892
|
|
| MD5 |
b171f7cebe61c0d9ab49aca87ea849db
|
|
| BLAKE2b-256 |
cf4881d2d6397b97738492b1fd5a85565b89dabd673845de852889a5549ce1ba
|