Skip to content

Commit ef3501e

Browse files
Merge branch 'main' into refractor-crp-controller
2 parents e84b596 + df041ef commit ef3501e

32 files changed

+4515
-603
lines changed

CLAUDE.md

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ KubeFleet is a CNCF sandbox project that provides multi-cluster application mana
1616
# Build all binaries
1717
make build
1818

19+
# Run specific agent binaries directly
20+
make run-hubagent
21+
make run-memberagent
22+
1923
# Run all tests (unit + integration)
2024
make test
2125

@@ -27,19 +31,28 @@ make integration-test
2731

2832
# Run E2E tests
2933
make e2e-tests
34+
35+
# Run custom E2E tests with labels
36+
make e2e-tests-custom
3037
```
3138

3239
### Code Quality
3340
```bash
3441
# Run linting (required before commits)
3542
make lint
3643

44+
# Run full linting (slower but more thorough)
45+
make lint-full
46+
3747
# Run static analysis
3848
make staticcheck
3949

4050
# Format code
4151
make fmt
4252

53+
# Run go vet
54+
make vet
55+
4356
# Run all quality checks
4457
make reviewable
4558
```
@@ -64,10 +77,24 @@ make setup-clusters MEMBER_CLUSTER_COUNT=5
6477
# Run parallel E2E tests (default - excludes custom tests)
6578
make e2e-tests
6679

80+
# Collect logs after E2E tests
81+
make collect-e2e-logs
82+
6783
# Clean up test clusters
6884
make clean-e2e-tests
6985
```
7086

87+
### Docker and Images
88+
```bash
89+
# Build and push all images
90+
make push
91+
92+
# Build individual images
93+
make docker-build-hub-agent
94+
make docker-build-member-agent
95+
make docker-build-refresh-token
96+
```
97+
7198
## Architecture Overview
7299

73100
### Core API Types
@@ -79,13 +106,18 @@ make clean-e2e-tests
79106
- **ClusterResourceSnapshot**: Immutable snapshot of cluster resource state for rollback and history
80107
- **ResourceSnapshot**: Immutable snapshot of namespaced resource state for rollback and history
81108
- **Work**: Contains manifests to be applied on member clusters
109+
- **ClusterResourceSnapshot**: Immutable snapshots of resources to be placed
110+
- **ClusterSchedulingPolicySnapshot**: Immutable snapshots of scheduling policies
82111

83112
### Key Controllers
84113
- **ClusterResourcePlacement Controller** (`pkg/controllers/clusterresourceplacement/`): Manages CRP lifecycle
85114
- **Scheduler** (`pkg/scheduler/`): Makes placement decisions using pluggable framework
86115
- **Rollout Controller** (`pkg/controllers/rollout/`): Manages rollout the changes to all the clusters that a placement decision has been made for
87116
- **WorkGenerator** (`pkg/controllers/workgenerator/`): Generates Work objects from bindings
88117
- **WorkApplier** (`pkg/controllers/workapplier/`): Applies Work manifests on member clusters
118+
- **Resource Placement Watchers**: Monitor and react to changes in placement decisions
119+
- **ClusterResourceBinding Watcher** (`pkg/controllers/clusterresourcebindingwatcher/`): Watches binding changes
120+
- **ClusterResourcePlacement Watcher** (`pkg/controllers/clusterresourceplacementwatcher/`): Watches placement changes
89121

90122
### Scheduler Framework
91123
The scheduler uses a pluggable architecture similar to Kubernetes scheduler:
@@ -112,23 +144,39 @@ cmd/hubagent/ # Hub agent main and setup
112144
cmd/memberagent/ # Member agent main and setup
113145
```
114146

115-
## Testing Guidelines
147+
## Development Notes
148+
149+
- Always run `make reviewable` before submitting PRs
150+
- Follow [Uber Go Style Guide](https://github.com/uber-go/guide/blob/master/style.md) when possible
151+
- Favor standard library over third-party libraries
152+
- Controllers should be thoroughly tested with integration tests
153+
- New scheduler plugins should implement both Filter and Score interfaces
154+
- Use existing patterns from similar controllers when adding new functionality
155+
- Property providers should implement the `PropertyProvider` interface
156+
- PR titles must use prefixes: `feat:`, `fix:`, `docs:`, `test:`, `chore:`, `ci:`, `perf:`, `refactor:`, `revert:`
157+
158+
## Testing Patterns
116159

117160
### Unit Tests
118161
- Use `testify` for assertions
119162
- Controllers use `envtest` for integration testing with real etcd
120163
- Mock external dependencies with `gomock`
164+
- Unit test files: `<go_file>_test.go` in same directory
165+
- Table-driven test style preferred
121166

122-
### E2E Tests
123-
- Located in `test/e2e/`
167+
### Integration Tests
168+
- Located in `test/integration/` and `test/scheduler/`
124169
- Use Ginkgo/Gomega framework
125170
- Tests run against real Kind clusters
171+
- Files named: `<go_file>_integration_test.go`
126172
- Separate test suites for different placement strategies
127173

128-
### Integration Tests
129-
- Located in `test/integration/`
174+
### E2E Tests
175+
- Located in `test/e2e/`
176+
- Use Ginkgo/Gomega framework
130177
- Test cross-controller interactions
131178
- Use shared test manifests in `test/integration/manifests/`
179+
- Run with `make e2e-tests` against 3 Kind clusters
132180

133181
## Key Patterns
134182

@@ -153,10 +201,7 @@ All controllers follow standard Kubernetes controller patterns:
153201
- v1beta1 APIs are current stable version
154202
- Feature flags control API version enablement
155203

156-
## Development Notes
157-
158-
- Always run `make reviewable` before submitting PRs
159-
- Controllers should be thoroughly tested with integration tests
160-
- New scheduler plugins should implement both Filter and Score interfaces
161-
- Use existing patterns from similar controllers when adding new functionality
162-
- Property providers should implement the `PropertyProvider` interface
204+
### Watcher Pattern
205+
- Resource placement watchers monitor CRP and binding changes
206+
- Event-driven architecture for responsive placement decisions
207+
- Separate watchers for different resource types to enable focused reconciliation

apis/placement/v1/commons.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ limitations under the License.
1616

1717
package v1
1818

19+
const (
20+
// fleetPrefix is the prefix used for official fleet labels/annotations.
21+
// Unprefixed labels/annotations are reserved for end-users
22+
// See https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#label-selector-and-annotation-conventions
23+
fleetPrefix = "kubernetes-fleet.io/"
24+
)
25+
1926
// NamespacedName comprises a resource name, with a mandatory namespace.
2027
type NamespacedName struct {
2128
// Name is the name of the namespaced scope resource.

0 commit comments

Comments
 (0)