helmify

module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2021 License: MIT

README

Helmify

CI GitHub go.mod Go version GitHub GitHub release (latest by date) Go Report Card GoDoc Maintainability Test Coverage Works

Helmify reads kubernetes resources from std.in and produces a Helm chart.

Main use-case is to create Helm charts for kubernetes operators build with Operator-SDK or Kubebuilder.

Run

Clone repo and execute command:

cat test_data/kustomize.output | go run cmd/helmify/main.go mychart

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

Integrate to your Operator-SDK/Kubebuilder project

Tested with operator-sdk version: "v1.8.0".

  1. Open Makefile in your operator project generated by Operator-SDK or Kubebuilder.
  2. Add these lines to Makefile:
HELMIFY = $(shell pwd)/bin/helmify
helmify:
	$(call go-get-tool,$(HELMIFY),github.com/arttor/helmify/cmd/helmify@v0.2.2)

helm: manifests kustomize helmify
	$(KUSTOMIZE) build config/default | $(HELMIFY)
  1. Run make helm in project root. It will generate helm chart with name 'chart' in 'chart' directory.

Available options

Helmify takes a chart name for an argument. Usage:

helmify [flags] CHART_NAME - CHART_NAME is optional. Default is 'chart'.

flag description sample
-h -help Prints help helmify -h
-v Enable verbose output. Prints WARN and INFO. helmify -v
-vv Enable very verbose output. Also prints DEBUG. helmify -vv

Status

Supported default operator resources:

  • deployment
  • service
  • RBAC (serviceaccount, (cluster-)role, (cluster-)rolebinding)
  • configs (configmap, secret)
  • webhooks (cert, issuer, ValidatingWebhookConfiguration)
Known issues
  • Helmify defines application (operator) name as the shortest common prefix of k8s objects names. It is possible because operator-sdk using operator name as prefix by default.
  • Helmify will not overwrite Chart.yaml file if presented. Done on purpose.
  • Helmify will not delete existing template file, only overwrite. So, if you delete CRD, re-run kustomize | helmify crd file will still be in templates directory. (todo: add option for this)
  • Helmify overwrites templates and values files on every run. This meas that all your manual changes in helm template files will be lost on the next run. Use kustomize /config folder as a single source of true and make changes there.

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.
Test

For manual testing, run program with debug output:

cat test_data/kustomize.output | go run cmd/helmify/main.go -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/kustomize.output to generate a chart in temporary directory. Then runs helm lint --strict to check if generated chart is valid.

Directories

Path Synopsis
cmd
pkg
app
helm
Package helm contains code for writing templates to a filesystem as Helm chart.
Package helm contains code for writing templates to a filesystem as Helm chart.
processor
Package processor contains processors converting k8s objects to Helm template
Package processor contains processors converting k8s objects to Helm template

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL