Installation #

Users can get kpt CLI in a variety of ways:

Binaries #

Download pre-compiled binaries:

Optionally verify the SLSA3 signatures generated using the OpenSSF’s slsa-framework/slsa-github-generator during the release process. To verify a release binary:

  1. Install the verification tool from slsa-framework/slsa-verifier#installation.
  2. Download the signature file multiple.intoto.jsonl from the GitHub releases page.
  3. Run the verifier:
slsa-verifier verify-artifact --provenance-path multiple.intoto.jsonl --source-uri github.com/kptdev/kpt --source-versioned-tag <the-tag> kpt_<os>_<arch>

On Linux and MacOS, make it executable:

chmod +x kpt

On MacOS the first time, it may be necessary to open the program from the finder with ctrl-click open.

Verify the version:

kpt version

(Optional) enable shell auto-completion #

kpt provides auto-completion support for several of the common shells. To see the options for enabling shell auto-completion:

kpt completion -h

Prerequisites #

Previous installations of kpt completion may have added the following line to the shell’s config file (e.g. .bashrc, .zshrc, etc.):

complete -C <KPT_PATH> kpt

This line needs to be removed for kpt’s completion implementation to function properly.

Enable kpt auto-completion #

The kpt completion script for a shell can be generated with the commands kpt completion bash, kpt completion zsh, etc. For instructions on how to enable the script for the given shell, see the help page with the commands kpt completion bash -h, kpt completion zsh -h, etc.

Homebrew #

Install the latest release with Homebrew on MacOS.

brew tap kptdev/kpt https://github.com/kptdev/kpt.git
brew install kpt
kpt version

The version of kpt installed using brew can only be a tagged release, master releases are not shipped.

Docker #

Use one of the kpt docker images.

Running kpt via Docker does not install kpt on your machine. Each docker run ... invocation starts a temporary container, runs the command inside that container, prints output, and then exits.

Featurekptkpt-gcloud
kpt
git
diffutils
gcloud

kpt #

docker run ghcr.io/kptdev/kpt:v1.0.0-beta.59 version

To use kpt with files on your host, mount your current directory into the container and set a working directory:

docker run --rm -v "$PWD":/workdir -w /workdir ghcr.io/kptdev/kpt:v1.0.0-beta.59 pkg tree
docker run --rm -v "$PWD":/workdir -w /workdir ghcr.io/kptdev/kpt:v1.0.0-beta.59 fn render

On Windows PowerShell, use ${PWD}.Path for the current directory:

docker run --rm -v "${PWD}.Path:/workdir" -w /workdir ghcr.io/kptdev/kpt:v1.0.0-beta.59 pkg tree

This pattern ensures kpt reads and writes files under /workdir, which maps to your current directory on the host.

kpt-gcloud #

An image which includes kpt based upon the Google cloud-sdk alpine image.

docker run ghcr.io/kptdev/kpt-gcloud:v1.0.0-beta.59 version

Optionally, you can define a shell alias so Docker-based usage feels like a local CLI:

alias kpt='docker run --rm -v "$PWD":/workdir -w /workdir ghcr.io/kptdev/kpt:v1.0.0-beta.59'

On Windows PowerShell, you can define a function with a similar effect:

function kpt { docker run --rm -v "${PWD}.Path:/workdir" -w /workdir ghcr.io/kptdev/kpt:v1.0.0-beta.59 $args }

After setting the alias, kpt version runs kpt in a container, and file changes persist in your current directory.

Source #

Install by compiling the source. This requires having Go version 1.21+:

go install -v github.com/kptdev/kpt@main

Post-installation notes and troubleshooting #

When installing with go install, the kpt binary is written to $(go env GOPATH)/bin by default. If GOBIN is set, Go installs binaries to that directory instead.

If that directory is not on your PATH, kpt version may return “command not found” even though the binary was installed successfully.

Verify where Go installed the binary, and confirm whether it is on your PATH:

go env GOPATH
ls "$(go env GOPATH)/bin"
echo "$PATH" | tr ':' '\n' | grep "$(go env GOPATH)/bin"

On Windows PowerShell:

go env GOPATH
Get-ChildItem "$(go env GOPATH)\bin" | Select-Object Name
$Env:Path -split ';' | Select-String -SimpleMatch "$(go env GOPATH)\bin"

If needed, add $(go env GOPATH)/bin to your PATH (adjust the shell profile file for your environment):

export PATH="$PATH:$(go env GOPATH)/bin"

On Windows PowerShell, you can update your user-level PATH for future sessions:

$gopath = (go env GOPATH)
[Environment]::SetEnvironmentVariable('Path', $Env:Path + ';' + "$gopath\bin", 'User')

Also note that go install may produce little or no output, and may complete very quickly, if Go reuses cached build artifacts.

If you suspect a stale module cache is affecting the build (for example, unexpected build results or missing updates), go clean -modcache can be a useful diagnostic step. This clears the module download cache and forces Go to re-fetch modules on the next build; it is not required for routine installs.

kpt version will return unknown for binaries built from source:

kpt version