|
| 1 | +# AGENTS.md - openstack-baremetal-operator |
| 2 | + |
| 3 | +## Project overview |
| 4 | + |
| 5 | +openstack-baremetal-operator is a Kubernetes operator that manages |
| 6 | +bare metal provisioning infrastructure for |
| 7 | +[OpenStack](https://docs.openstack.org/) on OpenShift/Kubernetes. It handles |
| 8 | +provisioning physical servers (PXE boot, RHEL image serving) and matching |
| 9 | +hardware requirements (CPU count/MHz, memory, disk size/SSD) for OpenStack |
| 10 | +services. It is part of the |
| 11 | +[openstack-k8s-operators](https://github.com/openstack-k8s-operators) project. |
| 12 | + |
| 13 | +Key domain concepts: **bare metal sets** (groups of provisioned hosts), |
| 14 | +**provision servers** (HTTP image serving), **hardware requirements** |
| 15 | +(CPU count, CPU MHz, memory, disk size, SSD), **IPMI**, **BMC** (Baseboard |
| 16 | +Management Controller), **Metal3** (bare metal host management). |
| 17 | + |
| 18 | +## Tech stack |
| 19 | + |
| 20 | +| Layer | Technology | |
| 21 | +|-------|------------| |
| 22 | +| Language | Go (modules, multi-module workspace via `go.work`) | |
| 23 | +| Scaffolding | [Kubebuilder v4](https://book.kubebuilder.io/) + [Operator SDK](https://sdk.operatorframework.io/) | |
| 24 | +| CRD generation | controller-gen (DeepCopy, CRDs, RBAC, webhooks) | |
| 25 | +| Config management | Kustomize | |
| 26 | +| Packaging | OLM bundle | |
| 27 | +| Testing | Ginkgo/Gomega + envtest (functional) | |
| 28 | +| Linting | golangci-lint (`.golangci.yaml`) | |
| 29 | +| CI | Zuul (`zuul.d/`), Prow (`.ci-operator.yaml`), GitHub Actions | |
| 30 | + |
| 31 | +## Custom Resources |
| 32 | + |
| 33 | +| Kind | Purpose | |
| 34 | +|------|---------| |
| 35 | +| `OpenStackBaremetalSet` | Manages a set of bare metal hosts provisioned for OpenStack services. Matches hardware requirements and provisions via Metal3. | |
| 36 | +| `OpenStackProvisionServer` | Manages an HTTP server for serving RHEL images to bare metal nodes during provisioning. | |
| 37 | + |
| 38 | +Both CRs have defaulting and validating admission webhooks. |
| 39 | + |
| 40 | +## Directory structure |
| 41 | + |
| 42 | +| Directory | Contents | |
| 43 | +|-----------|----------| |
| 44 | +| `api/v1beta1/` | CRD types (`openstackbaremetalset_types.go`, `openstackprovisionserver_types.go`), conditions, webhook markers | |
| 45 | +| `cmd/` | `main.go` entry point | |
| 46 | +| `internal/controller/` | Reconcilers: `openstackbaremetalset_controller.go`, `openstackprovisionserver_controller.go` | |
| 47 | +| `internal/openstackbaremetalset/` | BaremetalSet resource builders (bare metal host management, set helpers) | |
| 48 | +| `internal/openstackprovisionserver/` | ProvisionServer resource builders (deployment, volumes, init containers, jobs) | |
| 49 | +| `internal/webhook/` | Webhook implementation | |
| 50 | +| `templates/` | Config files and scripts mounted into pods via `OPERATOR_TEMPLATES` env var. Subdirs: `openstackbaremetalset/`, `openstackprovisionserver/` | |
| 51 | +| `config/crd,rbac,manager,webhook/` | Generated Kubernetes manifests (CRDs, RBAC, deployment, webhooks) | |
| 52 | +| `config/samples/` | Example CRs | |
| 53 | +| `containers/` | Container image build files (agent) | |
| 54 | +| `tests/functional/` | envtest-based Ginkgo/Gomega tests | |
| 55 | +| `hack/` | Helper scripts | |
| 56 | + |
| 57 | +## Build commands |
| 58 | + |
| 59 | +After modifying Go code, always run: `make generate manifests fmt vet`. |
| 60 | + |
| 61 | +## Code style guidelines |
| 62 | + |
| 63 | +- Follow standard openstack-k8s-operators conventions and lib-common patterns. |
| 64 | +- Use `lib-common` modules for conditions, endpoints, TLS, storage, and other |
| 65 | + cross-cutting concerns rather than re-implementing them. |
| 66 | +- CRD types go in `api/v1beta1/`. Controller logic goes in |
| 67 | + `internal/controller/`. Resource-building helpers go in |
| 68 | + `internal/openstackbaremetalset/` and `internal/openstackprovisionserver/` |
| 69 | + packages matching the CR they support. |
| 70 | +- Config templates are plain files in `templates/` -- they are mounted at |
| 71 | + runtime via the `OPERATOR_TEMPLATES` environment variable. |
| 72 | +- Webhook logic is split between the kubebuilder markers in `api/v1beta1/` and |
| 73 | + the implementation in `internal/webhook/`. |
| 74 | + |
| 75 | +## Testing |
| 76 | + |
| 77 | +- Functional tests use the envtest framework with Ginkgo/Gomega and live in |
| 78 | + `tests/functional/` (note: `tests/` not `test/`). |
| 79 | +- There are no KUTTL integration tests in this operator. |
| 80 | +- Run all functional tests: `make test`. |
| 81 | +- When adding a new field or feature, add corresponding test cases in |
| 82 | + `tests/functional/`. |
| 83 | + |
| 84 | +## Key dependencies |
| 85 | + |
| 86 | +- [lib-common](https://github.com/openstack-k8s-operators/lib-common): shared modules for conditions, endpoints, TLS, secrets, etc. |
| 87 | +- [Metal3 baremetal-operator](https://github.com/metal3-io/baremetal-operator): manages `BareMetalHost` CRDs for bare metal host lifecycle. |
| 88 | +- [Cluster Baremetal Operator](https://github.com/openshift/cluster-baremetal-operator): manages the `Provisioning` CRD for Metal3 provisioning infrastructure on OpenShift. |
0 commit comments