Introducing a new way to review your PRs.

Read the announcement

nklmilojevic / sofka

A Kubernetes TUI, reimagined in Rust - built on kube-rs and ratatui, async-first from the ground up.

View on GitHub

19 documents · Updated Nov 4, 2026

docs / cluster-operations-and-analysis

Cluster operations and analysis

Sofka gives engineers one place to inspect Kubernetes resources, understand workload health, and make guarded changes. It also connects live cluster state to delivery systems such as Flux and Argo CD, while a fleet view compares selected contexts without hiding a slow or unreachable cluster.

Cluster resource workspace

The cluster resource workspace is the main operating surface for a selected Kubernetes context. It keeps resource views current through the Kubernetes API and lets an engineer move from a broad list to the object or related resource that needs attention.

The workspace supports these broad activities:

  • Browse discovered resource kinds and switch namespaces or contexts.
  • Watch live object changes and refresh the current view.
  • Filter lists locally or with Kubernetes selectors.
  • Open YAML, descriptions, events, logs, and resource relationships.
  • Move from a finding or related object to its normal resource view.

The same context and namespace remain the basis for inspection and action. This keeps a diagnosis connected to the object that an engineer can inspect or change next.

References: src/k8s.rs• L968-1032 src/…/adjacent.rs• L35-73 docs/keys.md• L50-79

Filter and query scope

The filter and query system narrows a resource view without changing the resource itself. Plain words perform case-insensitive text matching. Structured input adds precise terms and Kubernetes selectors when a name search is not enough.

Structured filters support these broad forms:

  • Text, quoted text, regular expressions, fuzzy subsequence matching, and inverse terms.
  • Alternatives written with | and label-key or label-value matches.
  • Kubernetes label selectors and field selectors sent to the API.
  • Equality and range checks for status, restarts, CPU, memory, and age.
  • Boolean groups with &&, ||, and parentheses.

Resource queries can also name the resource, namespace, and context before the filter. Quotes keep spaces inside one term. Malformed input remains visible as a filter error instead of silently turning an incomplete read into an empty or healthy result.

References: src/filter.rs• L1-35 src/filter.rs• L262-317 src/filter.rs• L317-489 src/filter.rs• L594-650

Workload operations and analysis

Workload operations combine direct Kubernetes changes with views that explain current state. A workload is more than one row: its controller, child pods, events, logs, and resource requests together show whether a rollout is healthy and why it may be blocked.

The main workload paths are:

  • Inspection: Workload tables show readiness and rollout state. The explain view ranks evidence such as stalled conditions, unscheduled pods, image errors, crash loops, restarts, OOM kills, and probe problems.
  • Relationship analysis: The adjacent view follows owners, children, objects named by a specification, and objects that name the selection. This makes links such as workload-to-pod and pod-to-volume visible without requiring knowledge of each API field.
  • Operational access: Engineers can view logs, events, YAML, descriptions, container details, and resource timelines. They can also attach to a pod, open a shell, start a debug session, or save and copy evidence.
  • Change operations: Supported actions include edit, delete, scale, image change, restart, shell or debug access, port forwarding, node cordon, and node drain. Port forwards can stay active while the engineer continues to browse.
  • Resource sizing: Right-sizing compares historical CPU and memory use with current requests. It produces a suggested patch for review and does not apply the patch itself.

This flow turns a symptom into a next step: inspect the workload, follow the evidence to a blocking object, then use a guarded action or a reviewed patch when a change is needed.

The child page Workload operations and analysis tools describes these paths in more detail.

References: src/explain.rs• L1-14 src/…/explain.rs• L53-96 src/adjacent.rs• L1-4 src/…/adjacent.rs• L35-39 src/rightsize.rs• L1-8 src/…/rightsize.rs• L13-17 src/…/actions.rs• L21-75 src/…/actions.rs• L482-557 src/…/actions.rs• L785-1057 src/…/actions.rs• L1110-1325 docs/keys.md• L61-91

Change controls

Change controls protect the boundary between reading a cluster and changing it. Read-only mode can disable mutating actions for a session or for a selected context. Guardrails can deny an action, limit its bulk size, or require stronger confirmation.

Before a change reaches Kubernetes, the system considers:

  • The effective read-only policy for the current context.
  • Guardrails that match the context, namespace, resource, and action.
  • The target set, including marked rows for bulk operations.
  • Controller ownership, because a Flux, Argo CD, or other controller may restore the old state.
  • Confirmation needs and the selected delete cascade or drain risks.

Some actions also have a resource-specific safety meaning. Deleting a Helm release uses the release uninstall action rather than deleting its storage object. A node debug session explains its host access and requires confirmation. The session tracks its debug pods so the operator can clean them up later.

Accepted changes are recorded in the session journal as actions started. The journal helps explain what the operator attempted. It is not a record that the cluster accepted or completed the request.

References: docs/safety.md• L3-14 docs/safety.md• L16-65 docs/safety.md• L87-111 src/…/actions.rs• L21-75 src/…/actions.rs• L921-1057

Analytical views

Analytical views turn Kubernetes status and related evidence into short findings that point back to concrete resources. They are read-focused. The analysis helps an engineer choose an action, but it does not replace Kubernetes status or silently change the cluster.

The views use these evidence paths:

ViewPurposeMain result
ExplainFind why a resource is unhealthyRanked causes with links to blocking resources
AdjacentShow direct resource relationshipsOwners, children, references, and usages
TimelineShow changes seen during this sessionA bounded history of meaningful state changes
Usage trendsShow recent CPU and memory behaviorShort rolling bars for a selected container and relative node usage
Right-sizeCompare observed use with resource requestsVerdicts and a patch preview
Logs and eventsAdd runtime evidenceCurrent or historical output tied to the selection

The explain view is deterministic. It uses object state, related pods, and warning events to support each finding. The timeline is session-local. It shows changes observed after Sofka began watching and does not reconstruct past history.

Usage trends keep a short rolling view of samples. A missing sample remains a gap. A recreated container or node starts a new identity-aware history. This prevents stale data from looking like current usage.

References: src/explain.rs• L1-14 src/timeline.rs• L1-12 src/providers.rs• L1-19 src/…/explain.rs• L274-320 src/…/rightsize.rs• L198-265 src/…/metrics_history.rs• L5-10 src/…/metrics_history.rs• L24-59 src/…/metrics_history.rs• L61-142 src/…/metrics_history.rs• L145-210

Fleet health comparison

The fleet dashboard is an opt-in comparison of explicitly selected kubeconfig contexts. It gives an engineer a fast view of reachability and common health signals before detailed work begins in one context.

Each context is gathered independently and appears with a summary of:

  • API connectivity and Kubernetes version.
  • Ready and total nodes.
  • Healthy and unhealthy pods.
  • Flux resources with a failed Ready condition.
  • Argo CD Applications that are out of sync or unhealthy.
  • The effective read-only policy.

An unavailable or slow context reports its own error instead of stopping the dashboard. A healthy summary requires a reachable context, ready nodes, no unhealthy pods, and no reported Flux or Argo CD failures. A missing Flux or Argo CD installation is shown as unavailable data rather than as a failure.

Selecting a row normally switches to that context. When Argo CD problems are present, the dashboard can open the Applications view with the same degraded filter used for the count. The summary and drill-down then describe the same set.

References: src/fleet.rs• L1-10 src/fleet.rs• L53-111 src/…/fleet.rs• L81-116 src/…/fleet.rs• L215-280 docs/providers.md• L85-112

Delivery system integration

Delivery integration explains how a Kubernetes object reaches its current state through a GitOps controller. It keeps the operational view tied to the source and reconciliation process instead of treating a managed object as an isolated resource.

Flux analysis follows a managed object to its Kustomization or HelmRelease owner. It then follows the source revision and any Kustomizations that it depends on. The view reports whether the owner is ready, suspended, reconciled, blocked by its source, or waiting for a dependency. It can also show the owner's inventory and jump to resources in the current cluster.

Argo CD analysis reads an Application's sync and health state, source revisions, destination, managed resources, and blocking conditions. It can start from an Application or from an object that Argo CD manages. For Applications that deploy to another context, the view names the destination and does not offer a misleading jump into the current cluster.

The child page Fleet, GitOps, and Argo CD integration explains the delivery and cross-context workflows in more detail.

References: src/gitops.rs• L1-12 src/gitops.rs• L47-59 src/…/gitops.rs• L10-16 src/argocd.rs• L1-12 src/argocd.rs• L194-209 src/…/argocd.rs• L18-23

Operational flow

This flow shows how an engineer can move from a fleet signal or resource symptom to evidence and a controlled change.

flowchart TD
    A[Fleet or resource signal] --> B[Select context and namespace]
    B --> C[Inspect live resource state]
    C --> D{Need more context?}
    D -->|Relationships| E[Open adjacent or delivery view]
    D -->|Cause| F[Open explain, logs, or events]
    D -->|Capacity| G[Open right-size analysis]
    E --> H[Jump to related resource]
    F --> H
    G --> I[Review patch preview]
    H --> J{Change needed?}
    I --> J
    J -->|No| K[Continue observing]
    J -->|Yes| L[Apply policy and guardrail checks]
    L --> M[Confirm and send Kubernetes request]
    M --> N[Observe the result and journal the action]

The dashboard and analysis views narrow the search. The final state still comes from the Kubernetes API or the delivery controller. A change remains subject to the active safety policy.

References: src/…/fleet.rs• L181-207 src/…/explain.rs• L143-207 src/…/actions.rs• L141-203 docs/safety.md• L16-65

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep fleet health counts and their drill-down filter aligned. A changed definition of degraded Argo CD Applications must update both the row count and the Applications query.
  • Keep delivery destinations distinct from the current cluster. Remote Argo CD resources must not gain jump targets that point to same-named objects in the current context.
  • Keep ownership warnings aligned with change actions. A new mutating path must use the same read-only, guardrail, confirmation, and controller-ownership checks as existing actions.
  • Keep analysis links tied to the resource group and namespace. A kind or API-group change can otherwise send a finding to a different resource with the same name.
  • Keep missing data distinct from healthy data. Failed reads in fleet, explain, or right-size analysis must not become confident zero counts or healthy results.
  • Keep local filter terms and server-side selectors aligned. A parser change must preserve the scope and meaning of -l, -f, Boolean groups, and comparison terms.
  • Keep saved port forwards scoped to the active context and target kind. Context matching must not start a tunnel against a same-named object on another cluster.
  • Keep trend history tied to resource identity and collection generation. A recreated object or context switch must not inherit old samples.
  • Keep node-debug cleanup tied to the debugger pods launched by the session. Cleanup must not delete unrelated pods on the same node.
  • Keep node pod counts fresh across access modes. A refused watch must use a paced list fallback. A watch resync must rebuild counts from the new list instead of merging stale entries.

Important failure modes

TriggerConsequenceGuard
A fleet context cannot connect or a gather times outThat row is an error and is not treated as healthyEach context has an independent gather and timeout
Flux source or dependency is not readyThe owner is reported as blocked rather than reconciledThe GitOps view shows the owner, source, and dependency chain
An Argo CD Application deploys to another clusterManaged-resource jumps are unavailable from the current clusterThe destination is resolved and shown before navigation
A Kubernetes read is denied during analysisThe result can be incompleteThe view reports a warning instead of treating the missing list as empty
A change targets a controller-managed objectThe controller can restore or recreate the objectThe action warns about ownership and points the operator to the source
A right-size query has no data or failsNo valid recommendation is producedUnknown values remain unknown and the patch preview is omitted when needed
A structured filter is malformedThe view reports a filter error and cannot narrow as intendedParsing reports the first error instead of hiding it or blanking the table
A node debug session is left runningA privileged debug pod remains after the interactive sessionCleanup targets only node-debugger pods tracked from this session
A port-forward process exitsThe tunnel disappears while its row could otherwise look activeDead forwards are reaped and the operator receives a warning
A metric sample is missing or the resource identity changesA trend can look incomplete or stale if missing data becomes zeroGaps stay unknown and histories reset for a new UID or generation
Pod watch access is forbiddenNode pod counts stop updating if the system retries the watch foreverOne refused watch switches to paced list polling
A watch loses its resource versionOld pod counts can remain after the cluster state changesResync rebuilds the count map from the fresh list
Repeated list requests failThe API can receive a rapid retry stormRetry intervals grow with backoff

Key files

FileWhy to read it
src/…/fleet.rsShows the fleet dashboard lifecycle, health summary, drill-down, and independent context gathers.
src/fleet.rsDefines the cross-context summary and what counts as a healthy row.
src/explain.rsDefines the evidence-based unhealthy-resource analysis.
src/adjacent.rsDefines the model for owners, children, references, and usages.
src/filter.rsDefines resource scope parsing and the local and Kubernetes-side filter language.
src/…/metrics_history.rsDefines the short usage histories and identity-aware trend display.
src/gitops.rsDefines the Flux ownership and reconciliation picture.
src/argocd.rsDefines Argo CD health, sync, destination, and managed-resource analysis.
src/…/actions.rsShows the entry point for guarded Kubernetes changes, debug sessions, and port forwards.
src/rightsize.rsDefines usage verdicts and patch-preview behavior.
src/…/refresh.rsShows live resource refresh, watch updates, and fallback behavior when a watch is not allowed.
src/…/tests.rsVerifies node pod count freshness across watch, list fallback, resync, retry backoff, and compressed API responses.
docs/safety.mdDescribes read-only mode, guardrails, ownership warnings, authorization checks, and the action journal.
docs/keys.mdMaps the operational views and actions to their user-facing commands and keys.