{"id":50683048,"url":"https://github.com/wlanboy/kubectl_analytics","last_synced_at":"2026-06-08T20:30:44.884Z","repository":{"id":363165801,"uuid":"1254273753","full_name":"wlanboy/kubectl_analytics","owner":"wlanboy","description":"A command-line tool for gathering and visualizing statistics about Kubernetes cluster resources","archived":false,"fork":false,"pushed_at":"2026-06-07T17:16:13.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-07T19:12:08.427Z","etag":null,"topics":["kubectl","mirror","oc","python","ressources","statistics","usage"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wlanboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-30T11:08:53.000Z","updated_at":"2026-06-07T17:16:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wlanboy/kubectl_analytics","commit_stats":null,"previous_names":["wlanboy/kubectl_analytics"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/wlanboy/kubectl_analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fkubectl_analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fkubectl_analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fkubectl_analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fkubectl_analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wlanboy","download_url":"https://codeload.github.com/wlanboy/kubectl_analytics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlanboy%2Fkubectl_analytics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34080025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubectl","mirror","oc","python","ressources","statistics","usage"],"created_at":"2026-06-08T20:30:42.768Z","updated_at":"2026-06-08T20:30:44.874Z","avatar_url":"https://github.com/wlanboy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kubectl analytics\n\nkubectl_analytics is a lightweight tool that analyzes Kubernetes logs, events, and resource states to provide actionable insights into cluster behavior.\nIt helps identify patterns, anomalies, and potential issues by aggregating and interpreting data directly from the Kubernetes API.\n\nThe tool focuses on fast, local analytics without requiring external services or complex observability stacks.\nIt is ideal for debugging, troubleshooting, and gaining a deeper understanding of what is happening inside your cluster.\n\nKey capabilities include:\n\n- Collecting and analyzing pod logs\n- Inspecting Kubernetes events to detect warnings and failure patterns\n- Summarizing resource states across namespaces\n- Highlighting anomalies or repeating error messages\n- Providing human‑readable diagnostics for faster troubleshooting\n\nThis makes kubectl_analytics a practical companion for:\n\n- Developers debugging workloads\n- Platform engineers analyzing cluster health\n- SREs investigating incidents\n\nAnyone who wants quick insights without deploying a full observability stack\n\n---\n\n## Commands\n\n### `kubectl-analytics crds`\n\nCRD adoption rate — how many instances of each CRD exist across which namespaces.\n\n```\nkubectl-analytics crds [--namespace NS] [--breakdown] [--output table|json|csv] [--output-dir DIR]\n```\n\nOutput (`--output table`):\n\n```\n                 Custom Resource Adoption\n CRD                                         NAMESPACES  INSTANCES  ADOPTION\n certificates.cert-manager.io               12 / 24      42         50%\n issuers.cert-manager.io                     8 / 24      18         33%\n helmreleases.helm.toolkit.fluxcd.io        19 / 24      91         79%\n kustomizations.kustomize.toolkit.fluxcd.io 14 / 24      34         58%\n backupschedules.velero.io                   2 / 24       5          8%\n```\n\nWith `--breakdown`, a second table shows the raw instance count per namespace × CRD:\n\n```\n          CRD Instances per Namespace\n NAMESPACE    certificates  issuers  helmreleases  backupschedules\n team-alpha   3             1        5             1\n team-beta    0             0        2             0\n platform     8             6        12            4\n```\n\n---\n\n### `kubectl-analytics adoption`\n\nPer-namespace adoption metrics — raw counts for key platform capabilities.\n\n```\nkubectl-analytics adoption [--namespace NS] [--output table|json|csv] [--output-dir DIR]\n```\n\nOutput:\n\n```\n             Adoption Rate per Namespace\n NAMESPACE    PODS  LIMITS  NETPOL  DEPLOYS  PDB  HPA  FLUX  ARGO\n team-alpha   8     8/8     yes     3        1    1    5     0\n team-beta    5     2/5     no      2        0    0    2     0\n platform     14    14/14   yes     7        4    3    12    0\n```\n\n| Column | Source |\n|---|---|\n| `LIMITS` | pods with both CPU and memory limits set (`pods_with_limits / pod_count`) |\n| `NETPOL` | at least one `NetworkPolicy` in the namespace |\n| `PDB` | count of `PodDisruptionBudgets` |\n| `HPA` | count of `HorizontalPodAutoscalers` targeting a Deployment |\n| `FLUX` | sum of `HelmReleases` + `Kustomizations` (all API versions) |\n| `ARGO` | count of ArgoCD `Applications` |\n\n---\n\n### `kubectl-analytics istio`\n\nIstio service mesh usage. Without flags, shows namespace enrollment. Flags can be combined.\n\n```\nkubectl-analytics istio [--traffic] [--external] [--policies]\n                        [--namespace NS] [--output table|json|csv] [--output-dir DIR]\n```\n\n**Enrollment** (default):\n\n```\n           Istio Namespace Enrollment\n NAMESPACE    INJECTION  SIDECARS  PODS  COVERAGE\n team-alpha   yes        8         8     100%\n team-beta    no         0         5       0%\n platform     yes        12        14     85%\n legacy       no         0         3       0%\n```\n\n- `INJECTION` — value of the `istio-injection` label on the namespace\n- `SIDECARS` — pods with an `istio-proxy` container running\n- `COVERAGE` — `sidecars / pods`\n\n**`--traffic`** — VirtualServices, DestinationRules, Gateways, ServiceEntries, WorkloadEntries per namespace:\n\n```\n        Istio Traffic Policies per Namespace\n NAMESPACE    VirtualServices  DestinationRules  Gateways  ServiceEntries  WorkloadEntries\n team-alpha   4                2                 0         1               0\n platform     9                6                 2         3               2\n team-beta    0                0                 0         0               0\n```\n\nVirtualServices define routing rules (retries, timeouts, traffic splits). A namespace with Deployments but no VirtualServices relies on plain Kubernetes Service routing.\n\n**`--external`** — ServiceEntries detail view (external services registered in the mesh):\n\n```\n          Istio External Services (ServiceEntries)\n NAMESPACE  NAME              HOSTS                            RESOLUTION  PORTS\n platform   stripe-api        api.stripe.com                   DNS         443/HTTPS\n platform   internal-pg       postgresql.internal.example.com  DNS         5432/TCP\n team-alpha legacy-erp        legacy-erp.corp                  STATIC      8080/HTTP\n```\n\nServiceEntries register external services into the mesh — databases, third-party APIs, legacy systems. Namespaces calling external hosts without a ServiceEntry bypass all mesh policies for that traffic.\n\n**`--policies`** — PeerAuthentication and AuthorizationPolicies per namespace:\n\n```\n       Istio Security Policies per Namespace\n NAMESPACE    PeerAuthentication  AuthorizationPolicies  mTLS-MODE\n team-alpha   1                   3                      STRICT\n platform     1                   8                      STRICT\n team-beta    0                   0                      none\n```\n\n---\n\n### `kubectl-analytics all`\n\nRuns all reports sequentially. Collects data first (4 steps), then renders all 6 sections.\n\n```\nkubectl-analytics all [--output table|json|csv] [--output-dir DIR]\n```\n\n```\n╭─ kubectl analytics — all reports ──────────────╮\n│ Namespaces: 24  Output: table                  │\n╰────────────────────────────────────────────────╯\n✓ [1/4] CRD statistics       3.2s\n✓ [2/4] Adoption metrics     1.8s\n✓ [3/4] Istio stats          1.1s\n✓ [4/4] Service entries      0.4s\n\n──────────── Custom Resource Adoption ────────────\n ...table...\n─────────── Adoption Rate Metrics ────────────────\n ...table...\n──────────── Istio Enrollment ────────────────────\n ...\n```\n\nFor CSV output, `--output-dir` is required — one file per report:\n\n```bash\nkubectl-analytics all --output csv --output-dir ./reports/\n# writes: crds.csv, adoption.csv, istio.csv,\n#         istio-traffic.csv, istio-policies.csv, istio-external.csv\n```\n\nFor JSON output, a single combined file is written when `--output-dir` is given, or streamed to stdout:\n\n```bash\nkubectl-analytics all --output json --output-dir ./reports/\n# writes: all.json  (keys: crds, adoption, istio, service_entries)\n```\n\n---\n\n## Output Formats\n\nAll commands support `--output table|json|csv`.\n\n- **table** (default) — rendered to the terminal with Rich\n- **json** — serialized dataclass fields; streamed to stdout or written to `--output-dir`\n- **csv** — one row per resource; streamed to stdout or written to `--output-dir`\n\n```bash\n# stream CSV to stdout\nkubectl-analytics istio --external --output csv \u003e external-services.csv\n\n# write to directory\nkubectl-analytics crds --output json --output-dir ./out/\n```\n\n---\n\n## Design Goals\n\n- **Read-only** — only Kubernetes API reads, no cluster mutations\n- **No cluster-side components** — runs client-side, requires only `kubeconfig` access\n- **Per namespace by default** — every view is namespaced; cluster-wide rollups are additive\n- **Graceful degradation** — missing CRDs (Istio, Flux, ArgoCD not installed) return 0, never crash\n\n---\n\n## Requirements\n\n- Python \u003e= 3.12\n- Valid `kubeconfig` (or in-cluster service account)\n\n---\n\n## Installation\n\n### Als globales CLI-Tool (empfohlen)\n\n```bash\n# Wheel bauen\nuv build\n\n# Global installieren — danach steht kubectl-analytics systemweit bereit\nuv tool install dist/kubectl_analytics-0.1.0-py3-none-any.whl\n\nkubectl-analytics --help\n\n# Neu installieren nach einem Build\nuv tool install --force dist/kubectl_analytics-0.1.0-py3-none-any.whl\n\n# Deinstallieren\nuv tool uninstall kubectl-analytics\n```\n\n### Als Abhängigkeit in einem anderen Projekt\n\n```bash\nuv add dist/kubectl_analytics-0.1.0-py3-none-any.whl\n```\n\n### Lokal ohne Installation testen\n\n```bash\nuv run --with dist/kubectl_analytics-0.1.0-py3-none-any.whl kubectl-analytics --help\n```\n\n---\n\n## Development\n\n```bash\n# Abhängigkeiten inkl. Dev-Tools installieren\nuv sync\n\n# Typ-Prüfung\nuv run pyright\n\n# Linting\nuv run ruff check\n\n# Direkt aus dem Quellverzeichnis starten (ohne Build)\nuv run python -m kubectl_analytics.main --help\n\n# Wheel bauen\nuv build\n# Ergebnis: dist/kubectl_analytics-0.1.0-py3-none-any.whl\n#           dist/kubectl_analytics-0.1.0.tar.gz\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlanboy%2Fkubectl_analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwlanboy%2Fkubectl_analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlanboy%2Fkubectl_analytics/lists"}