This file provides guidance to AI Agents when working with the machine-api-operator project.
make build # Build all binaries
make test # Run all tests (Ginkgo + envtest)
make lint # Run golangci-lint
make fmt # Format code
make vet # Run go vet
make check # Run all validations (lint, fmt, vet, test)
make crds-sync # Sync CRDs from vendored openshift/api./bin/machine-api-operator start --kubeconfig $KUBECONFIG --images-json=path/to/images.jsonThe Machine API Operator (MAO) manages the lifecycle of Machine resources in OpenShift clusters, enabling declarative machine management across multiple cloud providers.
| Binary | Location | Purpose |
|---|---|---|
| machine-api-operator | cmd/machine-api-operator/ |
Main operator; deploys platform-specific controllers |
| machineset | cmd/machineset/ |
MachineSet replica management |
| machine-healthcheck | cmd/machine-healthcheck/ |
Health monitoring and remediation |
| nodelink-controller | cmd/nodelink-controller/ |
Links Nodes ↔ Machines |
| vsphere | cmd/vsphere/ |
VSphere machine controller |
| machine-api-tests-ext | cmd/machine-api-tests-ext/ |
Extended E2E tests |
Note: Other cloud providers (AWS, GCP, Azure) live in separate
machine-api-provider-*repos.
| Package | Purpose |
|---|---|
pkg/controller/machine/ |
Machine lifecycle (create/delete instances, drain nodes, track phases) |
pkg/controller/machineset/ |
Replica management, delete policies (Random, Oldest, Newest) |
pkg/controller/machinehealthcheck/ |
Node condition monitoring, remediation triggers |
pkg/controller/nodelink/ |
Machine↔Node linking via providerID/IP, label/taint sync |
pkg/controller/vsphere/ |
VSphere actuator |
pkg/operator/ |
Platform detection, controller deployment, ClusterOperator status |
pkg/webhooks/ |
Admission webhooks for Machine/MachineSet validation and mutation |
- CRDs: Machine, MachineSet, MachineHealthCheck
- Uses controller-runtime from sigs.k8s.io
- Vendored dependencies (
go mod vendor, useGOFLAGS=-mod=vendor) - Feature gates controlled via OpenShift's featuregates mechanism
- When bumping
github.com/openshift/api, runmake crds-syncto sync CRDs from/vendorto/install(CVO deploys from there)
make test # All unit tests
NO_DOCKER=1 make test # Run locally without container
make test-e2e # E2E tests (requires KUBECONFIG)TEST_PACKAGES="$(go list -f '{{ .Dir }}' ./pkg/controller/machine/...)" make unit- Default args:
-r -v --randomize-all --randomize-suites --keep-going --race --trace --timeout=10m - Use
GINKGO_EXTRA_ARGSto add arguments - Use
GINKGO_ARGSto override defaults entirely
- Tests use Ginkgo/Gomega with envtest for K8s API simulation
- Prefer komega over plain Gomega/Ginkgo where possible
- Each controller has a
*_suite_test.gofor setup - Follow existing test patterns in the codebase
- Defaults to
podman, falls back todocker USE_DOCKER=1to force DockerNO_DOCKER=1to run locally without containers
- Run
make lintbefore committing - Run
make testto verify changes - Check
pkg/controller/<name>/for controller logic - Look at existing controllers as patterns for new code
- Edit files under
vendor/directly - Add new cloud providers here (they belong in
machine-api-provider-*repos) - Forget to run
go mod vendorafter changing dependencies - Skip running tests before submitting changes