Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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/<provider>/` (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.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AGENTS.md
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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