github vladimirvivien/ktop v0.7.7

38 minutes ago

ktop Release v0.7.7

ktop v0.7.7 adds auto-discovered kube-state-metrics (KSM) governance telemetry, built-in Kubernetes Component SLIs (/metrics/slis) and Kubelet probe counters (/metrics/probes), lock-free joins into both the interactive TUI and headless --noui JSON/JSONL snapshots, and an always-visible Overview Cluster Summary layout for terminals of 45 rows or fewer.

Operators gain live visibility into control-plane and kubelet healthcheck SLIs (incorporated into cluster health_score when explicitly unhealthy), failing readiness/liveness/startup probes, HPA scaling ceilings, PDB disruption budgets, ResourceQuota utilization, CronJob schedules, pod disruption reasons, and DRA ResourceClaim associations—with silent degradation when KSM or SLI endpoints are absent or RBAC-restricted.


Detailed Changes by Category

1. Auto-Discovered kube-state-metrics (KSM) Enrichment (metrics/ksm, config, cmd)

Streaming Allowlist Parser & Service-Proxy Discovery

  • Problem / Context: Cluster governance state—such as HPA scaling limits, PDB zero-disruption budgets, ResourceQuota saturation, CronJob schedule timestamps, pod disruption reasons, and DRA ResourceClaim mappings—was not surfaced in ktop without manually inspecting multiple API resources.
  • Technical Implementation: Added metrics/ksm (metrics/ksm/types.go, metrics/ksm/parser.go, metrics/ksm/collector.go) with a line-by-line streaming allowlist parser (ParseStream) that skips non-allowlisted series before label parsing and extracts:
    • kube_horizontalpodautoscaler_* (info, spec_min_replicas, spec_max_replicas, status_current_replicas, status_desired_replicas, status_condition)
    • kube_poddisruptionbudget_status_* (current_healthy, desired_healthy, expected_pods, pod_disruptions_allowed)
    • kube_resourcequota (hard, used, computed UsedPct)
    • kube_cronjob_* (spec_suspend, status_active, status_last_schedule_time, next_schedule_time)
    • kube_pod_status_disruption_reason and kube_pod_resourceclaim_info
  • Added config.NormalizeKSMMode (config/config.go), metrics.ksm_mode / metrics.ksm_endpoint config keys, and --ksm (auto default, off) / --ksm-endpoint CLI flags (cmd/ktop.go).
  • APIs / Signatures:
    # Default auto-discovery via API-server service proxy (degrades silently when absent)
    ktop
    
    # Disable KSM discovery
    ktop --ksm=off
    
    # Explicit service proxy or direct HTTP URL override
    ktop --ksm-endpoint=monitoring/kube-state-metrics:8080
    ktop --ksm-endpoint=http://127.0.0.1:8080/metrics
  • Behavioral Notes: Auto-discovery scans kube-system, monitoring, observability, prometheus, and the configured namespace for matching kube-state-metrics services and streams /metrics through the Kubernetes API server service proxy with zero port-forwarding. Missing or RBAC-forbidden services degrade silently without blocking startup.

2. Component SLIs (/metrics/slis) & Kubelet Probes (/metrics/probes) (metrics/sli, views/model, k8s)

Control-Plane & Kubelet SLI Scraping with health_score Integration

  • Problem / Context: API reachability alone could not detect internal component degradation (such as failing etcd readiness checks or kubelet syncloop failures) or containers experiencing repeated probe failures.
  • Technical Implementation: Added metrics/sli (metrics/sli/types.go, metrics/sli/parser.go, metrics/sli/collector.go) scraping GET /metrics/slis on the API server and nodes/{node}/proxy/metrics/slis + nodes/{node}/proxy/metrics/probes across nodes with bounded concurrency and atomic lock-free Latest() snapshots. Updated model.CalculateHealthScore (views/model/summary_model.go) and Controller.BuildClusterSummary (k8s/summary_controller.go).
  • Behavioral Notes:
    • When /metrics/slis is reachable and explicitly reports failing checks (kubernetes_healthcheck == 0), CalculateHealthScore deducts 15 points per unhealthy component (capped at 30).
    • When /metrics/slis is unavailable or RBAC-forbidden, ktop applies zero penalty to health_score.
    • Kubelet prober_probe_total counters aggregate per-container Readiness, Liveness, and Startup failure counts per pod.

3. Snapshot Join, Overview Layout & Detail Surfacing (internal/snapshot, collector, views/overview, views/workloads, views/pod, docs)

Lock-Free Snapshot & --noui Schema Extensions

  • Technical Implementation: Added optional Governance *GovernanceData (json:"governance,omitempty") and SLIs *SLIData (json:"slis,omitempty") to snapshot.Snapshot (internal/snapshot/snapshot.go, internal/snapshot/builder.go) and collector.Aggregate (collector/collector.go), plus pod-level disruption_reason, resource_claims, and failing_probes fields and SLI/KSM rollup counts on SummaryData. Updated K8sSnapshotProvider.WaitReady (collector/k8s_provider.go) with a bounded best-effort initial KSM/SLI scrape so single-shot ktop --noui captures them immediately.

Overview Cluster Summary & Detail Panel Surfacing

  • Problem / Context: On terminals with 45 rows or fewer, Overview's Cluster Summary previously hid both the top resource stats row and bottom enhanced stats row, leaving only sparklines visible.
  • Technical Implementation:
    • Updated views/overview/summary_panel.go and views/overview/main_panel.go to keep the full Cluster Summary visible below 45 rows using compact 1-row borderless stats lines (summaryHeight = 9 in Prometheus mode / 8 in non-Prometheus mode, trimming 3 rows from the flex Pods table).
    • Added SLIs: OK|<N> fail, Probes: <N> fail, and KSM: OK|<alerts> status badges to the bottom Cluster Summary line under the sparklines.
    • Surfaced HPA and PDB rows in Workload Detail (views/workloads/detail.go, k8s/workloads_controller.go), and failing Probes, Disrupt, and DRA Claims lines in Pod Detail (views/pod/detail.go, views/overview/main_panel.go).
    • Documented --ksm, --ksm-endpoint, governance, and slis in docs/cli.md and docs/noui.md.

Upgrade & Compatibility Notes

  • Backward Compatibility: Fully backward compatible with existing ktop CLI flags, kubectl ktop plugin usage, ~/.ktop/config.yaml configurations, and --noui JSON/JSONL consumers (governance, slis, and new summary/pod fields are additive omitempty fields).
  • Deprecations & Retractions: None.
  • Migration Actions: None required. Clusters without kube-state-metrics or /metrics/slis access continue operating with no configuration changes and zero health_score penalty.

Workspace / Repository Metrics

 30 files changed, 2624 insertions(+), 49 deletions(-)

Don't miss a new ktop release

NewReleases is sending notifications on new releases.