For Copilot, Cursor, Codex, Gemini Code Assist, or any agents generating code or reviewing pull requests in this repository.
- Never commit directly to this repository, always aim for a pull request
- Always ask for a final review from a human before committing
- Make sure that AI agent usage is attributed in the correct way
- When committing suggested changes, add a sign-off from the human author and add the
Assisted-bytag with the suggesting agent and its used model to the commit message - If a comment was not accepted and the Conversation was resolved do not make the same comment again
kpt is a package-centric toolchain that automates Kubernetes configuration editing and management. It enables declarative configuration authoring, automation, and delivery at scale through a "Configuration as Data" approach, supporting Kubernetes platforms and KRM-driven infrastructure (e.g., Config Connector, Crossplane).
- Language: Go (version is defined in the go.mod file)
- License: Apache 2.0
- Key Topics: Kubernetes, configuration management, CLI tooling, GitOps, policy-as-code, KRM (Kubernetes Resource Model)
Trust these instructions first. Only perform searches if you find this information incomplete or inaccurate.
- Go (version is specified in go.mod)
- Git (required and checked at runtime)
- Docker or Podman (for
test-dockerand function runtime tests) - KinD (CI uses the version defined in
.github/workflows/e2eEnvironment.yml)
make buildThis compiles kpt to $(go env GOPATH)/bin/kpt using LDFLAGS with git commit SHA.
make allRuns: fix vet fmt lint test build tidy in sequence. Always run this before committing.
make testRuns Go tests with coverage. Set KRM_FN_RUNTIME to select function runtime (docker/podman, default uses system default).
make test-dockerRequires Docker or Podman. Tests that need container runtime (e.g., pipeline tests). Respects KRM_FN_RUNTIME environment variable.
make test-fn-render T=".*"make test-fn-eval T=".*"Use T parameter to filter tests by regex (e.g., T=fnconfig for function config tests). Set KRM_FN_RUNTIME to select runtime.
make test-live-applyRequires KinD with Kubernetes versions defined in jobs.kind.strategy.matrix.version path of the
e2e test workflows (specific SHAs pinned in CI). These tests use Kind
internally. Timeout is 20 minutes.
make lintRuns golangci-lint v2.11.4. If already installed locally with matching version, uses it; otherwise downloads and runs via go run.
make fmt # Run gofmt
make fix # Run go fix
make vet # Run go vet
make tidy # Run go mod tidy
make generate # Generate code from templates (mdtogo, copyright headers)
make schema # Generate schemaMany tests require git configuration:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"- main.go: CLI entry point; contains //go:generate directives for CLI documentation
- Makefile: Primary build orchestration
- .golangci.yml: Linting configuration (used golangci-lint version is defined in the
GOLANGCI_LINT_VERSIONvariable of the Makefile) - go.mod / go.sum: Dependency management
- CONTRIBUTING.md: Contribution guidelines and code review requirements
- CODEOWNERS: Default reviewers
- commands/: CLI command implementations using Cobra framework
- run/: Main CLI setup; contains GetMain() that initializes Cobra commands with environment setup
- pkg/: Core library packages (business logic, utilities)
- internal/: Internal packages; includes internal/docs/generated/ (generated from Markdown via mdtogo)
- mdtogo/: Code generator tool that converts CLI documentation Markdown files to Go variables
- .github/workflows/go.yml: Main CI workflow
- Runs on Linux (docker/podman matrix) and macOS
- Executes:
make all+make test-docker - Triggered on PRs (except changes limited to ignored paths like
**.md) and pushes (pushes exclude dependabot branches)
- .github/workflows/e2eEnvironment.yml: KinD-based e2e tests
- Tests Kubernetes versions defined in
jobs.kind.strategy.matrix.versionwith KinD (KinD version injobs.kind.steps["Install KinD"].with.version) - Runs
./e2e/live/end-to-end-test.sh -k <K8S_VERSION>
- Tests Kubernetes versions defined in
- .github/workflows/live-e2e.yml: Live apply e2e tests
- Tests with pinned Kubernetes image SHAs
- Runs
make test-live-applywithK8S_VERSIONenvironment variable
- .github/workflows/release-api.yml: Release the kpt API module
- Builds, tests and lints the kpt API module
- Runs
make api
-
documentation/: Hugo-based website published to kpt.dev
- Run
make servefromdocumentation/(serves docs locally) - Requires
npm installfirst (run indocumentation/) - Documentation shold follow the style guide for documentation
- Run
-
e2e/: End-to-end test suites
- Contains testdata directories for function render/eval tests
- Live tests in
e2e/live/end-to-end-test.sh
- release/: Release automation (GoReleaser config, Homebrew formula generation)
- hack/: Miscellaneous development utilities
- healthcheck/: Separate module for health checking (Go (Go version is defined in healthcheck/go.mod), local Makefile)
- thirdparty/: Third-party code (excluded from linting)
- Formula/: Homebrew package definition (generated by
go run ./release/formula/main.go VERSION)
- Linter configuration is defined in the .golangci.yml file
- Copyright Headers: All files must have Apache 2.0 license header
- Use format: // Copyright YEAR The kpt Authors (or year range if modified)
- Year should match creation year, or creation-to-modification year range (see the instructions in Porch for more details)
- Developer Certificate of Origin (DCO): Commits must be signed with -s flag
- Large Features: Require reviewed and merged design document (use /docs/design-docs/00-template.md as template)
- AI Usage: Must declare AI usage in the PR description;
Assisted-by: AGENT_NAME:MODEL_VERSIONattribution in commit messages is recommended (see CONTRIBUTING.md).
Before submitting a PR, verify:
- ✅ All tests pass: make all
- ✅ All linting passes: make lint
- ✅ Code formatted: make fmt
- ✅ Dependencies tidied: make tidy
- ✅ Copyright headers added/updated per CONTRIBUTING.md
- ✅ DCO sign-off: use git commit -s
- ✅ For CLI/API changes: design document reviewed and merged
- ✅ AI usage declared in PR description (if applicable)
If make test-docker fails due to missing Docker/Podman:
- Install Docker Desktop or Podman
- For Podman: ensure it's on PATH and
podman versionruns successfully - Set
KRM_FN_RUNTIME=podmanif using Podman
For e2e live tests (make test-live-apply):
- KinD is auto-installed by CI workflow
- Requires Docker running in background
- Tests use specific Kubernetes image SHAs (see live-e2e.yml matrix)
- Timeout is 20 minutes; allow sufficient time
Tests fail silently if git user not configured. Always run:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"If changes modify CLI documentation in documentation/content/en/reference/cli/:
- Run
make generateto regenerateinternal/docs/generated/ - Commit generated files
- Windows build currently disabled (see
.github/workflows/go.yml, issue #3463) - Some linters disabled:
funlen,gosec(marked TODO in.golangci.yml)
- KRM_FN_RUNTIME: Select function runtime for tests:
docker,podmanornerdctl - K8S_VERSION: Kubernetes version for e2e live tests (used in CI with pinned SHAs)
- KPT_NO_PAGER_HELP: Set to 1 to disable pager for help output
- PAGER: Custom pager command (default: less -R)
- KPT_FN_WASM_RUNTIME: WASM function runtime selection
- GOPATH: Go workspace path (used in CI workflows)
- GOBIN: Go binary installation directory
- Cobra: CLI framework
- Kubernetes libraries (k8s.io/*): For Kubernetes resource handling
- sigs.k8s.io/cli-utils: CLI utilities
- sigs.k8s.io/kustomize/kyaml: YAML handling for Kubernetes
- sigs.k8s.io/controller-runtime: Controller and reconciliation patterns
- wasmtime-go: WebAssembly function runtime
- go-containerregistry: Container image handling
- Unit Tests: Run with
make test(standard Go tests) - Docker-based Tests: Run with
make test-docker(requires container runtime) - Function E2E Tests: Run with
make test-fn-render/make test-fn-eval(testdata-driven) - Live Apply E2E: Run with
make test-live-apply(KinD-based, 20-minute timeout) - Example Verification: Run with
make site-verify-examples(verifies CLI examples in docs)
- CLI Commands: Add to
commands/directory; use Cobra; updatedocumentation/content/en/reference/cli/for documentation - Library Code: Place in
pkg/for public APIs; useinternal/for internal utilities - Tests: Colocate
*_test.gofiles with source; use testdata directories for fixtures - Generated Code: Run
make generateafter modifying templates - Linting Issues: Address all
golangci-lintfindings; consult.golangci.ymlfor thresholds - Git Flow: Always create feature branches; use squash-merge preferred per repository settings
- Documentation: Update Markdown in documentation/; run
make serveto make sure that there are no errors
Trust these instructions. They have been validated against the Makefile, GitHub workflows, go.mod, and contributing guidelines. Only search for additional details if:
- Build or test commands fail with unexpected errors
- Instructions reference non-existent paths or commands
- New tool versions are released and compatibility is unclear