Home

Awesome

Helmify

CI GitHub go.mod Go version GitHub GitHub release (latest by date) Go Report Card GoDoc GitHub total downloads

CLI that creates Helm charts from kubernetes manifests.

Helmify reads a list of supported k8s objects from stdin and converts it to a helm chart. Designed to generate charts for k8s operators but not limited to. See examples of charts generated by helmify.

Supports Helm >=v3.6.0

Submit issue if some features missing for your use-case.

Usage

  1. As pipe:

    cat my-app.yaml | helmify mychart
    

    Will create 'mychart' directory with Helm chart from yaml file with k8s objects.

    awk 'FNR==1 && NR!=1  {print "---"}{print}' /<my_directory>/*.yaml | helmify mychart
    

    Will create 'mychart' directory with Helm chart from all yaml files in <my_directory> directory.

  2. From filesystem:

    helmify -f /my_directory/my-app.yaml mychart
    

    Will create 'mychart' directory with Helm chart from my_directory/my-app.yaml.

    helmify -f /my_directory mychart
    

    Will create 'mychart' directory with Helm chart from all yaml files in <my_directory> directory.

    helmify -f /my_directory -r mychart
    

    Will create 'mychart' directory with Helm chart from all yaml files in <my_directory> directory recursively.

    helmify -f ./first_dir -f ./second_dir/my_deployment.yaml -f ./third_dir  mychart
    

    Will create 'mychart' directory with Helm chart from multiple directories and files.

  3. From kustomize output:

    kustomize build <kustomize_dir> | helmify mychart
    

    Will create 'mychart' directory with Helm chart from kustomize output.

Integrate to your Operator-SDK/Kubebuilder project

  1. Open Makefile in your operator project generated by Operator-SDK or Kubebuilder.
  2. Add these lines to Makefile:
  1. Run make helm in project root. It will generate helm chart with name 'chart' in 'chart' directory.

Install

With Homebrew (for MacOS or Linux): brew install arttor/tap/helmify

Or download suitable for your system binary from the Releases page. Unpack the helmify binary and add it to your PATH and you are good to go!

Available options

Helmify takes a chart name for an argument. Usage:

helmify [flags] CHART_NAME - CHART_NAME is optional. Default is 'chart'. Can be a directory, e.g. 'deploy/charts/mychart'.

flagdescriptionsample
-h -helpPrints helphelmify -h
-fFile source for k8s manifests (directory or file), multiple sources supportedhelmify -f ./test_data
-rScan file directory recursively. Used only if -f providedhelmify -f ./test_data -r
-vEnable verbose output. Prints WARN and INFO.helmify -v
-vvEnable very verbose output. Also prints DEBUG.helmify -vv
-versionPrint helmify version.helmify -version
-crd-dirPlace crds in their own folder per Helm 3 docs. Caveat: CRDs templating is not supported by Helm.helmify -crd-dir
-image-pull-secretsAllows the user to use existing secrets as imagePullSecretshelmify -image-pull-secrets
-original-nameUse the object's original name instead of adding the chart's release name as the common prefix.helmify -original-name
-cert-manager-as-subchartAllows the user to install cert-manager as a subcharthelmify -cert-manager-as-subchart
-cert-manager-versionAllows the user to specify cert-manager subchart version. Only useful with cert-manager-as-subchart. (default "v1.12.2")helmify -cert-manager-version=v1.12.2
-cert-manager-install-crdAllows the user to install cert-manager CRD as part of the cert-manager subchart.(default "true")helmify -cert-manager-install-crd
-preserve-nsAllows users to use the object's original namespace instead of adding all the resources to a common namespace. (default "false")helmify -preserve-ns
-add-webhook-optionAdds an option to enable/disable webhook installationhelmify -add-webhook-option

Status

Supported k8s resources:

Known issues

Develop

To support a new type of k8s object template:

  1. Implement helmify.Processor interface. Place implementation in pkg/processor. The package contains examples for most k8s objects.
  2. Register your processor in the pkg/app/app.go
  3. Add relevant input sample to test_data/kustomize.output.

Run

Clone repo and execute command:

cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify mychart

Will generate mychart Helm chart form file test_data/k8s-operator-kustomize.output representing typical operator kustomize output.

Test

For manual testing, run program with debug output:

cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify -vv mychart

Then inspect logs and generated chart in ./mychart directory.

To execute tests, run:

go test ./...

Beside unit-tests, project contains e2e test pkg/app/app_e2e_test.go. It's a go test, which uses test_data/* to generate a chart in temporary directory. Then runs helm lint --strict to check if generated chart is valid.

Contribute

Following rules will help changes to be accepted faster:

Contribution flow

Check list before submitting PR:

  1. Run go fmt ./...
  2. Run tests go test ./...
  3. Update chart examples:
    cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
    
    cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
    
  4. In case of long commit history (more than 3) squash local commits into one