Generate kpt packages from Helm charts

Any solution which emits configuration can also generate kpt packages (because they are just configuration).

Helm charts may be used to generate kpt packages which can then be further customized directly.


  1. Fetch a Helm chart
  2. Expand the Helm chart
  3. Publish the kpt package

Fetch a Helm chart

helm fetch stable/mysql

Pull down a helm chart for expansion. This may optionally be checked into git so it can be expanded again in the future.

Expand the Helm chart

helm template mysql-1.3.1.tgz --output-dir .

Expand the Helm chart into resource configuration. Template values may be provided on the commandline or through a value.yaml

wrote ./mysql/templates/secrets.yaml
wrote ./mysql/templates/tests/test-configmap.yaml
wrote ./mysql/templates/pvc.yaml
wrote ./mysql/templates/svc.yaml
wrote ./mysql/templates/tests/test.yaml
wrote ./mysql/templates/deployment.yaml
tree mysql/
└── templates
├── deployment.yaml
├── pvc.yaml
├── secrets.yaml
├── svc.yaml
└── tests
├── test-configmap.yaml
└── test.yaml

Publish the kpt package

The expanded chart will function as a kpt package once checked into a git repository. It may optionally be tagged with a package version.

git add .
git commit -m “add mysql package”
git tag package-examples/mysql/mysql/templates/v0.1.0
git push package-examples/mysql/mysql/templates/v0.1.0

Once stored in git, kpt can be used to fetch the package and customize it directly.

export REPO=https://github.com/GoogleContainerTools/kpt.git
kpt pkg get $REPO/package-examples/mysql/mysql/templates@v0.16.0 mysql/

The package local package can be modified after it is fetched, and pull in upstream changes when the upstream package is regenerated from the chart or otherwise modified.

Last modified July 16, 2020: Fix all markdownlint issues (e20b22cd)