fleet
CLAUDE.md227 starsChanged 9 months agoApache-2.0View on GitHub
KubeFleet is a CNCF sandbox project that provides multi-cluster application management for Kubernetes. It uses a hub-and-spoke architecture with two main components:
We split this CLAUDE.md into the rules it gives an agent
17 rules. About 0 are common, 13 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 133
PickAll: Place on all matching clusters
- Distinctive: line 134
PickN: Place on N highest-scoring clusters
- Distinctive: line 135
PickFixed: Place on specific named clusters
- Very specific: line 153
Always run make reviewable before submitting PRs
- Distinctive: line 154
Follow Uber Go Style Guide when possible
- Distinctive: line 158
Use existing patterns from similar controllers when adding new functionality
- Distinctive: line 161
When creating new files, always add an empty line at the end
- Distinctive: line 166
Avoid the use of ‘assert’ libraries.
- Distinctive: line 171
Use cmp.Equal for equality comparison and cmp.Diff to obtain a human-readable diff between objects.
- Distinctive: line 172
Test outputs should output the actual value that the function returned before printing the value that was expected.
- Distinctive: line 175
If your function returns multiple return values, you don’t need to wrap those in a struct before comparing them.
- Distinctive: line 179
Use Ginkgo/Gomega framework
- Very specific: line 188
Use shared test manifests in test/integration/manifests/
- Very specific: line 189
Run with make e2e-tests against 3 Kind clusters
- Very specific: line 192
Use want or wanted instead of expect or expected when creating the desired state
- Distinctive: line 200
All controllers follow standard Kubernetes controller patterns:
- Distinctive: line 206
All policy changes create immutable snapshots
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md 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.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
KubeFleet is a CNCF sandbox project that provides multi-cluster application management for Kubernetes. It uses a hub-and-spoke architecture with two main components:
- Hub Agent: Runs on the central hub cluster, manages placement decisions, scheduling, and cluster inventory
- Member Agent: Runs on each member cluster, applies workloads and reports cluster status
Common Development Commands
Building and Testing
# Build all binaries
make build
# Run specific agent binaries directly
make run-hubagent
make run-memberagent
# Run all tests (unit + integration)
make test
# Run unit tests only
make local-unit-test
# Run integration tests only
make integration-test
# Run E2E tests
make e2e-tests
# Run custom E2E tests with labels
make e2e-tests-custom
# Clean up E2E environment
make clean-e2e-testsCode Quality
# Run linting (required before commits)
make lint
# Run full linting (slower but more thorough)
make lint-full
# Run static analysis
make staticcheck
# Format code
make fmt
# Run go vet
make vet
# Run all quality checks
make reviewableCode Generation
# Generate CRDs and manifests
make manifests
# Generate deep copy methods
make generateE2E Testing
# Set up test clusters (creates 3 member clusters by default)
make setup-clusters
# Run E2E tests with custom cluster count
make setup-clusters MEMBER_CLUSTER_COUNT=5
# Run parallel E2E tests (default - excludes custom tests)
make e2e-tests
# Collect logs after E2E tests
make collect-e2e-logs
# Clean up test clusters
make clean-e2e-testsDocker and Images
# Build and push all images
make push
# Build individual images
make docker-build-hub-agent
make docker-build-member-agent
make docker-build-refresh-tokenArchitecture Overview
Core API Types
- ClusterResourcePlacement (CRP): Main API for placing cluster scoped resources across clusters with scheduling policies. If one namespace is selected, we will place everything in that namespace across clusters.
- ResourcePlacement (RP): Main API for placing namespaced resources across clusters with scheduling policies.
- MemberCluster: Represents a member cluster with identity and heartbeat settings
- ClusterResourceBinding: Represents scheduling decisions binding cluster scoped resources to clusters
- ResourceBinding: Represents scheduling decisions binding resources to clusters
- ClusterResourceSnapshot: Immutable snapshot of cluster resource state for rollback and history
- ResourceSnapshot: Immutable snapshot of namespaced resource state for rollback and history
- Work: Contains manifests to be applied on member clusters
- ClusterResourceSnapshot: Immutable snapshots of resources to be placed
- ClusterSchedulingPolicySnapshot: Immutable snapshots of scheduling policies
Key Controllers
- ClusterResourcePlacement Controller (
pkg/controllers/clusterresourceplacement/): Manages CRP lifecycle - Scheduler (
pkg/scheduler/): Makes placement decisions using pluggable framework - Rollout Controller (
pkg/controllers/rollout/): Manages rollout the changes to all the clusters that a placement decision has been made for - WorkGenerator (
pkg/controllers/workgenerator/): Generates Work objects from bindings - WorkApplier (
pkg/controllers/workapplier/): Applies Work manifests on member clusters - Resource Placement Watchers: Monitor and react to changes in placement decisions
- ClusterResourceBinding Watcher (
pkg/controllers/clusterresourcebindingwatcher/): Watches binding changes - ClusterResourcePlacement Watcher (
pkg/controllers/clusterresourceplacementwatcher/): Watches placement changes
Scheduler Framework
The scheduler uses a pluggable architecture similar to Kubernetes scheduler:
- Filter plugins:
clusteraffinity,tainttoleration,clustereligibility - Score plugins:
clusteraffinity,sameplacementaffinity - Property-based scheduling: Uses cluster properties (CPU, memory, cost) for decisions
Placement Strategies
- PickAll: Place on all matching clusters
- PickN: Place on N highest-scoring clusters
- PickFixed: Place on specific named clusters
Directory Structure
apis/ # API definitions and CRDs
├── cluster/v1beta1/ # MemberCluster APIs
├── placement/v1beta1/ # Placement and work APIs
pkg/controllers/ # All controllers organized by resource type
pkg/scheduler/ # Scheduler framework and plugins
pkg/propertyprovider/ # Cloud-specific property providers (Azure)
pkg/utils/ # Shared utilities and helpers
cmd/hubagent/ # Hub agent main and setup
cmd/memberagent/ # Member agent main and setupDevelopment Notes
- Always run
make reviewablebefore submitting PRs - Follow Uber Go Style Guide when possible
- Favor standard library over third-party libraries
- Controllers should be thoroughly tested with integration tests
- New scheduler plugins should implement both Filter and Score interfaces
- Use existing patterns from similar controllers when adding new functionality
- Property providers should implement the
PropertyProviderinterface - PR titles must use prefixes:
feat:,fix:,docs:,test:,chore:,ci:,perf:,refactor:,revert: - When creating new files, always add an empty line at the end
Testing Patterns
Unit Tests
- Avoid the use of ‘assert’ libraries.
- Controllers use
envtestfor integration testing with real etcd - Mock external dependencies with
gomock - Unit test files:
<go_file>_test.goin same directory - Table-driven test style preferred
- Use cmp.Equal for equality comparison and cmp.Diff to obtain a human-readable diff between objects.
- Test outputs should output the actual value that the function returned before printing the value that was expected. A usual format for printing test outputs is “YourFunc(%v) = %v, want %v”.
- If your function returns a struct, don’t write test code that performs an individual comparison for each field of the struct. Instead, construct the struct that you’re expecting your function to return, and compare in one shot using diffs or deep comparisons. The same rule applies to arrays and maps.
- If your struct needs to be compared for approximate equality or some other kind of semantic equality, or it contains fields that cannot be compared for equality (e.g. if one of the fields is an io.Reader), tweaking a cmp.Diff or cmp.Equal comparison with cmpopts options such as cmpopts.IgnoreInterfaces may meet your needs (example); otherwise, this technique just won’t work, so do whatever works.
- If your function returns multiple return values, you don’t need to wrap those in a struct before comparing them. Just compare the return values individually and print them.
Integration Tests
- Located in
test/integration/andtest/scheduler/ - Use Ginkgo/Gomega framework
- Tests run against real Kind clusters
- Files named:
<go_file>_integration_test.go - Separate test suites for different placement strategies
E2E Tests
- Located in
test/e2e/ - Use Ginkgo/Gomega framework
- Test cross-controller interactions
- Use shared test manifests in
test/integration/manifests/ - Run with
make e2e-testsagainst 3 Kind clusters
Test Coding Style
- Use
wantorwantedinstead ofexpectorexpectedwhen creating the desired state - Comments that are complete sentences should be capitalized and punctuated like standard English sentences. (As an exception, it is okay to begin a sentence with an uncapitalized identifier name if it is otherwise clear. Such cases are probably best done only at the beginning of a paragraph.)
- Comments that are sentence fragments have no such requirements for punctuation or capitalization.
- Documentation comments should always be complete sentences, and as such should always be capitalized and punctuated. Simple end-of-line comments (especially for struct fields) can be simple phrases that assume the field name is the subject.
Key Patterns
Controller Pattern
All controllers follow standard Kubernetes controller patterns:
- Reconcile functions with retry logic
- Status subresource updates
- Event recording for debugging
Snapshot-based Versioning
- All policy changes create immutable snapshots
- Enables rollback and change tracking
- Snapshots stored as separate CRDs
Property-based Scheduling
- Property providers collect cluster metrics
- Azure provider tracks VM costs and node properties
- Custom properties supported for scheduling decisions
Multi-API Version Support
- v1beta1 APIs are current stable version
- Feature flags control API version enablement
Watcher Pattern
- Resource placement watchers monitor CRP and binding changes
- Event-driven architecture for responsive placement decisions
- Separate watchers for different resource types to enable focused reconciliation
Other versions1 project uses a version of this.
Word for word · 1
- kubefleet-dev/kubefleet★ 162100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- agent-collaborationSkill
- coordinator-init-modeSkill
- coordinator-response-modeSkill
- coordinator-source-of-truthSkill
- cross-squad-communicationSkill
- cross-squadSkill
- error-recoverySkill
- git-workflowSkill
- iterative-retrievalSkill
- reflectSkill
- reviewer-protocolSkill
- secret-handlingSkill
- session-recoverySkill
- squad-conventionsSkill
- squad-helpSkill
- squadSkill
- squad-version-checkSkill
- test-disciplineSkill
- tiered-memorySkill
- humanizerSkill
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
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.

