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
Copy file name to clipboardExpand all lines: CLAUDE.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,22 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
6
6
7
7
Cluster API Provider BYOH (BringYourOwnHost) is a Kubernetes infrastructure provider that lets operators declare, provision, and manage Kubernetes clusters on already-provisioned Linux hosts. It decouples node provisioning from host provisioning by running an agent daemon on each BYO host that registers with a management cluster.
8
8
9
+
This repo (`platform9/cluster-api-provider-bringyourownhost`) is Platform9's fork of the upstream `vmware-tanzu/cluster-api-provider-bringyourownhost`. The root Go module keeps the upstream import path (`github.com/vmware-tanzu/cluster-api-provider-bringyourownhost`) for compatibility with existing imports; new Platform9-authored code (`cmd/byohctl`) uses its own module under the `github.com/platform9/...` path instead. Keep this distinction in mind when adding imports — don't assume the whole tree shares one module or one import prefix.
10
+
9
11
## Build & Development Commands
10
12
11
13
```bash
12
14
# Build
13
15
make build # Build manager binary to bin/manager
14
16
make host-agent-binaries # Build host agent binaries
17
+
cd cmd/byohctl && make build # Build byohctl CLI (separate Go module, see Architecture)
15
18
16
19
# Run tests
17
-
make test# All unit tests with coverage
20
+
make test# All unit tests with coverage (includes cmd-test)
18
21
make controller-test # Controller tests only
19
22
make agent-test # Agent tests only
20
23
make webhook-test # Webhook tests only
24
+
make cmd-test # byohctl tests (cd cmd && go test ./...)
21
25
make test-e2e # End-to-end tests (requires a cluster)
The project produces three binaries, two of which share the root Go module:
50
54
-**Manager** (`main.go`) — runs in the management cluster; reconciles `ByoCluster`, `ByoMachine`, `ByoHost`, and related CRs.
51
55
-**Host Agent** (`agent/main.go`) — runs as a daemon on each BYO host; registers the host with the management cluster and drives Kubernetes installation.
56
+
-**byohctl** (`cmd/byohctl/`) — operator-facing CLI for onboarding, deauthorizing, and decommissioning a host (`cmd/byohctl/cmd/{onboard,deauthorise,decommission}.go`). Lives in its own Go module (`cmd/go.mod`) with its own `cmd/byohctl/Makefile`; built and tested independently of the root module — see `make cmd-test`.
@@ -103,4 +108,23 @@ Markers in type files (e.g. `// +kubebuilder:object:root=true`) drive controller
103
108
104
109
## Linting
105
110
106
-
Config is in `.golangci.yml` (timeout 10 min). Key enabled linters include `gosec`, `staticcheck`, `errcheck`, `gocyclo`, and `depguard`. Run `make lint` before submitting; CI enforces this.
111
+
Config is in `.golangci.yml` (v2 schema, timeout 10 min). Key enabled linters include `gosec`, `staticcheck`, `errcheck`, `gocyclo`, and `depguard`. Run `make lint` before submitting; CI enforces this via `golangci-lint-action@v9` pinned to v2.12.2 (`.github/workflows/lint.yml`).
112
+
113
+
Gotcha: the `golangci-lint` target in the Makefile only installs the binary if `bin/golangci-lint` doesn't already exist, and pins an older v1.64.8 install script — if you have a stale v1 binary in `bin/`, `make lint` will run against the v2-schema config and fail or disagree with CI. Delete `bin/golangci-lint` and re-run `make lint` if results look wrong.
114
+
115
+
## Licensing
116
+
117
+
Most existing files carry a VMware copyright header, e.g.:
118
+
```go
119
+
// Copyright 2021 VMware, Inc. All Rights Reserved.
120
+
// SPDX-License-Identifier: Apache-2.0
121
+
```
122
+
123
+
- Never remove or replace an existing copyright header, including VMware's.
124
+
- When editing a file going forward, add a Platform9 copyright line above the `SPDX-License-Identifier` line (don't replace the existing one) using the current year:
125
+
```go
126
+
// Copyright 2021 VMware, Inc. All Rights Reserved.
127
+
// Copyright 2026 Platform9, Inc. All Rights Reserved.
128
+
// SPDX-License-Identifier: Apache-2.0
129
+
```
130
+
- New files that have no prior header get a Platform9-only header.
// Remove UninstallationSecret reference (secret deletion is handled manager-side)
379
-
byoHost.Spec.UninstallationSecret=nil
379
+
//
380
+
// FIXME: Currently we cleanup uninstallation secret from the management plane controller.
381
+
// This means we have split-ownership of cleanup between the agent and the management plane controller.
382
+
// We should ensure agent's boundary for cleanup remains within the host itself and it should not be modifying the ByoHost CR at all. The management of the ByoHost CR is the management plane's responsibility, until the host decides to "deboard". And even then it may only ask the management plane to initiate the cleanup of the CR, but not do so itself.
// FIXME: We only support token based kubeconfig for now. cert based flow needs a redesign. Disable it for now to allow host onboarding for the time being.
88
+
// NOTE: When you're fixing this, see the tests that were skipped as part of the commit that disabled this check.
89
+
//
90
+
// if len(substrs) >= 3 && !strings.Contains(byoHost.Name, substrs[2]) {
0 commit comments