This document provides guidelines and useful commands for AI agents contributing to the Cluster API Provider OpenStack (CAPO) repository.
⚠️ IMPORTANT: When making changes to Makefile targets, PR requirements, code generation workflows, verification steps, or any other information referenced in this document, AGENTS.md must be updated accordingly to keep it synchronized with the actual project state.
Cluster API Provider OpenStack (CAPO) is a Kubernetes-native declarative infrastructure provider for managing Kubernetes clusters on OpenStack. It implements the Cluster API (CAPI) specification for self-managed Kubernetes clusters on OpenStack infrastructure.
Key Concepts:
- CAPI: Cluster API - the upstream Kubernetes project defining cluster lifecycle APIs
- CAPO: Cluster API Provider OpenStack - this repository
- Reconciler: Controller-runtime pattern for managing Kubernetes custom resources
- Scope: Context and configuration wrapper for controllers and services
- CLA Required: All contributors MUST sign the Kubernetes Contributor License Agreement (CLA)
- See: https://git.k8s.io/community/CLA.md
All code PRs MUST be labeled with one of:
⚠️ :warning:- major or breaking changes- ✨
:sparkles:- feature additions - 🐛
:bug:- patch and bugfixes - 📖
:book:- documentation or proposals - 🌱
:seedling:- minor or other
⚠️ IMPORTANT: Themake verifytargets compare the working tree againstHEAD(the last commit). This means:
make verifywill always fail if you have uncommitted changes, even if those changes are correct- You should commit your changes first, then run
make verifyto confirm everything is in order- The typical workflow is: make changes →
make generate→make modules→make test→ commit →make verify
# Run all verification checks (should pass before submitting PR)
# NOTE: This compares against HEAD, so commit your changes first!
make verify
# Verify boilerplate headers
make verify-boilerplate
# Verify go modules are up to date (runs `go mod tidy` and diffs against HEAD)
make verify-modules
# Verify generated code is up to date (runs `make generate` and diffs against HEAD)
make verify-gen
# Verify container images for vulnerabilities
make verify-container-images
# Check code for security vulnerabilities
make verify-govulncheck
# Run all security checks (images + code)
make verify-security# Lint codebase
make lint
# Lint and auto-fix issues
make lint-update
# Run faster linters only
make lint-fast# Run unit tests
make test
# Run unit tests for CAPO specifically
make test-capo
# Build e2e test binaries
make build-e2e-tests
# Run e2e tests (requires OpenStack environment)
make test-e2e
# Run conformance tests
make test-conformance
# Compile e2e tests (verify they build)
make compile-e2e# Generate ALL code (manifests, deepcopy, clients, mocks, docs)
make generate
# Generate Go code (mocks, etc.)
make generate-go
# Generate controller-gen code (deepcopy, etc.)
make generate-controller-gen
# Generate client code (clientsets, listers, informers)
make generate-codegen
# Generate CRD manifests
make generate-manifests
# Generate API documentation
make generate-api-docs
# Generate cluster templates
make templates# Update go modules
make modules
# Check for API differences (useful before breaking changes)
make apidiff# Build manager binaries
make managers
# Build all binaries
make binaries
# Build Docker image
make docker-build
# Build debug Docker image
make docker-build-debug
# Build for all architectures
make docker-build-all# Clean all build artifacts
make clean
# Clean binaries only
make clean-bin
# Clean temporary files
make clean-temporary
# Clean release artifacts
make clean-release- Define API types in
/api/v1beta1(or/api/v1alpha1for experimental features) - Run
make generateto create deepcopy methods and update CRDs - Create controller in
/controllers - Create service implementation in
/pkg/cloud/services/<category> - Update or create scope in
/pkg/scopeif needed - Add webhooks in
/pkg/webhooksfor validation/defaulting - Add unit tests for controller and services
- Update documentation
- Generate cluster templates if applicable with
make templates
- Unit Tests: Test individual functions/methods with mocks
- Integration Tests: Test controller behavior with envtest
- E2E Tests: Deploy real clusters on OpenStack, verify functionality
- Conformance Tests: Run upstream Kubernetes conformance suite
Before submitting a PR, ensure:
-
Code is generated and up to date:
make generate
-
Modules are tidy:
make modules
-
Code passes linting:
make lint
-
Tests pass:
make test -
All verification checks pass:
make verify
- Make your code changes
- Run code generation:
make generate - Update modules if needed:
make modules - Run tests:
make test - Lint the code:
make lint - Commit changes with descriptive message
- Verify everything:
make verify(this compares against HEAD, so must be done after commit)
- Update
go.modorhack/tools/go.modas needed (e.g.,go get sigs.k8s.io/cluster-api@v1.x.x) - Run:
make modulesto tidy dependencies - Run:
make generateto regenerate code (dependency updates often change generated code) - Run:
make testto ensure everything still works - Commit all changes (go.mod, go.sum, and any regenerated files)
- Run:
make verifyto confirm everything is in order
The project uses golangci-lint. If you get lint errors:
- Run
make lint-updatefirst to auto-fix - Check
.golangci.ymlfor enabled linters - Some issues require manual fixes (cognitive complexity, error handling, etc.)
- Don't disable linters without good reason - fix the underlying issue
- envtest issues: Ensure KUBEBUILDER_ASSETS is set correctly
- Flaky E2E tests: Transient infrastructure issues, failure to deploy devstack
If make verify fails with generated file drift:
- Run
make generateto regenerate all files - Run
make modulesto ensure go.mod/go.sum are tidy - Review the changes to ensure they're expected
- Commit the generated files - verify targets compare against HEAD!
- Run
make verifyagain - it should pass now - Never manually edit generated files
If make verify-gen or make verify-modules fails even after running make generate or make modules:
- Remember that these targets compare against
HEAD(the last commit) - If you have uncommitted changes, they will show as "drift" even if correct
- Solution: Commit your changes first, then run
make verify - This is by design - it ensures the committed code is complete and self-consistent
Primary documentation is in /docs/book/src/ (mdBook format):
- Getting started guides
- Developer documentation
- Troubleshooting guides
- API reference
- Cluster template documentation
Build and serve docs locally:
make -C docs/book serve| Task | Command |
|---|---|
| Full verification before PR | make verify && make test |
| Generate all code | make generate |
| Update dependencies | make modules |
| Lint and fix | make lint-update |
| Run tests | make test |
| Build binary | make managers |
| Build Docker image | make docker-build |
| Clean everything | make clean |
| Check API compatibility | make apidiff |
| Generate templates | make templates |
| Build and serve docs | make -C docs/book serve |