This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Kong Operator is a Kubernetes Operator (Kubebuilder v4, multigroup layout) that manages Kong Gateway deployments and Kong Kubernetes Ingress Controllers. Domain: gateway-operator.konghq.com.
make build # Full build: generate code + compile binary to bin/manager
make build.operator # Build optimized binary only (no code generation)
make generate # Full code generation (CRDs, deepcopy, mocks, docs, manifests, chart golden files)
make manifests # Generate CRDs and RBAC manifests only
make tools # Install all required development tools via misemake lint # Run Go linters (modules, golangci-lint)
make lint.all # Full lint: Go + charts + GitHub Actions + markdown
make lint.api # Lint Kubernetes API types
make lint.golangci-lint # Run golangci-lint linter for Go code
make go-fix # Run go-fix on the codebase to ensure you're not using old or deprecated Go constructs.CI runs make lint with GOLANGCI_LINT_FLAGS="--fix=false" (auto-fix is enabled locally but disabled in CI).
make test.unit # Run unit tests with verbose output
make test.unit.pretty # Run unit tests with compact output
make test.unit.pretty GOTESTFLAGS="-run TestSpecificGatewayNN -count 1" # Run specific testmake test.envtest # Run envtest tests with standard verbose output
make test.envtest.pretty # Run envtest tests with compact output
make test.envtest CLUSTER_VERSION=1.30 # Run envtest tests with specific Kubernetes (apiserver) version
make test.envtest GOTESTFLAGS="-run TestSpecificGatewayNN -count 1" # Run specific test from envtest suitemake test.integration-ko # Kong Operator integration tests
make test.integration-bluegreen # DataPlane upgrade/blue-green tests
make test.integration-validatingwebhook # Webhook testsmake test.crds-validation # Run the CRD validation tests. This uses envtest to run tests against real Kubernetes API server.
make test.crds-validation.pretty # Run the CRD validation tests with pretty output. This uses envtest to run tests against real Kubernetes API server.
### Other Tests
```bash
make test.conformance # Gateway API conformance tests
make test.kongintegration # Kong integration tests (uses testcontainers)
make test.e2e # End-to-end tests
make test.e2e.chainsaw # Chainsaw-based E2E tests
make test.charts.golden # Helm chart golden file tests
make test.charts.golden.update # Update chart golden files- Unit tests:
*_test.gofiles next to source code - Envtest:
test/envtest/ - Integration:
test/integration/ - Conformance:
test/conformance/ - CRD validation:
test/crdsvalidation/ - E2E:
test/e2e/ - Mocks:
test/mocks/(generated by mockery)
make run # Run operator locally via telepresence (installs CRDs, sets up RBAC)
make run.skaffold # Run with skaffold for iterative development
make debug # Run with delve debuggerRequires a Kubernetes cluster configured in KUBECONFIG and telepresence installed.
cmd/main.go → modules/cli.Parse() → modules/manager.Run() → SetupControllers()
Kubernetes API definitions which are used to generate CRDs, deepcopy methods, clientsets, informers, listers, and documentation.
api/gateway-operator/v1beta1/- DataPlane, ControlPlane, GatewayConfigurationapi/gateway-operator/v1alpha1/- AIGateway (experimental), DataPlaneMetricsExtensionapi/konnect/v1alpha1/,v1alpha2/- Konnect integrationapi/configuration/- Kong configuration typesapi/common/v1alpha1/- Shared types (ControlPlaneRef, ObjectRef, KongTags)
Each implements SetupWithManager(ctx, mgr) and Reconcile(ctx, req):
dataplane/- Manages Kong Gateway Deployments, Services, ConfigMapscontrolplane/- Manages Kong Ingress Controller deploymentsgateway/- Implements Gateway API, creates DataPlane/ControlPlanekonnect/- Konnect cloud synchronizationhybridgateway/- Hybrid mode supportspecialized/- AIGateway and other specialized controllers
manager/- Controller-runtime setup, controller registration (controller_setup.go)cli/- Command-line flag parsingadmission/- Validating/conversion webhooks
Documentation generated from the API definitions and CLI args.
Configuration files for deploying the operator (manifests, kustomize, etc).
/config/samples: Sample YAML manifests for deploying custom resources. These are tested in CI by applying against a real Kubernetes cluster.
Contains the embedded Kong Kubernetes Ingress Controller code.
Helm chart for deploying the operator.
- Use
DataPlanenotDataplane - Use
ControlPlanenotControlplane - For ControlPlane types, use
github.com/kong/kong-operator/internal/typespackage (aliased asgwtypes)
See .golangci.yaml for the full list of required import aliases.
See .golangci.yaml for the full list of blocked packages and their alternatives.
Uses mise for tool versions. Tool versions defined in .tools_versions.yaml and .mise.toml. Tools are automatically downloaded as dependencies for each Makefile target that needs them.
make tools # Install: controller-gen, kustomize, client-gen, golangci-lint, gotestsum, skaffold, yq, crd-ref-docs- Add to
PROJECTfile - Annotate with
+kubebuilder:markers for CRD generation - Run
make generateto regenerate CRDs, deepcopy, docs - Run
make test.charts.golden.updateif chart templates change - Add type specific CRD validation tests in
test/crdsvalidation/
-
Run linting -
make lintmust pass (CI runs with--fix=false) -
Run unit tests -
make test.unitfor quick feedback -
Run envtest -
make test.envtestfor controller logic validation -
Regenerate code if needed - If you modified API types, CRDs, or anything that requires code generation:
make generate # Regenerates all generated code make verify.generators # Verify generated code is up-to-date (CI runs this)
-
Update CHANGELOG.md - For significant changes, add release notes
make lint # Linting passes
make test.unit # Unit tests pass
make verify.generators # Generated code is up-to-dateWhen changing files in api/:
make generate # Regenerate CRDs, deepcopy, docs, manifests
make test.charts.golden.update # Update Helm chart golden files if CRDs changed
make verify.manifests # Verify manifests are consistentMain test workflow: .github/workflows/tests.yaml:
- Runs on PRs to all branches and pushes to main/release branches
- Jobs: lint, verify, unit-tests, envtest-tests, CRDs validation, conformance-tests, integration tests
- Uses mise for tool management
- Kubernetes versions tested: defined in
.github/supported_k8s_node_versions.yaml