Extracting Kubernetes Manifests from a Helm Chart

Preface

Helm is nice. It reduce complexity to end users, and abstracting away duplicate values in all of the needed resources to a nice values.yaml---an excellent example of the implementation of DRY.

Too bad for me, for my monkey brain, Helm felt like it abstracting things a little bit too much. Skill issue probably, but anyway.

ArgoCD actually work out of the box with Helm, but most of the time I usually convert it to a format that I more familiar with: Kustomize, which I feel offer more observability to the resources an application need.

Long story short, here’s how I usually do it.

Prerequisite

  • The Helm charts, obviously.

Procedure

Pull the Manifest

helm template <chart-name> > manifests.yaml

Extract the Manifests into its own files

Using this comment, each of the needed resources will be divided into their own file. It’s simple, but the file name is kind of unrepresentative.

mkdir extracted_manifests 
csplit --quiet --prefix=extracted_manifests/ manifests.yaml '/^---$/' '{*}'

You can also write some kind of scripts to do it better. For example, you can check the one I write with Python here. This script would output the files into ./output/ folder, which you can just rename into base to be used as part of Kustomization.