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 if [[ -z "$END" ]]; then
59 cat $COMPUTED_OVERRIDES | sed -n '/^'"$START"'/,/'"$END"'/p' \
60 | sed '1d;$d' | cut -c3- > $SUBCHART_DIR/subchart-overrides.yaml
62 cat $COMPUTED_OVERRIDES | sed -n '/^'"$START"'/,/^'"$END"'/p' \
63 | sed '1d;$d' | cut -c3- > $SUBCHART_DIR/subchart-overrides.yaml
69 resolve_deploy_flags() {
72 for (( i = 0; i < n; i++ )); do
74 if [[ $PARAM == "-f" || \
75 $PARAM == "--values" || \
76 $PARAM == "--set" || \
77 $PARAM == "--set-string" || \
78 $PARAM == "--version" ]]; then
79 # skip param and its value
82 DEPLOY_FLAGS="$DEPLOY_FLAGS $PARAM"
90 if [[ -z "$1" || -z "$2" ]]; then
98 CHART_REPO="$(cut -d'/' -f1 <<<"$CHART_URL")"
99 CHART_NAME="$(cut -d'/' -f2 <<<"$CHART_URL")"
100 CACHE_DIR=~/.helm/plugins/deploy/cache
101 CHART_DIR=$CACHE_DIR/$CHART_NAME
102 CACHE_SUBCHART_DIR=$CHART_DIR-subcharts
103 LOG_DIR=$CHART_DIR/logs
105 # determine if verbose output is enabled
107 if [[ $FLAGS = *"--verbose"* ]]; then
108 FLAGS="$(echo $FLAGS| sed -n 's/--verbose//p')"
111 if [[ $FLAGS = *"--dry-run"* ]]; then
113 FLAGS="$FLAGS --debug"
116 # should pass all flags instead
117 NAMESPACE="$(echo $FLAGS | sed -n 's/.*\(namespace\).\s*/\1/p' | cut -c10- | cut -d' ' -f1)"
119 VERSION="$(echo $FLAGS | sed -n 's/.*\(version\).\s*/\1/p' | cut -c8- | cut -d' ' -f1)"
121 if [ ! -z $VERSION ]; then
122 VERSION="--version $VERSION"
125 # Remove all override values passed in as arguments. These will be used during dry run
126 # to resolve computed override values. Remaining flags will be passed on during
127 # actual upgrade/install of parent and subcharts.
128 DEPLOY_FLAGS=$(resolve_deploy_flags "$FLAGS")
130 # determine if upgrading individual subchart or entire parent + subcharts
131 SUBCHART_RELEASE="$(cut -d'-' -f2 <<<"$RELEASE")"
132 if [[ ! -d "$CACHE_SUBCHART_DIR/$SUBCHART_RELEASE" ]]; then
135 # update specified subchart without parent
136 RELEASE="$(cut -d'-' -f1 <<<"$RELEASE")"
139 # clear previously cached charts
142 # create log driectory
145 # fetch umbrella chart (parent chart containing subcharts)
146 if [[ -d "$CHART_URL" ]]; then
148 cp -R $CHART_URL/* $CHART_DIR/
150 charts=$CHART_DIR/charts/*
151 for subchart in $charts ; do
152 tar xzf ${subchart} -C $CHART_DIR/charts/
154 rm -rf $CHART_DIR/charts/*.tgz
156 echo "fetching $CHART_URL"
157 helm fetch $CHART_URL --untar --untardir $CACHE_DIR $VERSION
160 # move out subcharts to process separately
161 mkdir -p $CACHE_SUBCHART_DIR
162 mv $CHART_DIR/charts/* $CACHE_SUBCHART_DIR/
163 # temp hack - parent chart needs common subchart
164 mv $CACHE_SUBCHART_DIR/common $CHART_DIR/charts/
166 # disable dependencies
167 rm $CHART_DIR/requirements.lock
168 mv $CHART_DIR/requirements.yaml $CHART_DIR/requirements.deploy
170 # compute overrides for parent and all subcharts
171 COMPUTED_OVERRIDES=$CACHE_DIR/$CHART_NAME/computed-overrides.yaml
172 helm upgrade -i $RELEASE $CHART_DIR $FLAGS --dry-run --debug \
173 | sed -n '/COMPUTED VALUES:/,/HOOKS:/p' | sed '1d;$d' > $COMPUTED_OVERRIDES
175 # extract global overrides to apply to parent and all subcharts
176 GLOBAL_OVERRIDES=$CHART_DIR/global-overrides.yaml
177 generate_overrides $COMPUTED_OVERRIDES $GLOBAL_OVERRIDES
179 # upgrade/install parent chart first
180 if [[ -z "$SUBCHART_RELEASE" ]]; then
181 LOG_FILE=$LOG_DIR/${RELEASE}.log
184 helm upgrade -i $RELEASE $CHART_DIR $DEPLOY_FLAGS -f $COMPUTED_OVERRIDES \
187 if [[ $VERBOSE == "true" ]]; then
190 echo "release \"$RELEASE\" deployed"
194 # upgrade/install each "enabled" subchart
195 cd $CACHE_SUBCHART_DIR/
196 for subchart in * ; do
197 SUBCHART_OVERRIDES=$CACHE_SUBCHART_DIR/$subchart/subchart-overrides.yaml
200 if [[ -f $SUBCHART_OVERRIDES ]]; then
201 SUBCHART_ENABLED=$(cat $SUBCHART_OVERRIDES | grep -c "^enabled: true")
204 if [[ $SUBCHART_ENABLED -eq 1 ]]; then
205 if [[ -z "$SUBCHART_RELEASE" || $SUBCHART_RELEASE == "$subchart" ]]; then
206 LOG_FILE=$LOG_DIR/"${RELEASE}-${subchart}".log
209 helm upgrade -i "${RELEASE}-${subchart}" $CACHE_SUBCHART_DIR/$subchart \
210 $DEPLOY_FLAGS -f $GLOBAL_OVERRIDES -f $SUBCHART_OVERRIDES \
213 if [[ $VERBOSE == "true" ]]; then
216 echo "release \"${RELEASE}-${subchart}\" deployed"
220 array=($(helm ls -q | grep "${RELEASE}-${subchart}"))
222 for (( i = n-1; i >= 0; i-- )); do
223 helm del "${array[i]}" --purge
228 # report on success/failures of installs/upgrades
229 helm ls | grep FAILED | grep $RELEASE
232 case "${1:-"help"}" in