Creates Helm chart from Kubernetes yaml

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.

Comments
  • Neither Labels nor Annotations are currently supported for CRDs

    Neither Labels nor Annotations are currently supported for CRDs

    until the follow are reviewed and merged can we remove the labels and annotations from the CRD template?

    https://github.com/kubernetes-sigs/controller-tools/pull/691 https://github.com/kubernetes-sigs/controller-tools/issues/454

    It doesnt make sense to include something which will be rejected at a later point by native tooling. Maybe better to use kustomize and point to how that could work if needed as an option

  • minimal implementation for imagePullSecrets

    minimal implementation for imagePullSecrets

    This is the very minimal implementation. Some notes:

    • I can't use a default value for the imagePullSecrets in values.yaml, as this should only be specified by the user if necessary. To let the user know about the feature, I render a comment in values.yaml with an example how to use it.
    • I use toJson in the helm expression to get started somewhere
    • There could be some refactoring done generally to handle PodSpec uniformly in one place. Currently there is quite a few duplicate code in daemonset.go and deployment.go. For this PR I just kept it like it is, and implemented in handling in an own package
    • I tested the generate e2e app chart, and it looked good at the first glace.

    Please let me know what you think about it.

  • Error unclosed action

    Error unclosed action

    Hi, I'm very impressed with helmify, saving me a lot of work, thank you!

    One problem... PS C:\dev\Helm\Helmify\One> helm install firstheml mychart Error: parse error at (mychart/templates/mongodb-configmap.yaml:8): unclosed action

    that file looks like this apiVersion: v1 kind: Secret metadata: name: {{ include "mychart.fullname" . }}-mongodb-secret labels: {{- include "mychart.labels" . | nindent 4 }} data: mongo-root-password: {{ required "mongodbSecret.mongoRootPassword is required" .Values.mongodbSecret.mongoRootPassword | b64enc | quote }} mongo-root-username: {{ required "mongodbSecret.mongoRootUsername is required" .Values.mongodbSecret.mongoRootUsername | b64enc | quote }}

    the .Values file contains mongodbSecret: mongoRootPassword: "" mongoRootUsername: ""

    All help much appreciated

    Doug

  • [Feature Request] Add support for secrets

    [Feature Request] Add support for secrets

    In kustomization.yaml it is possible to generate secrets using secretGenerator:

    secretGenerator:
    - files:
      - ca.crt
      name: ca
      type: opaque
    - envs:
      - envfile.env
      name: my-secret
      type: opaque
    

    I would like the helmify tool to generate the secrets in the Helm Chart output.

  • Names that are too long generate invalid multi-line strings

    Names that are too long generate invalid multi-line strings

    The following snippet of YAML results in an invalid credentials.yaml file:

    apiVersion: v1
    kind: Secret
    metadata:
      name: spellbook-credentials
    type: Opaque
    data:
      MQTT_HOST: "Zm9vYmFy"
      MQTT_PORT: "Zm9vYmFy"
      ELASTIC_HOST: "Zm9vYmFy"
      ELASTIC_PORT: "Zm9vYmFy"
      ELASTIC_PROTOCOL: "Zm9vYmFy"
      ELASTIC_PASSWORD: "Zm9vYmFy"
      ELASTIC_FOOBAR_HUNTER123_MEOWTOWN_VERIFY: "Zm9vYmFy"
    

    The resulting output:

    apiVersion: v1
    kind: Secret
    metadata:
      name: {{ include "spellbook.fullname" . }}-credentials
      labels:
      {{- include "spellbook.labels" . | nindent 4 }}
    data:
      ELASTIC_FOOBAR_HUNTER123_MEOWTOWN_VERIFY: {{ required "credentials.elasticFoobarHunter123MeowtownVerify
        is required" .Values.credentials.elasticFoobarHunter123MeowtownVerify | b64enc
        | quote }}
      ELASTIC_HOST: {{ required "credentials.elasticHost is required" .Values.credentials.elasticHost
        | b64enc | quote }}
      ELASTIC_PASSWORD: {{ required "credentials.elasticPassword is required" .Values.credentials.elasticPassword
        | b64enc | quote }}
      ELASTIC_PORT: {{ required "credentials.elasticPort is required" .Values.credentials.elasticPort
        | b64enc | quote }}
      ELASTIC_PROTOCOL: {{ required "credentials.elasticProtocol is required" .Values.credentials.elasticProtocol
        | b64enc | quote }}
      MQTT_HOST: {{ required "credentials.mqttHost is required" .Values.credentials.mqttHost
        | b64enc | quote }}
      MQTT_PORT: {{ required "credentials.mqttPort is required" .Values.credentials.mqttPort
        | b64enc | quote }}
    

    Running helm install will error out because of the invalid YAML generated for key names past a certain length:

    $ helm install -f ./contrib/k8s/examples/spellbook/values.yaml webrtc-dev-telemetry ./contrib/k8s/charts/spellbook
    Error: INSTALLATION FAILED: parse error at (spellbook/templates/credentials.yaml:8): unterminated quoted string
    

    Thanks for your work on this, by the way.

  • Allow to specify existing imagePullSecret for podSpec

    Allow to specify existing imagePullSecret for podSpec

    It is considered a best practise to include an imagePullSecrets field in values.yaml so that the consumer of a helm chart can use a private registry, for which a Secret has already been created.

    It would be nice if helmify checks if there is anything assigned to the ImagePullSecrets field of a PodSpec (which may be part of a Deployment, DaemonSet, ...). If this is set, helmify should continue as-is.

    But if the ImagePullSecret is not set, helmify should include a imagePullSecrets in values.yaml and include it in the PodSpec, if it has been set by the user.

    What do you think?

  • Doesn't convert arrays properly to the values file, using hardcoded values

    Doesn't convert arrays properly to the values file, using hardcoded values

    If you got something like this in the kustomize file:

    authorizedUsers: ["user1", "user2"]

    Or like this:

    authorizedUsers:
      - user1
      - user2
    

    Then is parsed as the same value directly on the template, like a hardcoded value, instead of creating this array on the values.yaml and using it on the template as every other variable does.

    Expected in the template example:

    authorizedUsers: {{ toYaml .Values.authorizedUsers | nindent 8 }}

  • put any CRD in its own directory

    put any CRD in its own directory

    thanks for making/maintaining this tool, fills a much needed gap in Operator-SDK, appreciated.

    per the latest helm3 docs it would be nice if there was the option to place crds in their own directory so that users can take advantage of any further changes to how CRDs are handled during the install process. I can also see how this would be cleaner and makes using other validation tooling simpler to use by convention.

    I haven't written much go but could have a look if its more than 5 minutes for anyone else.

  • fix: inject-ca-from is not correctly generated

    fix: inject-ca-from is not correctly generated

    Hi there,

    Thanks for creating this fantastic project! This will definitely enable more usage when users want to use both kustomize and helm charts but also want to maintain single version of truth.

    When I tried to use helmify with kubebuilder for my admission controller, I noticed that inject-ca-from field is not correctly converted into helm charts.

    Expected:

        cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "chart.fullname" . }}-serving-cert
    

    Actual:

        cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "chart.fullname" . }}-admission-controller-system/admission-controller-serving-cert
    

    Looks like its namespace and prefix is not correctly trimmed. Somehow appMeta.ChartName() is always chart, so it fails to remove those prefix.

    This PR fixes the issue by using appMeta.TrimName() to trim, like other processors.

    Let me know if you have any question or comment.

    Thanks a lot! Sam

  • initialising/updating crds do not inherit chart labels when running helmify against the kustomize build example

    initialising/updating crds do not inherit chart labels when running helmify against the kustomize build example

    Helmify version: 0.3.15 example chart: https://github.com/fire-ant/consulkv-operator

    instructions: clone the example chart and run 'make helm'. the output returns a diff where the labels will not render.

    expected result: the go template instruction remains unchanged and is inserted into the labels field of the crd.yaml.

    actual result: helmify should render the labels for the crd in 'crds/'

    Due to how crds are templated it appears that the labels line of the crd needs to be affixed to include from the _helpers inside the templates directory, alternatively it may be better to handle this templating inside the logic of helmify itself (Im a little unsure of which is better and why)

  • why helmify doesn't  support Daemonset and Statefulset?

    why helmify doesn't support Daemonset and Statefulset?

    Hello, arttor, I think daemonset and statefulset are frequently-used resource,and why helmify doesn't support Daemonset and Statefulset? The support for statefulset and daemonset are on plan?

  • Helmify Repo Contribution

    Helmify Repo Contribution

    Hi,

    I'm a developer in AWS working on k8s ML platform/toolings. I recently came across your helmify tool that seems to solve the same problem we had a while ago.

    At first we were deploying our program with kustomize but in our recent release we are supporting both helm and terraform. You can check out our repo: https://github.com/awslabs/kubeflow-manifests

    I wonder if we can contribute back to the repo instead of solving the same thing.

    It will be helpful if you can:

    • Give a brief introduction about yourself
    • Who is maintaining the repo? I see there are 13 contributors so far and it seems to be pretty well maintained (last commit was 7 hours ago), but it seems like you do the majority of the commits.
    • I see that it's under MIT license, are there other licensing issues you want us to be aware of?
  • Allow more configuration to be customised

    Allow more configuration to be customised

    The generated helm chart should allow changing things like:

    • annotations
    • nodeSelector
    • affinity rules
    • etc

    It would be great if we could support a config file where the user can specify schema/attribute name and field-ref/s and helmify will automatically templatize it.

    Example:

    vars:
    - name: annotations
      optional: true
      objref:
        kind: Deployment
        group: apps
        version: v1
        name: xyz
      fieldrefs:
        - fieldpath: spec.template.metadata.annotation
    

    PS: If this the community and maintainers are interested in I am happy to contribute

  • Add a flag to disable/enable the webhook while rendering Operator

    Add a flag to disable/enable the webhook while rendering Operator

    Hi, there, could we provide a flag to add a judgment in webhooks and relevant resources(service, volume, etc) while rendering Operator built by kubebuilder?

  • More flags to control what is generated

    More flags to control what is generated

    For our use case, we really want to leverage helmify to keep CRDs and RBAC up to date with changes in the chart kept in the same repository that houses a large set of controllers.

    However, we want to maintain the chart (e.g. deployment, values, and so on) ourselves. We would really benefit from individual flags within helmify to control what it generates and what it doesn't (e.g. only do CRDs and RBAC).

  • Wrong templating in certificate if chart name is the same as namespace name

    Wrong templating in certificate if chart name is the same as namespace name

    The generated Certificate looks like this:

    apiVersion: cert-manager.io/v1
    kind: Certificate
    metadata:
      name: {{ include "busola-operator.fullname" . }}-serving-cert
      labels:
      {{- include "busola-operator.labels" . | nindent 4 }}
    spec:
      dnsNames:
      - '{{ include "{{ .Release.Namespace }}.fullname" . }}-$(SERVICE_NAME).$(SERVICE_NAMESPACE).svc'
      - '{{ include "{{ .Release.Namespace }}.fullname" . }}-$(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local'
      issuerRef:
        kind: Issuer
        name: '{{ include "busola-operator.fullname" . }}-selfsigned-issuer'
      secretName: webhook-server-cert
    

    Under spec.dnsNames the template is {{ include "{{ .Release.Namespace }}.fullname" . }} although it should be {{ include "busola-operator.fullname" . }}

    I am using helmify version 0.3.7

    It works fine when the chart name is different to the namespace name, this only happens when both are the same

Helm Operator is designed to managed the full lifecycle of Helm charts with Kubernetes CRD resource.

Helm Operator Helm Operator is designed to install and manage Helm charts with Kubernetes CRD resource. Helm Operator does not create the Helm release

Aug 25, 2022
Katenary - Convert docker-compose to a configurable helm chart
Katenary - Convert docker-compose to a configurable helm chart

Katenary is a tool to help transforming docker-compose files to a working Helm C

Dec 23, 2022
helm-lint-ls is helm lint language server protocol LSP.

helm-lint-ls is helm lint language server protocol LSP.

Dec 27, 2022
Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider.

dredger Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider. Dredger is made of dark magic and cannot full

Aug 25, 2022
The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism
The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism

___ werf is an Open Source CLI tool written in Go, designed to simplify and speed up the delivery of applications. To use it, you need to describe the

Jan 4, 2023
Helm : a tool for managing Kubernetes charts

Helm Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources. Use Helm to: Find and use popular soft

Nov 30, 2021
Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates
Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates

Keel - automated Kubernetes deployments for the rest of us Website https://keel.sh Slack - kubernetes.slack.com look for channel #keel Keel is a tool

Dec 28, 2022
YurtCluster Operator creates and manages OpenYurt cluster atop Kubernetes

YurtCluster Operator Quick Start Prepare a Kubernetes cluster # cat <<EOF | kind create cluster --config=- kind: Cluster apiVersion: kind.x-k8s.io/v1a

Aug 3, 2022
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.
PolarDB Stack is a DBaaS implementation for PolarDB-for-Postgres, as an operator creates and manages PolarDB/PostgreSQL clusters running in Kubernetes. It provides re-construct, failover swtich-over, scale up/out, high-available capabilities for each clusters.

PolarDB Stack开源版生命周期 1 系统概述 PolarDB是阿里云自研的云原生关系型数据库,采用了基于Shared-Storage的存储计算分离架构。数据库由传统的Share-Nothing,转变成了Shared-Storage架构。由原来的N份计算+N份存储,转变成了N份计算+1份存储

Nov 8, 2022
Create changelogs for Helm Charts, based on git history

helm-changelog Create changelogs for Helm Charts, based on git history. The application depends on the assumption that the helm chart is released on t

Nov 27, 2022
A helm v3 plugin to get values from a previous release

helm-val helm-val is a helm plugin to fetch values from a previous release. Getting started Installation To install the plugin: $ helm plugin install

Dec 11, 2022
Render helm values-files from others

helm-plugin-render-values The Helm downloader plugin with rendering templated values files Install Use helm CLI to install this plugin: $ helm plugin

Aug 1, 2022
sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC), and Everything as Code. So it is a tool for DevOps.

sail 中文文档 sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC),a

Dec 16, 2021
Plugin for Helm to integrate the sigstore ecosystem

helm-sigstore Plugin for Helm to integrate the sigstore ecosystem. Search, upload and verify signed Helm Charts in the Rekor Transparency Log. Info he

Dec 21, 2022
A best practices Go source project with unit-test and integration test, also use skaffold & helm to automate CI & CD at local to optimize development cycle

Dependencies Docker Go 1.17 MySQL 8.0.25 Bootstrap Run chmod +x start.sh if start.sh script does not have privileged to run Run ./start.sh --bootstrap

Apr 4, 2022
A Terraform module that creates AWS alerts billing for your resources.

terraform-aws-billing-alarms terraform-aws-billing-alarms for project Replace name project to New Project agr 'terraform-aws-billing-alarms' 'new-pr

Oct 20, 2021
How you can use Go to replace YAML files with Kubernetes.

YamYams A small project that is free to use. ?? I wanted to offer a starting point for anyone interested in replacing YAML with Go. You can read more

Jan 6, 2023
Not another markup language. Framework for replacing Kubernetes YAML with Go.

Not another markup language. Replace Kubernetes YAML with raw Go! Say so long ?? to YAML and start using the Go ?? programming language to represent a

Jan 3, 2023
kubectl plugin for signing Kubernetes manifest YAML files with sigstore
kubectl plugin for signing Kubernetes manifest YAML files with sigstore

k8s-manifest-sigstore kubectl plugin for signing Kubernetes manifest YAML files with sigstore ⚠️ Still under developement, not ready for production us

Nov 28, 2022