Skip to content

Instantly share code, notes, and snippets.

@figaw
Created September 25, 2019 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figaw/5f5c1c79cd11a95b985f144ec452ab51 to your computer and use it in GitHub Desktop.
Save figaw/5f5c1c79cd11a95b985f144ec452ab51 to your computer and use it in GitHub Desktop.
QoL script for templating a number of "values-*.yaml" files for Helm. #Kubernetes #k8s #Helm
#!/bin/bash
CHARTNAME=oauth2-proxy #used in flatten()
## USAGE
# 000. replace the CHARTNAME above
# 00. `cd` to the `chartname`-folder (the one containing the `Charts.yaml`-file)
# 0. Append the .gitignore
# --- .gitignore ---
# # script
# charter.sh
# # m-folders and values-
# m*
# values-*.yaml
# # if there is no .gitignore
# # helm/charts/stable sub-charts don't have one.
# .gitignore
# --- .gitignore ---
# 1. Create a number of `values-var.yaml`-files,
# with different configurations.
# 2. Add "-var" to the list below.
# 3. Run `./charter.sh` to create a number of `m-var`-directories,
# with the generated templates, for verification.
# charts to create
LIST=(
"" # the standard chart "values.yaml"
# -volumes # generate a template using the "values-volumes.yaml"-file
# -resources # etc..
)
### HELPERS
# /dir/CHARTNAME/templates/deployment.yaml -> /dir/deployment.yaml
flatten () {
DIR=$1
mv ./$DIR/*/templates/* ./$DIR
rm -r ./$DIR/$CHARTNAME
}
for n in "${LIST[@]}"; do
mkdir -p m${n} # make "m-var"-dir. m for manifest.
# template chart w/ "values-var.yaml" in "m-var"-dir.
helm template ./ --output-dir m${n} --values=values${n}.yaml
flatten m${n} # flatten directory.
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment