Skip to content

feat: dorikin - Kubernetes configuration drift detector - #1

Merged
indrasvat merged 60 commits into
mainfrom
create-dorikin
Jan 8, 2026
Merged

indrasvat merged 60 commits into
mainfrom
create-dorikin

Conversation

@indrasvat

@indrasvat indrasvat commented Jan 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Dorikin is a Kubernetes configuration drift detector that compares desired manifests against live cluster state. It provides both a CLI for CI/CD integration and an interactive TUI for exploration and debugging.

Core Features

  • Real-time drift detection — Compares YAML manifests against live cluster state with smart field filtering
  • Interactive TUI — Navigate resources, view diffs, filter by status (AE86 Panda Trueno themed)
  • Multiple output formats — Table, JSON, YAML, or quiet mode for scripting
  • HPA-aware comparison — Automatically skips spec.replicas for HPA-managed workloads
  • Helm support — Scan Helm charts directly with --helm-values and --helm-set overrides
  • Kustomize support — Scan Kustomize overlays directly with --kustomize
  • Quantity normalization — Treats equivalent K8s quantities as equal (128Mi = 134217728, 500m = 0.5)
  • Content-based matching — Matches arrays by key field (containers by name, not index)
  • Configuration file — .dorikin.yaml for custom ignore paths and resource-specific rules
  • Auto-refresh — Continuous monitoring with configurable intervals

Drift Status Types

Status Description
IN_SYNC Resource matches manifest
DRIFTED Resource exists but fields differ
MISSING Defined in manifest, absent from cluster
EXTRA Exists in cluster, not in manifests
ERROR Fetch or comparison failed

Loader Support

Loader Command Description
Raw YAML dorikin scan ./manifests/ Direct YAML files
Helm dorikin scan --helm ./chart/ Helm charts with values/set
Kustomize dorikin scan --kustomize ./overlay/ Kustomize overlays

Test Track

Includes a local testing environment using Colima + k3s with pre-built drift scenarios:

make track-setup    # Create test environment
make track-scan     # Run drift scan
make track-drift    # Apply drift scenarios
make track-tui      # Launch interactive TUI

Test Plan

  • make ci passes (344 tests, lint clean)
  • Test track validates all drift detection scenarios
  • HPA-aware detection verified with StatefulSet and Deployment HPAs
  • Helm loader tested with values files and --set overrides
  • Kustomize loader tested with overlays
  • Quantity normalization verified (128Mi = 134217728 bytes)
  • Content-based array matching verified (env var reordering)
  • Configuration file loading tested with custom ignore paths

Convert all numeric types to float64 before comparison since JSON
unmarshaling returns numbers as float64 while YAML keeps integers.
This eliminates false positives from type mismatches.
- Press 'r' for manual refresh
- Press 'a' to toggle auto-refresh (default 5s interval)
- Add --refresh-interval flag to configure interval
Fix HPA minReplicas to match deployment replicas (3) to prevent
HPA-induced drift at baseline.
Include features, installation, CLI reference, TUI controls,
test track instructions, and roadmap.
Explains comparison algorithm, field filtering, type normalization,
limitations (HPA, ranges, ordering), and future improvements.
Skip spec.replicas comparison for resources managed by HPAs.
Supports Deployments, StatefulSets, and ReplicaSets.

Modes: --hpa-aware=manifests (default), cluster, disabled
- Load config from .dorikin.yaml (walks up directory tree)
- Global and resource-specific ignore paths
- extend_defaults option to include/replace built-in ignores
- CLI flags override config file settings
- Add VHS tape files for generating demo recordings
- Add demo.gif showing tmux split-pane live drift detection
- Update README with demo GIF in Overview section
- Add `make demo` target for regenerating the GIF
- Use relative paths for portability
- Enable auto-refresh with 'a' key press
- Remove temporary test tape file
- Add dorikin-branded status bar (jade green badge, amber LIVE indicator)
- Add jade green pane borders for active pane
- Add demo-tui make target for quick TUI launches
- Document VHS tape format learnings in CLAUDE.md
- Add helper script for pane initialization
- Use conditional pane-border-format with correct pane-base-index (1, not 0)
- Add dedicated init scripts for left/right pane titles
- Document tmux pane-base-index gotcha in CLAUDE.md
- Left pane shows "test track", right pane shows "dorikin tui"
- Create common.go with ScanFlags struct and shared initialization
- Export ParseHPAAwareMode and BuildLoader for reuse
- Add BuildScanContext to handle common setup logic
- Reduce scan.go from 205 to 75 lines
- Reduce ui.go from 155 to 69 lines
- Add CLI tests (39.8% coverage, up from 0%)
- Quantity normalization: Treat 128Mi = 134217728 bytes, 500m = 0.5 CPU
  Uses k8s.io/apimachinery/pkg/api/resource for semantic comparison
- Content-based array matching: Match containers, env, volumes, etc. by
  key field (name, containerPort, port) instead of by index
- Prevents false positives when array order changes or quantities use
  different but equivalent representations
- Update test track with Q/R drift scenarios to exercise new features
- Update docs to reflect implemented features (344 tests, 80%+ coverage)
@indrasvat
indrasvat merged commit 2a03d14 into main Jan 8, 2026
6 checks passed
@indrasvat
indrasvat deleted the create-dorikin branch January 8, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant