This is the documentation for version 0.39. For documentation on the latest version of kpt, please see kpt.dev.

Init

Initialize and publish a new package

A kpt package is published as a git subdirectory containing configuration files (YAML). Publishers of kpt packages can create or generate YAML files however they like using the tool of their choice.

Publishing a package is done by pushing the git directory (and optionally tagging it with a version).

Multiple packages may exist in a single repo under separate subdirectories.

Packages may be nested – both parent (composite) and child (component) directories may be fetched as a kpt package.

A package is versioned by tagging the git repo as one of:

  • package-subdirectory/package-version (directory scoped versioning)
  • package-version (repo scoped versioning)

So package example that exists in the example folder of the repo, can be individually versioned (as version v1.0.2) by creating the tag example/v1.0.2.

Steps

  1. Create a git repo
  2. Create the package contents
  3. Create configuration
  4. Publish package to git
  5. Fetch the released package

Create a git repo

REPO_NAME=my-repo
REPO_URL="<url>"
mkdir $REPO_NAME # or clone with git `git clone`
git init $REPO_NAME # only if new repo

Create the package

mkdir $REPO_NAME/nginx

Recommended: initialize the package with metadata

kpt pkg init $REPO_NAME/nginx --tag kpt.dev/app=nginx --description "kpt nginx package"

Create configuration

curl https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/controllers/nginx-deployment.yaml --output $REPO_NAME/nginx/nginx-deployment.yaml

Publish package to git

(cd $REPO_NAME && git add . && git commit -m "Add nginx package")

Recommended: tag the commit as a release

# tag as DIR/VERSION for per-directory versioning
(cd $REPO_NAME && git tag nginx/v0.1.0)
# git push nginx/v0.1.0 # requires an upstream repo

Fetch the released package

kpt pkg get $REPO_URL/nginx@v0.1.0 nginx