This file provides guidance when working with code in this repository.
HyperShift is a middleware for hosting OpenShift control planes at scale. It provides cost-effective and time-efficient cluster provisioning with portability across clouds while maintaining strong separation between management and workloads.
Project documentation is published via MkDocs. The site structure and navigation are defined in docs/mkdocs.yml, with content under docs/content/. When adding or reorganizing documentation pages, update the nav section in mkdocs.yml to keep the site navigation in sync.
- hypershift-operator: Main operator managing HostedCluster and NodePool resources
- control-plane-operator: Manages control plane components for hosted clusters. See support/controlplane-component/README.md
- control-plane-pki-operator: Handles PKI and certificate management
- karpenter-operator: Manages Karpenter resources for auto-scaling
- ignition-server: Serves ignition configs for node bootstrapping
api/: API definitions and CRDs for hypershift, scheduling, certificates, and karpentercmd/: CLI commands for cluster/nodepool management and infrastructure operationshypershift-operator/: Main operator controllers and logiccontrol-plane-operator/: Control plane component managementsupport/: Shared utilities and librariestest/: E2E and integration tests
The codebase supports multiple platforms:
- AWS (primary platform) - both self-managed and managed control plane (aka ROSA HCP)
- Azure - both self-managed and managed control plane (aka ARO HCP)
- IBM Cloud (PowerVS)
- KubeVirt
- OpenStack
- Agent
make build # Build all binaries
make hypershift-operator # Build hypershift-operator
make control-plane-operator # Build control-plane-operator
make hypershift # Build CLImake test # Run unit tests with race detection
make e2e # Build E2E test binaries
make tests # Compile all testsmake lint # Run golangci-lint
make lint-fix # Auto-fix linting issues
make verify # Full verification (generate, fmt, vet, lint, etc.)
make staticcheck # Run staticcheck on core packages
make fmt # Format code
make vet # Run go vetmake api # Regenerate all API resources and CRDs
make generate # Run go generate
make clients # Update generated clients
make update # Full update (api-deps, workspace-sync, deps, api, api-docs, clients)See .claude/skills/dev
- Located throughout the codebase alongside source files
- Use race detection and parallel execution
- Run with
make test
- Located in
test/e2e/ - Platform-specific tests for cluster lifecycle
- Nodepool management and upgrade scenarios
- Karpenter integration tests
- v2 framework standards and patterns: see test/e2e/v2/AGENTS.md
- Located in
test/envtest/with build tagenvtest - Tests CRD validation rules (CEL, OpenAPI schema) against real kube-apiserver + etcd
- Test cases are YAML-driven following the openshift/api convention
- Each YAML file defines
onCreateandonUpdatetest cases with expected errors - Run with
make test-envtest-ocp(OpenShift k8s versions) ormake test-envtest-kube(vanilla k8s versions), ormake test-envtest-api-allfor both - Tests run across multiple Kubernetes versions (1.31–1.35) to verify validation ratcheting and compatibility
- Feature gate filtering: test suites can target stable, tech-preview, or feature-gated CRD variants
See test/envtest/README.md for details
- Located in
test/integration/ - Focus on controller behavior and API interactions
Please see /hypershift/.cursor/rules/code-formatting.mdc
- Follow standard controller-runtime patterns
- Controllers in
hypershift-operator/controllers/andcontrol-plane-operator/controllers/ - Use reconcile loops with proper error handling and requeuing
- Platform-specific logic isolated in separate packages
- Common interfaces defined in
support/packages - Platform implementations in respective controller subdirectories
- Use
support/upsert/for safe resource creation/updates - Follow owner reference patterns for proper garbage collection
- Leverage controller-runtime's structured logging
See api/AGENTS.md
See docs/content/reference/goals-and-design-invariants.md for security and architectural invariants that all code changes must respect.
See docs/content/reference/versioning-support.md for release cycle, version skew policies, and support matrices for the HyperShift Operator, CPO, and other components.
See docs/content/how-to/upgrades.md for Control Plane and Data Plane upgrades
This is a Go 1.25+ project using:
- Kubernetes 0.34.x APIs
- Controller-runtime 0.22.x
- Various cloud provider SDKs (AWS, Azure, IBM)
- OpenShift API dependencies
The project uses vendoring (go mod vendor) and includes workspace configuration in hack/workspace/.
This repository contains multiple Go modules. The api/ directory is a separate Go module with its own api/go.mod (module path: github.com/openshift/hypershift/api). The main module at the repository root consumes the api/ module through vendoring.
This means:
- Edits to files under
api/(e.g.api/hypershift/v1beta1/) are not visible to the main module until the vendored copy is updated. - After modifying any types, constants, or functions in
api/, you must runmake updateto regenerate CRDs, revendor dependencies, and sync everything.make updateruns the full sequence:api-deps→workspace-sync→deps→api→api-docs→clients→docs-aggregate. Without this, the main module build will fail withundefinederrors for any new symbols added inapi/. - Do not modify
vendor/directories directly. Thevendor/directories are managed bygo mod vendor(viamake depsandmake api-deps). Always usemake updateto keep them in sync. - Running
go build ./...orgo vet ./...from the repository root will not compile theapi/module — it is a separate module. To build/vet the API module, run commands from within theapi/directory. - The
hack/workspace/directory contains a Go workspace configuration (go.work) that can be used for local development across both modules.
api/is a separate Go module: Always runmake updateafter modifying types in theapi/package. See Multi-Module Structure above for details.- Do not modify
vendor/directories directly: They are managed bygo mod vendorviamake update. - Use
make verifybefore submitting PRs to catch formatting/generation issues. - Platform-specific controllers require their respective cloud credentials for testing.
- E2E tests need proper cloud infrastructure setup (S3 buckets, DNS zones, etc.).
Please see /hypershift/.cursor/rules/git-commit-format.mdc for information on how commit messages should be generated or formatted in this project.
- The project uses gitlint to enforce commit message format
- gitlint can be run by using this command
make run-gitlint - Ensure all commit messages pass gitlint validation
- Common gitlint rules to follow:
- Conventional commit format
- Proper line length limits
- Required footers
- No trailing whitespace
- Prefer Gherkin Syntax to define unit test cases, e.g. "When... it should..."
- Prefer gomega for unit test assertions