Helm: render manifest locally
  1. 1.
    Install yq (brew install yq)
  2. 2.
    Download chart to local
  3. 3.
    Get values from release yaml
  4. 4.
    Using helm template to render manifest
1
function download {
2
CHART_REPO=$(yq r ${1} spec.chart.repository)
3
CHART_NAME=$(yq r ${1} spec.chart.name)
4
CHART_VERSION=$(yq r ${1} spec.chart.version)
5
CHART_DIR=${2}/${CHART_NAME}
6
helm repo add ${CHART_NAME} ${CHART_REPO}
7
helm fetch --version ${CHART_VERSION} --untar ${CHART_NAME}/${CHART_NAME} --untardir ${2}
8
echo ${CHART_DIR}
9
}
10
11
HELM_RELEASE=my-release
12
TMPDIR=/tmp/${HELM_RELEASE}
13
14
# Download chart to local
15
CHART_DIR=$(download ${HELM_RELEASE} ${TMPDIR}| tail -n1)
16
17
# Custom values
18
yq r ./releases/$HELM_RELEASE.yaml spec.values > my-custom.values.yaml
19
20
HELM_RELEASE_NAME=$(yq r ${HELM_RELEASE} metadata.name)
21
HELM_RELEASE_NAMESPACE=$(yq r ${HELM_RELEASE} metadata.namespace)
22
23
# Render
24
helm template ${HELM_RELEASE_NAME} ${CHART_DIR} --namespace $HELM_RELEASE_NAMESPACE --skip-crds true -f my-custom.values.yaml
Copied!
Copy link
Edit on GitHub