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 [])
46 local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
47 sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
48 -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
50 indent = length($1)/2;
52 for (i in vname) {if (i > indent) {delete vname[i]}}
54 vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
55 printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
60 generate_overrides() {
61 SUBCHART_NAMES=($(cat $COMPUTED_OVERRIDES | grep -v '^\s\s'))
63 for index in "${!SUBCHART_NAMES[@]}"; do
64 START=${SUBCHART_NAMES[index]}
65 END=${SUBCHART_NAMES[index+1]}
66 if [[ $START == "global:" ]]; then
67 echo "global:" > $GLOBAL_OVERRIDES
68 cat $COMPUTED_OVERRIDES | sed '/common:/,/consul:/d' \
69 | sed -n '/'"$START"'/,/'log:'/p' | sed '1d;$d' >> $GLOBAL_OVERRIDES
71 SUBCHART_DIR="$CACHE_SUBCHART_DIR/$(cut -d':' -f1 <<<"$START")"
72 if [[ -d "$SUBCHART_DIR" ]]; then
73 cat $COMPUTED_OVERRIDES | sed -n '/'"$START"'/,/'"$END"'/p' \
74 | sed '1d;$d' | cut -c3- > $SUBCHART_DIR/subchart-overrides.yaml
84 CHART_REPO="$(cut -d'/' -f1 <<<"$CHART_URL")"
85 CHART_NAME="$(cut -d'/' -f2 <<<"$CHART_URL")"
86 CACHE_DIR=~/.helm/plugins/deploy/cache
87 CHART_DIR=$CACHE_DIR/$CHART_NAME
88 CACHE_SUBCHART_DIR=$CHART_DIR-subcharts
89 # should pass all flags instead
90 NAMESPACE="$(echo $FLAGS | sed -n 's/.*\(namespace\).\s*/\1/p' | cut -c10-)"
92 # clear previously cached charts
95 # fetch umbrella chart (parent chart containing subcharts)
96 if [[ -d "$CHART_URL" ]]; then
98 cp -R $CHART_URL/* $CHART_DIR/
100 cd $CHART_DIR/charts/
101 for subchart in * ; do
106 helm fetch $CHART_URL --untar --untardir $CACHE_DIR
109 # move out subcharts to process separately
110 mkdir -p $CACHE_SUBCHART_DIR
111 mv $CHART_DIR/charts/* $CACHE_SUBCHART_DIR/
112 # temp hack - parent chart needs common subchart
113 mv $CACHE_SUBCHART_DIR/common $CHART_DIR/charts/
115 # disable dependencies
116 rm $CHART_DIR/requirements.lock
117 mv $CHART_DIR/requirements.yaml $CHART_DIR/requirements.deploy
119 # compute overrides for parent and all subcharts
120 COMPUTED_OVERRIDES=$CACHE_DIR/$CHART_NAME/computed-overrides.yaml
121 helm upgrade -i $RELEASE $CHART_DIR $FLAGS --dry-run --debug \
122 | sed -n '/COMPUTED VALUES:/,/HOOKS:/p' | sed '1d;$d' > $COMPUTED_OVERRIDES
124 # extract global overrides to apply to parent and all subcharts
125 GLOBAL_OVERRIDES=$CHART_DIR/global-overrides.yaml
126 generate_overrides $COMPUTED_OVERRIDES $GLOBAL_OVERRIDES
128 # upgrade/install parent chart first
129 helm upgrade -i $RELEASE $CHART_DIR --namespace $NAMESPACE -f $COMPUTED_OVERRIDES
131 # parse computed overrides - will use to determine if a subchart is "enabled"
132 eval $(parse_yaml $COMPUTED_OVERRIDES "computed_")
134 # upgrade/install each "enabled" subchart
135 cd $CACHE_SUBCHART_DIR
136 for subchart in * ; do
137 VAR="computed_${subchart}_enabled"
139 eval "SUBCHART_ENABLED=$COMMAND"
140 if [[ $SUBCHART_ENABLED == "true" ]]; then
141 SUBCHART_OVERRIDES=$CACHE_SUBCHART_DIR/$subchart/subchart-overrides.yaml
142 helm upgrade -i "${RELEASE}-${subchart}" $CACHE_SUBCHART_DIR/$subchart \
143 --namespace $NAMESPACE -f $GLOBAL_OVERRIDES -f $SUBCHART_OVERRIDES
148 if [[ $# < 2 ]]; then
153 case "${1:-"help"}" in