Skip to content

Commit efddaaf

Browse files
authored
Support helm tiller upgrade and fix verify (#361)
* Fix verify This doesn't use KALM, but at least it enables testing of deployers using v2 schema. * Support helm upgrade
1 parent b4b5bef commit efddaaf

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

marketplace/deployer_helm_tiller_base/bin/deploy_internal.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,20 @@ for chart in /data/chart/*; do
5454
# Note: The local tiller process is configured with --storage=secret,
5555
# which is recommended but not default behavior.
5656
/bin/expand_config.py --values_mode=raw --app_uid="$app_uid"
57-
helm tiller run "$NAMESPACE" -- \
58-
helm install \
59-
--name="$NAME" \
60-
--namespace="$NAMESPACE" \
61-
--values=<(print_config.py --output=yaml) \
62-
"$chart"
57+
command="$(helm tiller run "$NAMESPACE" -- helm get "$NAME" &>2 && echo "upgrade" || echo "install")"
58+
if [[ "$command" == "install" ]]; then
59+
helm tiller run "$NAMESPACE" -- \
60+
helm install \
61+
--name="$NAME" \
62+
--namespace="$NAMESPACE" \
63+
--values=<(print_config.py --output=yaml) \
64+
"$chart"
65+
else
66+
helm tiller run "$NAMESPACE" -- \
67+
helm upgrade "$NAME" \
68+
--values=<(print_config.py --output=yaml) \
69+
"$chart"
70+
fi
6371

6472
# Establish an ownerReference back to the Application resource, so that
6573
# the helm release will be cleaned up when the Application is deleted.

marketplace/deployer_util/provision.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import yaml
2222

2323
import config_helper
24+
import log_util as log
2425
import property_generator
2526
import schema_values_common
2627
import storage
@@ -108,15 +109,22 @@ def process(schema, values, deployer_image, deployer_entrypoint, version_repo,
108109
# Merge input and provisioned properties.
109110
app_params = dict(list(values.iteritems()) + list(props.iteritems()))
110111

112+
use_kalm = False
111113
if (schema.is_v2() and
112114
schema.x_google_marketplace.managed_updates.kalm_supported):
115+
if version_repo:
116+
use_kalm = True
117+
else:
118+
log.warn('The deployer supports KALM but no --version-repo specified. '
119+
'Falling back to provisioning the deployer job only.')
120+
121+
if use_kalm:
113122
manifests += provision_kalm(
114123
schema,
115124
version_repo=version_repo,
116125
app_name=app_name,
117126
namespace=namespace,
118127
deployer_image=deployer_image,
119-
deployer_entrypoint=deployer_entrypoint,
120128
image_pull_secret=image_pull_secret,
121129
app_params=app_params)
122130
else:
@@ -156,7 +164,7 @@ def provision_from_storage(key, value, app_name, namespace):
156164

157165

158166
def provision_kalm(schema, version_repo, app_name, namespace, deployer_image,
159-
deployer_entrypoint, app_params, image_pull_secret):
167+
app_params, image_pull_secret):
160168
"""Provisions KALM resource for installing the application."""
161169
if not version_repo:
162170
raise Exception('A valid --version_repo must be specified')

0 commit comments

Comments
 (0)