agentleFS
kubefleet-devkubefleet-dev/kubefleet/.github/copilot-instructions.md

kubefleet

Copilot instructions164 starsChanged 6 days agoApache-2.0View on GitHub

KubeFleet is a multi-cluster Kubernetes management system (CNCF sandbox) using a hub-and-spoke model. The hub agent runs on a central cluster; member agents run on each managed cluster. User-created placement flows through a chain of controllers: CRDs starting with Cluster are cluster-scoped; the name without the Cluster prefix is the namespace-scoped counterpart. For example: ClusterResourcePlacement (cluster-scoped) vs ResourcePlacement (namespace-scoped). This affects CRUD operations — namespace-scoped resources require a Namespace field in types.NamespacedName. Pluggable architecture modeled after the Kubernetes scheduler: -…

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this copilot-instructions.md into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All policy and resource changes create immutable snapshot CRDs (ResourceSnapshot, SchedulingPolicySnapshot, OverrideSnapshot).

    line 76
  2. Distinctive:

    Follow the Uber Go Style Guide

    line 88
  3. Distinctive:

    Always add an empty line at the end of new files

    line 91
  4. Very specific:

    Run make reviewable before submitting PRs

    line 92
  5. Very specific:

    Do not use assert libraries.

    line 107
  6. Very specific:

    Use want / wanted (not expect / expected) for desired state variables

    line 108
  7. Very specific:

    Test output format: "FuncName(%v) = %v, want %v"

    line 109
  8. Very specific:

    When adding Ginkgo tests, add to a new Context.

    line 112
  9. Very specific:

    Use .github/.copilot/specifications/ for feature specs.

    line 122

≈ “Common” is an estimate: at least 1 in 5 of the 3,779 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

KubeFleet Copilot Instructions

Build, Test, and Lint Commands

make build                # Build all binaries
make reviewable           # Run all quality checks (fmt, vet, lint, staticcheck, tidy) — required before PRs
make lint                 # Fast linting
make lint-full            # Thorough linting (--fast=false)
make test                 # Unit + integration tests
make local-unit-test      # Unit tests only
make integration-test     # Integration tests only (Ginkgo, uses envtest)
make manifests            # Regenerate CRDs from API types
make generate             # Regenerate deep copy methods

Running a single test

# Single package
go test -v -race -timeout=30m ./pkg/controllers/rollout/...

# Single test by name
go test -v -race -run TestReconcile ./pkg/controllers/rollout/...

# Single Ginkgo integration test by description
cd test/scheduler && ginkgo -v --focus="should schedule"

E2E tests

make setup-clusters                 # Create 3 Kind clusters
make e2e-tests                      # Run E2E suite (ginkgo, ~70min timeout)
make clean-e2e-tests                # Tear down clusters

Architecture

KubeFleet is a multi-cluster Kubernetes management system (CNCF sandbox) using a hub-and-spoke model. The hub agent runs on a central cluster; member agents run on each managed cluster.

Reconciliation Pipeline

User-created placement flows through a chain of controllers:

ClusterResourcePlacement / ResourcePlacement  (user intent)
        ↓
  Placement Controller → creates ResourceSnapshot + SchedulingPolicySnapshot (immutable)
        ↓
  Scheduler → creates ClusterResourceBinding / ResourceBinding (placement decisions)
        ↓
  Rollout Controller → manages staged rollout of bindings
        ↓
  Work Generator → creates Work objects (per-cluster manifests)
        ↓
  Work Applier (member agent) → applies manifests, creates AppliedWork
        ↓
  Status flows back: AppliedWork → Work status → Binding status → Placement status

API Naming Convention

CRDs starting with Cluster are cluster-scoped; the name without the Cluster prefix is the namespace-scoped counterpart. For example: ClusterResourcePlacement (cluster-scoped) vs ResourcePlacement (namespace-scoped). This affects CRUD operations — namespace-scoped resources require a Namespace field in types.NamespacedName.

Scheduler Framework

Pluggable architecture modeled after the Kubernetes scheduler:

  • Plugin interfaces: PreFilterPlugin, FilterPlugin, PreScorePlugin, ScorePlugin, PostBatchPlugin
  • Built-in plugins: clusteraffinity, tainttoleration, clustereligibility, sameplacementaffinity
  • Placement strategies: PickAll (all matching), PickN (top N scored), PickFixed (named clusters)
  • Plugins share state via CycleStatePluginReadWriter

Snapshot-Based Versioning

All policy and resource changes create immutable snapshot CRDs (ResourceSnapshot, SchedulingPolicySnapshot, OverrideSnapshot). This enables rollback, change tracking, and consistent scheduling decisions.

Terminology

  • Fleet: A collection of clusters managed together
  • Hub Cluster: Central control plane cluster
  • Member Cluster: A managed cluster in the fleet
  • Hub Agent: Controllers on the hub for scheduling and placement
  • Member Agent: Controllers on member clusters for applying workloads and reporting status

Code Conventions

  • Follow the Uber Go Style Guide
  • Favor standard library over third-party libraries
  • PR titles must use a prefix: feat:, fix:, docs:, test:, chore:, ci:, perf:, refactor:, revert:, style:, interface:, util:, or [WIP]
  • Always add an empty line at the end of new files
  • Run make reviewable before submitting PRs

Controller Pattern

All controllers embed client.Client, use a standard Reconcile loop (fetch → check deletion → apply defaults → business logic → requeue), update status via the status subresource, and record events. Error handling uses categorized errors (API Server, User, Expected, Unexpected) for retry semantics. See existing controllers in pkg/controllers/ for reference.

API Interface Pattern

Resources implement Conditioned (for status conditions) and ConditionedObj (combining client.Object + Conditioned). See apis/interface.go.

Testing Conventions

  • Unit tests: <file>_test.go in the same directory; table-driven style
  • Integration tests: <file>_integration_test.go; use Ginkgo/Gomega with envtest
  • E2E tests: test/e2e/; Ginkgo/Gomega against Kind clusters
  • Do not use assert libraries; use cmp.Diff / cmp.Equal from google/go-cmp for comparisons
  • Use want / wanted (not expect / expected) for desired state variables
  • Test output format: "FuncName(%v) = %v, want %v"
  • Compare structs in one shot with cmp.Diff, not field-by-field
  • Mock external dependencies with gomock
  • When adding Ginkgo tests, add to a new Context; reuse existing setup

Collaboration Protocol

Domain Knowledge

Refer to .github/.copilot/domain_knowledge/ for entity relationships, workflows, and ubiquitous language. Update these files as understanding grows.

Specifications

Use .github/.copilot/specifications/ for feature specs. Ask which specifications apply if unclear.

Breadcrumb Protocol

For non-trivial tasks, create a breadcrumb file at .github/.copilot/breadcrumbs/yyyy-mm-dd-HHMM-{title}.md to track decisions and progress. Update it before and after code changes, and get plan approval before implementation. See existing breadcrumbs for format examples.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.