You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Run all tests with `make test`. Integration tests live under `tests/operator/` and expect a reachable Pulsar cluster; set `NAMESPACE`, `BROKER_NAME`, `PROXY_URL` as needed.
32
+
- Keep tests deterministic and fast; prefer envtest for controller logic.
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Project Overview
6
+
7
+
Pulsar Resources Operator is a Kubernetes operator that manages Apache Pulsar resources (tenants, namespaces, topics, permissions, functions, sinks, sources, etc.) using Custom Resource Definitions. Built with the Operator SDK and controller-runtime framework.
8
+
9
+
## Common Commands
10
+
11
+
### Build and Run
12
+
```bash
13
+
make build # Build manager binary
14
+
make run # Run controller locally (requires CRDs installed)
15
+
go run .# Alternative: run operator locally
16
+
```
17
+
18
+
### Code Generation
19
+
```bash
20
+
make generate # Generate DeepCopy methods for API types
21
+
make generate-internal # Generate internal types and client code
22
+
make manifests # Generate CRDs, RBAC, and webhook configurations
23
+
```
24
+
25
+
### Testing
26
+
```bash
27
+
make test# Run all tests with coverage
28
+
29
+
# Run single test
30
+
go test -v ./pkg/connection -run TestReconcileTenant
31
+
32
+
# E2E tests (separate module in tests/)
33
+
cd tests && ginkgo --trace --progress ./operator
34
+
35
+
# Run E2E tests against external Pulsar cluster
36
+
export ADMIN_SERVICE_URL=http://localhost:80
37
+
export NAMESPACE=pulsar
38
+
cd tests && ginkgo --trace --progress ./operator
39
+
```
40
+
41
+
### Linting and Formatting
42
+
```bash
43
+
make fmt # Run go fmt
44
+
make vet # Run go vet
45
+
make license-check # Check license headers
46
+
make license-fix # Fix license headers
47
+
```
48
+
49
+
### Deployment
50
+
```bash
51
+
make install # Install CRDs to cluster
52
+
make uninstall # Remove CRDs from cluster
53
+
make deploy IMG=<image># Deploy operator to cluster
54
+
make undeploy # Remove operator from cluster
55
+
```
56
+
57
+
### Helm Chart
58
+
```bash
59
+
make copy-crds # Sync CRDs to charts/pulsar-resources-operator/crds
60
+
```
61
+
62
+
## Architecture
63
+
64
+
### Entry Point and Controller Setup
65
+
-`main.go` - Initializes the controller manager and registers all reconcilers
1.**PulsarConnectionReconciler** - Central controller that manages Pulsar resources by watching `PulsarConnection` and all related resource types. Triggers reconciliation when any dependent resource changes.
75
+
2.**StreamNative Cloud Controllers** - Individual controllers for cloud resources (`APIServerConnectionReconciler`, `WorkspaceReconciler`, `FlinkDeploymentReconciler`, etc.) that share a `ConnectionManager` for API connectivity.
76
+
77
+
### Core Packages (`pkg/`)
78
+
-`connection/` - Pulsar resource reconciliation logic with sub-reconcilers for each resource type (tenant, namespace, topic, permission, etc.)
79
+
-`admin/` - Pulsar Admin API client wrapper
80
+
-`streamnativecloud/` - StreamNative Cloud API clients and converters
-`utils/` - Retry logic, event source, and helper utilities
83
+
-`feature/` - Feature gate management
84
+
85
+
### Reconciliation Pattern
86
+
The operator uses a hierarchical reconciliation pattern:
87
+
1.`PulsarConnection` serves as the parent resource linking to a Pulsar cluster
88
+
2. Child resources (tenants, namespaces, topics) reference a connection via `spec.connectionRef` with an indexed field (`spec.connectionRef.name`) for efficient lookup
89
+
3. When any child resource changes, it triggers the parent connection's reconciliation
90
+
4. The connection reconciler iterates through all associated resources and reconciles them in dependency order
0 commit comments