Navigation Menu

Skip to content

RothAndrew/convert-to-helm-raw-values

Repository files navigation

convert-to-helm-raw-values

What

convert-to-helm-raw-values converts a standard Kubernetes YAML document into one that can be used by the Helm chart incubator/raw

Why

Sometimes, particularly when dealing with Kubernetes Operators, the instructions say to just apply a kubernetes yaml file. Here's an example from the docs website for the Mattermost Operator:

kubectl create ns mattermost-operator
kubectl apply -n mattermost-operator -f https://raw.githubusercontent.com/mattermost/mattermost-operator/master/docs/mattermost-operator/mattermost-operator.yaml

This is fine, but what if your Kubernetes development and deployment workflow centers around deploying and managing Helm charts and/or Helmfiles? The wonderful little chart incubator/raw takes in arbitrary K8s yaml and applies it using the standard Helm format. However, the format for a values file for incubator/raw is different from that of standard Kubernetes YAML.

Kubernetes YAML:

a: Easy!
b:
  c: 2
  d: [3, 4]
---
a: Easy!
b:
  c: 2
  d: [3, 4]

Needs to be converted to a format that incubator/raw accepts:

resources:
  - a: Easy!
    b:
      c: 2
      d:
        - 3
        - 4
  - a: Easy!
    b:
      c: 2
      d:
        - 3
        - 4

How

Using the same Mattermost Operator example as above, you can now do this:

wget https://raw.githubusercontent.com/mattermost/mattermost-operator/master/docs/mattermost-operator/mattermost-operator.yaml
convert-to-helm-raw-values -i mattermost-operator.yaml -o mattermost-operator-values.yaml
helm install --name mattermost-operator incubator/raw -f mattermost-operator-values.yaml

Usage

$ convert-to-helm-raw-values --help
Converts K8s YAML to a version that helm incubator/raw can use

Usage:
  convert-to-helm-raw-values [flags]
  convert-to-helm-raw-values [command]

Available Commands:
  help        Help about any command
  version     Output tool version

Flags:
  -h, --help             help for convert-to-helm-raw-values
  -i, --infile string    Input file - Must be compliant with K8s YAML
  -o, --outfile string   Output file - Will be formatted such that it can be used as values.yaml for helm chart incubator/raw.
                         Will always overwrite if the file already exists.

Use "convert-to-helm-raw-values [command] --help" for more information about a command.

Contributor Guide

Releasing new versions

To release a new version, just push a new tag. Automation will cover the rest. Make sure the tag conforms to SemVer. goreleaser is used in the pipeline to create a GitHub Release.

About

Small utility that will convert K8s YAML files to a values.yaml file capable of being used with the incubator/raw helm chart

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages