5 Install (or upgrade) an umbrella Helm Chart, and its subcharts, as separate Helm Releases
7 The umbrella Helm Chart is broken apart into a parent release and subchart releases.
8 Subcharts the are disabled (<chart>.enabled=false) will not be installed or upgraded.
9 All releases are grouped and deployed within the same namespace.
12 The deploy arguments must be a release and chart. The chart
13 argument can be either: a chart reference('stable/onap'), a path to a chart directory,
14 a packaged chart, or a fully qualified URL. For chart references, the latest
15 version will be specified unless the '--version' flag is set.
17 To override values in a chart, use either the '--values' flag and pass in a file
18 or use the '--set' flag and pass configuration from the command line, to force string
19 values, use '--set-string'.
21 You can specify the '--values'/'-f' flag multiple times. The priority will be given to the
22 last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
23 contained a key called 'Test', the value set in override.yaml would take precedence:
25 $ helm deploy demo ./onap --namespace onap -f openstack.yaml -f overrides.yaml
27 You can specify the '--set' flag multiple times. The priority will be given to the
28 last (right-most) set specified. For example, if both 'bar' and 'newbar' values are
29 set for a key called 'foo', the 'newbar' value would take precedence:
31 $ helm deploy demo local/onap --namespace onap -f overrides.yaml --set log.enabled=false --set vid.enabled=false
34 helm deploy [RELEASE] [CHART] [flags]
37 --namespace string namespace to install the release into. Defaults to the current kube config namespace.
38 --set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
39 --set-string stringArray set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
40 -f, --values valueFiles specify values in a YAML file or a URL(can specify multiple) (default [])
41 --verbose enables full helm install/upgrade output during deploy
45 generate_overrides() {
46 SUBCHART_NAMES=($(cat $COMPUTED_OVERRIDES | grep -v '^\s\s'))
48 for index in "${!SUBCHART_NAMES[@]}"; do
49 START=${SUBCHART_NAMES[index]}
50 END=${SUBCHART_NAMES[index+1]}
51 if [[ $START == "global:" ]]; then
52 echo "global:" > $GLOBAL_OVERRIDES
53 cat $COMPUTED_OVERRIDES | sed '/common:/,/consul:/d' \
54 | sed -n '/'"$START"'/,/'log:'/p' | sed '1d;$d' >> $GLOBAL_OVERRIDES
56 SUBCHART_DIR="$CACHE_SUBCHART_DIR/$(cut -d':' -f1 <<<"$START")"
57 if [[ -d "$SUBCHART_DIR" ]]; then
58 cat $COMPUTED_OVERRIDES | sed -n '/^'"$START"'/,/^'"$END"'/p' \
59 | sed '1d;$d' | cut -c3- > $SUBCHART_DIR/subchart-overrides.yaml
65 resolve_deploy_flags() {
68 for (( i = 0; i < n; i++ )); do
70 if [[ $PARAM == "-f" || \
71 $PARAM == "--values" || \
72 $PARAM == "--set" || \
73 $PARAM == "--set-string" ]]; then
74 # skip param and its value
77 DEPLOY_FLAGS="$DEPLOY_FLAGS $PARAM"
85 if [[ -z "$1" || -z "$2" ]]; then
93 CHART_REPO="$(cut -d'/' -f1 <<<"$CHART_URL")"
94 CHART_NAME="$(cut -d'/' -f2 <<<"$CHART_URL")"
95 CACHE_DIR=~/.helm/plugins/deploy/cache
96 CHART_DIR=$CACHE_DIR/$CHART_NAME
97 CACHE_SUBCHART_DIR=$CHART_DIR-subcharts
98 LOG_DIR=$CHART_DIR/logs
100 # determine if verbose output is enabled
102 if [[ $FLAGS = *"--verbose"* ]]; then
103 FLAGS="$(echo $FLAGS| sed -n 's/--verbose//p')"
106 if [[ $FLAGS = *"--dry-run"* ]]; then
108 FLAGS="$FLAGS --debug"
111 # should pass all flags instead
112 NAMESPACE="$(echo $FLAGS | sed -n 's/.*\(namespace\).\s*/\1/p' | cut -c10- | cut -d' ' -f1)"
114 # Remove all override values passed in as arguments. These will be used during dry run
115 # to resolve computed override values. Remaining flags will be passed on during
116 # actual upgrade/install of parent and subcharts.
117 DEPLOY_FLAGS=$(resolve_deploy_flags "$FLAGS")
119 # determine if upgrading individual subchart or entire parent + subcharts
120 SUBCHART_RELEASE="$(cut -d'-' -f2 <<<"$RELEASE")"
121 if [[ ! -d "$CACHE_SUBCHART_DIR/$SUBCHART_RELEASE" ]]; then
124 # update specified subchart without parent
125 RELEASE="$(cut -d'-' -f1 <<<"$RELEASE")"
128 # clear previously cached charts
131 # create log driectory
134 # fetch umbrella chart (parent chart containing subcharts)
135 if [[ -d "$CHART_URL" ]]; then
137 cp -R $CHART_URL/* $CHART_DIR/
139 charts=$CHART_DIR/charts/*
140 for subchart in $charts ; do
141 tar xzf ${subchart} -C $CHART_DIR/charts/
143 rm -rf $CHART_DIR/charts/*.tgz
145 echo "fetching $CHART_URL"
146 helm fetch $CHART_URL --untar --untardir $CACHE_DIR
149 # move out subcharts to process separately
150 mkdir -p $CACHE_SUBCHART_DIR
151 mv $CHART_DIR/charts/* $CACHE_SUBCHART_DIR/
152 # temp hack - parent chart needs common subchart
153 mv $CACHE_SUBCHART_DIR/common $CHART_DIR/charts/
155 # disable dependencies
156 rm $CHART_DIR/requirements.lock
157 mv $CHART_DIR/requirements.yaml $CHART_DIR/requirements.deploy
159 # compute overrides for parent and all subcharts
160 COMPUTED_OVERRIDES=$CACHE_DIR/$CHART_NAME/computed-overrides.yaml
161 helm upgrade -i $RELEASE $CHART_DIR $FLAGS --dry-run --debug \
162 | sed -n '/COMPUTED VALUES:/,/HOOKS:/p' | sed '1d;$d' > $COMPUTED_OVERRIDES
164 # extract global overrides to apply to parent and all subcharts
165 GLOBAL_OVERRIDES=$CHART_DIR/global-overrides.yaml
166 generate_overrides $COMPUTED_OVERRIDES $GLOBAL_OVERRIDES
168 # upgrade/install parent chart first
169 if [[ -z "$SUBCHART_RELEASE" ]]; then
170 LOG_FILE=$LOG_DIR/${RELEASE}.log
173 helm upgrade -i $RELEASE $CHART_DIR $DEPLOY_FLAGS -f $COMPUTED_OVERRIDES \
176 if [[ $VERBOSE == "true" ]]; then
179 echo "release \"$RELEASE\" deployed"
183 # upgrade/install each "enabled" subchart
184 cd $CACHE_SUBCHART_DIR/
185 for subchart in * ; do
186 SUBCHART_OVERRIDES=$CACHE_SUBCHART_DIR/$subchart/subchart-overrides.yaml
189 if [[ -f $SUBCHART_OVERRIDES ]]; then
190 SUBCHART_ENABLED=$(cat $SUBCHART_OVERRIDES | grep -c "^enabled: true")
193 if [[ $SUBCHART_ENABLED -eq 1 ]]; then
194 if [[ -z "$SUBCHART_RELEASE" || $SUBCHART_RELEASE == "$subchart" ]]; then
195 LOG_FILE=$LOG_DIR/"${RELEASE}-${subchart}".log
198 helm upgrade -i "${RELEASE}-${subchart}" $CACHE_SUBCHART_DIR/$subchart \
199 $DEPLOY_FLAGS -f $GLOBAL_OVERRIDES -f $SUBCHART_OVERRIDES \
202 if [[ $VERBOSE == "true" ]]; then
205 echo "release \"${RELEASE}-${subchart}\" deployed"
209 array=($(helm ls -q | grep "${RELEASE}-${subchart}"))
211 for (( i = n-1; i >= 0; i-- )); do
212 helm del "${array[i]}" --purge
217 # report on success/failures of installs/upgrades
218 helm ls | grep FAILED | grep $RELEASE
221 case "${1:-"help"}" in