{"id":50803395,"url":"https://github.com/databus23/kubectl-diff-watch","last_synced_at":"2026-06-12T22:33:34.526Z","repository":{"id":355045973,"uuid":"1226553813","full_name":"databus23/kubectl-diff-watch","owner":"databus23","description":"A kubectl plugin that watches Kubernetes resources and shows colored diffs when they change","archived":false,"fork":false,"pushed_at":"2026-05-01T16:47:44.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-01T17:11:09.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/databus23.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-01T14:49:27.000Z","updated_at":"2026-05-01T16:47:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/databus23/kubectl-diff-watch","commit_stats":null,"previous_names":["databus23/kubectl-watch-diff"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/databus23/kubectl-diff-watch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fkubectl-diff-watch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fkubectl-diff-watch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fkubectl-diff-watch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fkubectl-diff-watch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/databus23","download_url":"https://codeload.github.com/databus23/kubectl-diff-watch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fkubectl-diff-watch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34265491,"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-12T02:00:06.859Z","response_time":109,"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":[],"created_at":"2026-06-12T22:33:32.361Z","updated_at":"2026-06-12T22:33:34.494Z","avatar_url":"https://github.com/databus23.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kubectl-diff-watch\n\nA kubectl plugin that watches Kubernetes resources and shows colored diffs when they change.\n\n## Features\n\n- **Pure Go implementation** — no shell-outs to `kubectl`, `diff`, or other tools\n- **Multiple output formats** — colored unified diff (default), [dyff](https://github.com/homeport/dyff) structural diff, or plain text\n- **Watches any resource** — uses Kubernetes dynamic client, supports all resource types including CRDs\n- **Label \u0026 field selectors** — filter which resources to watch\n- **Multiple resources** — watch multiple resource types simultaneously\n- **Clean diffs** — strips `managedFields`, `resourceVersion`, `generation`, and `observedGeneration` by default\n- **Timestamps** — shows when each change occurred\n- **kubectl plugin** — install as `kubectl diff-watch`\n\n## Installation\n\n```bash\ngo install github.com/databus23/kubectl-diff-watch@latest\n```\n\nOr build from source:\n\n```bash\ngit clone https://github.com/databus23/kubectl-diff-watch\ncd kubectl-diff-watch\ngo build -o kubectl-diff-watch .\n```\n\nPlace the binary in your `$PATH` to use as a kubectl plugin.\n\n## Usage\n\n```bash\n# Watch a specific pod\nkubectl diff-watch pod mypod\n\n# Watch all pods with a label selector\nkubectl diff-watch pods -l app=nginx\n\n# Watch a deployment in a specific namespace\nkubectl diff-watch deployment myapp -n production\n\n# Watch with dyff structural output\nkubectl diff-watch pods -l app=nginx -o dyff\n\n# Watch with no color (for piping to a file)\nkubectl diff-watch nodes --no-color\n\n# Watch across all namespaces\nkubectl diff-watch pods -l app=nginx -A\n\n# Watch multiple resource types\nkubectl diff-watch pods,deployments -l app=nginx\n\n# Watch a specific resource by name\nkubectl diff-watch deployment/myapp\n\n# Don't strip managedFields\nkubectl diff-watch pod mypod --show-managed-fields\n\n# Show resourceVersion/generation changes\nkubectl diff-watch pod mypod --strip-server=false\n\n# Increase diff context lines\nkubectl diff-watch pod mypod -C 5\n```\n\n## Output Examples\n\n### `diff` (default)\n\n```diff\n16:14:55 Deployment/nginx -n production changed\n@@ -7,9 +7,9 @@\n    spec:\n      containers:\n      - name: nginx\n-       image: nginx:1.24\n+       image: nginx:1.25\n        ports:\n        - containerPort: 80\n        resources:\n          requests:\n-           memory: 128Mi\n+           memory: 256Mi\n            cpu: 100m\n```\n\n### `dyff`\n\n```\n16:14:55 Deployment/nginx -n production changed\n\nspec.template.spec.containers.0.image\n  ± value change\n    - nginx:1.24\n    + nginx:1.25\n\nspec.template.spec.containers.0.resources.requests.memory\n  ± value change\n    - 128Mi\n    + 256Mi\n```\n\n## Output Formats\n\n### `diff` (default)\n\nColored unified diff output, similar to `git diff`:\n\n- Added lines in green with `+` prefix\n- Removed lines in red with `-` prefix\n- Context lines with 2-space indent preserving YAML structure\n- File headers in bold red/green\n- Hunk headers in cyan\n\nUse `--no-color` to disable colors (e.g. when piping to a file).\n\n### `dyff`\n\nUses the [dyff](https://github.com/homeport/dyff) library for structural YAML comparison. Shows changes at the semantic level (by path, e.g. `data.foo`) rather than line-by-line, making it easier to understand complex changes.\n\n## Flags\n\n| Flag | Short | Default | Description |\n|------|-------|---------|-------------|\n| `--output` | `-o` | `diff` | Output format: `diff`, `dyff` |\n| `--diff-context` | `-C` | `3` | Number of context lines in diff |\n| `--no-color` | | `false` | Disable colored output |\n| `--selector` | `-l` | | Label selector to filter resources |\n| `--field-selector` | | | Field selector to filter resources |\n| `--namespace` | `-n` | | Namespace to watch in (also `$KUBENAMESPACE`) |\n| `--all-namespaces` | `-A` | `false` | Watch across all namespaces |\n| `--show-managed-fields` | | `false` | Keep managedFields in output (same as kubectl) |\n| `--strip-server` | | `true` | Strip resourceVersion, generation, observedGeneration |\n| `--timestamps` | | `true` | Show timestamps on each diff |\n| `--kubeconfig` | | | Path to kubeconfig file (also `$KUBECONFIG`) |\n| `--context` | | | Kubernetes context to use (also `$KUBECONTEXT`) |\n\n## Environment Variables\n\n| Variable | Description |\n|----------|-------------|\n| `KUBECONFIG` | Path to kubeconfig file (standard kubectl variable) |\n| `KUBECONTEXT` | Kubernetes context to use |\n| `KUBENAMESPACE` | Namespace to watch in |\n\n## How It Works\n\n1. Resolves resource types using the Kubernetes discovery API (supports short names, plurals, CRDs)\n2. Creates dynamic informers for each requested resource with optional label/field selectors\n3. On each update event, serializes the resource to YAML, strips noisy server-managed fields, and computes a diff against the previous version\n4. Skips events where the cleaned YAML is unchanged (e.g. only resourceVersion bumped)\n5. Outputs the diff in the configured format\n\n## Running Tests\n\nIntegration tests use [envtest](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest) to spin up a real kube-apiserver:\n\n```bash\n# Install envtest binaries (one-time)\ngo install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest\nsetup-envtest use\n\n# Run tests\nKUBEBUILDER_ASSETS=\"$(setup-envtest use --print path)\" go test -v -timeout 120s ./tests/\n```\n\n## Acknowledgements\n\nThis project was inspired by:\n\n- [kubectl-watch-diff](https://github.com/alexmt/kubectl-watch-diff) by Alex Matyushentsev\n- [kube-watch-diff](https://github.com/leopoldxx/kube-watch-diff) by leopoldxx\n\n## License\n\nApache License 2.0 — see [LICENSE](./LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabus23%2Fkubectl-diff-watch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatabus23%2Fkubectl-diff-watch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabus23%2Fkubectl-diff-watch/lists"}