diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 00000000..e333730a --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,32 @@ +inheritance: true +language: en-US +reviews: + profile: "chill" + request_changes_workflow: false + high_level_summary: true + high_level_summary_placeholder: "@coderabbitai summary" + high_level_summary_in_walkthrough: true + review_status: true + collapse_walkthrough: true + sequence_diagrams: false + estimate_code_review_effort: false + poem: false + suggested_labels: false + changed_files_summary: true + auto_review: + enabled: true + drafts: true + path_filters: + - "!vendor/**" + tools: + golangci-lint: + enabled: true +knowledge_base: + code_guidelines: + enabled: true + filePatterns: + - AGENTS.md + - .claude/agents/*.md + - .cursor/rules/*.mdc + learnings: + scope: local diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..138e7e73 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,50 @@ +# Agent Instructions + +This file provides context and rules for AI agents (Cursor, Claude Code, Copilot, etc.) working on the `karpenter-operator` repository. + +## What This Repo Is + +`karpenter-operator` is a CVO-managed (Cluster Version Operator) OpenShift operator that deploys and manages [Karpenter](https://karpenter.sh/) as an operand on OpenShift clusters. The operator discovers the cluster's cloud infrastructure at runtime and configures Karpenter accordingly. + +**This repo is currently scaffolding only.** The operator starts, runs health checks, and participates in leader election, but does not yet register any controllers or reconcile any resources. Cloud-provider logic, controllers, and CRDs will be added in subsequent commits. + +## Repository Layout + +```none +cmd/ Operator entry point +pkg/operator/ Manager setup, options, validation +pkg/version/ Build-time version injection +pkg/cloudprovider/ CloudProvider interface + per-provider implementations (planned) +pkg/controllers/ Reconcilers (planned) +install/ CVO manifests (applied as-is to the cluster) +``` + +## Design Principles + +### Multi-cloud from the start + +This operator will eventually support deploying Karpenter on most major cloud providers, as well as Cluster API. +Even though only AWS is being implemented first: + +- **Never import cloud-provider SDKs in generic packages.** Cloud-specific code belongs in `pkg/cloudprovider//` (to be added). Generic code in `cmd/`, `pkg/operator/`, and `pkg/controllers/` must interact through interfaces. +- **Use a `CloudProvider` interface** for anything provider-specific: credential readiness checks, operand configuration, node class reconciliation, CSR verification, etc. +- **Detect the provider at runtime** from the OpenShift `Infrastructure` CR (`status.platformStatus.type`), not from build tags or hardcoded assumptions. +- When adding AWS-specific behavior, always ask: "What would the Azure/GCP equivalent look like?" and leave room for it (interface methods, switch statements, TODOs). + +### CVO integration + +- Manifests in `install/` must carry `exclude.release.openshift.io/internal-openshift-hosted: "true"` and `include.release.openshift.io/self-managed-high-availability: "true"` annotations, or CVO will skip them. +- CVO rewrites container image references in manifests when they match entries in `install/image-references`. Do not hardcode real image pullspecs — use the placeholder values from `image-references` instead. +- CVO does not template or interpolate values in manifests. Any runtime configuration (cluster name, cloud provider details, etc.) must be discovered by the operator at startup. + +### Operator / operand separation + +- The **operator** (this binary) runs on control-plane nodes, discovers infrastructure, and manages the operand lifecycle. +- The **operand** (Karpenter) is a separate image deployed by the operator into the same namespace. The operator creates the operand's Deployment, ServiceAccount, RBAC, and passes cloud configuration via environment variables and volume mounts. + +## Coding Conventions + +- **Dependencies** are vendored. Run `make vendor` after changing `go.mod`. +- **Import ordering** is opinionated and enforced by `.golangci.yml`. Run `make lint` after changes to auto-fix. +- **Linting and testing**: Run `make verify` to execute all checks. See `Makefile` for individual targets. +- **No comments that just narrate code.** Comments should explain non-obvious intent, trade-offs, or constraints only. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..47dc3e3d --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..c4534057 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# karpenter-operator + +OpenShift operator that deploys and manages [Karpenter](https://karpenter.sh/) on Red Hat OpenShift clusters. Managed by the Cluster Version Operator (CVO) as part of the OpenShift release payload. + +## Building + +```bash +make build # Build the operator binary +make test # Run unit tests +make lint # Run golangci-lint +make verify # Run all checks (vet, fmt, lint, test) +make docker-build # Build container image +``` + +## Deploying (dev) + +```bash +make deploy \ + IMG=quay.io/you/karpenter-operator:dev \ + OPERAND_IMG=quay.io/you/karpenter:dev \ + CLUSTER_NAME=my-cluster \ + DEV=true +``` + +## Documentation + +- [AGENTS.md](AGENTS.md) — design principles and coding conventions for contributors and AI agents