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..75cf2094 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,28 @@ +# Agent Instructions + +Rules and gotchas for AI agents working on the `karpenter-operator` repository. + +## What This Repo Is + +`karpenter-operator` is an OpenShift operator that deploys and manages [Karpenter](https://karpenter.sh/) on OpenShift clusters. It discovers the cluster's cloud provider at runtime and configures Karpenter accordingly. + +## Multi-cloud Rules + +This operator must support multiple cloud providers. Only AWS is implemented so far, but these rules apply to all code changes: + +- **Never import cloud-provider SDKs in generic packages.** Cloud-specific code belongs in `pkg/cloudprovider//`. Generic code in `cmd/`, `pkg/operator/`, and `pkg/controllers/` must interact through the `CloudProvider` interface only. +- **Detect the provider at runtime** from the `Infrastructure` CR (`status.platformStatus.type`), not from build tags or hardcoded assumptions. +- When adding provider-specific behavior, ask: "What would the other providers need here?" and leave room for it (interface methods, switch statements, TODOs). + +## Operator / Operand Separation + +The **operator** (this binary) manages the **operand** (Karpenter). They are separate images in separate Deployments. Do not conflate them — the operator creates and manages the operand's Deployment, ServiceAccount, and RBAC. They share a namespace but have independent credentials and RBAC. + +The operand image varies by cloud provider — each provider has its own Karpenter image. The operator must select the correct operand image based on the discovered infrastructure. + +## Coding Gotchas + +- **Dependencies are vendored.** Always run `make vendor` after changing `go.mod`. Do not use `go get` alone. +- **Import ordering** is enforced by `.golangci.yml`. Run `make lint` after changes — it auto-fixes. +- **Run `make verify`** after any code change. It runs vet, fmt, lint, and tests together. +- **No narrating comments.** Do not add comments that restate what the code does. Comments should only explain non-obvious intent, trade-offs, or constraints. 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