Coder Social home page Coder Social logo

helmify's Introduction

Helmify

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

CLI that creates Helm charts from kubernetes yamls.

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.

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

Usage

  1. From file: cat my-app.yaml | helmify mychart

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

  2. From directory with yamls:

    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.

  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

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/[email protected])
    
    helm: manifests kustomize helmify
        $(KUSTOMIZE) build config/default | $(HELMIFY)
  3. 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'.

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
-version Print helmify version. helmify -version

Status

Supported default operator resources:

  • deployment
  • service
  • RBAC (serviceaccount, (cluster-)role, (cluster-)rolebinding)
  • configs (configmap, secret)
  • webhooks (cert, issuer, ValidatingWebhookConfiguration)

Known issues

  • Helmify will not overwrite Chart.yaml file if presented. Done on purpose.
  • Helmify will not delete existing template files, only overwrite.
  • 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.

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.

helmify's People

Contributors

arttor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.