Skip to content

Commit

Permalink
Support helm tiller upgrade and fix verify (#361)
Browse files Browse the repository at this point in the history
* Fix verify

This doesn't use KALM, but at least it enables testing of
deployers using v2 schema.

* Support helm upgrade
  • Loading branch information
huyhg authored May 31, 2019
1 parent b4b5bef commit efddaaf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
20 changes: 14 additions & 6 deletions marketplace/deployer_helm_tiller_base/bin/deploy_internal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@ for chart in /data/chart/*; do
# Note: The local tiller process is configured with --storage=secret,
# which is recommended but not default behavior.
/bin/expand_config.py --values_mode=raw --app_uid="$app_uid"
helm tiller run "$NAMESPACE" -- \
helm install \
--name="$NAME" \
--namespace="$NAMESPACE" \
--values=<(print_config.py --output=yaml) \
"$chart"
command="$(helm tiller run "$NAMESPACE" -- helm get "$NAME" &>2 && echo "upgrade" || echo "install")"
if [[ "$command" == "install" ]]; then
helm tiller run "$NAMESPACE" -- \
helm install \
--name="$NAME" \
--namespace="$NAMESPACE" \
--values=<(print_config.py --output=yaml) \
"$chart"
else
helm tiller run "$NAMESPACE" -- \
helm upgrade "$NAME" \
--values=<(print_config.py --output=yaml) \
"$chart"
fi

# Establish an ownerReference back to the Application resource, so that
# the helm release will be cleaned up when the Application is deleted.
Expand Down
12 changes: 10 additions & 2 deletions marketplace/deployer_util/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import yaml

import config_helper
import log_util as log
import property_generator
import schema_values_common
import storage
Expand Down Expand Up @@ -108,15 +109,22 @@ def process(schema, values, deployer_image, deployer_entrypoint, version_repo,
# Merge input and provisioned properties.
app_params = dict(list(values.iteritems()) + list(props.iteritems()))

use_kalm = False
if (schema.is_v2() and
schema.x_google_marketplace.managed_updates.kalm_supported):
if version_repo:
use_kalm = True
else:
log.warn('The deployer supports KALM but no --version-repo specified. '
'Falling back to provisioning the deployer job only.')

if use_kalm:
manifests += provision_kalm(
schema,
version_repo=version_repo,
app_name=app_name,
namespace=namespace,
deployer_image=deployer_image,
deployer_entrypoint=deployer_entrypoint,
image_pull_secret=image_pull_secret,
app_params=app_params)
else:
Expand Down Expand Up @@ -156,7 +164,7 @@ def provision_from_storage(key, value, app_name, namespace):


def provision_kalm(schema, version_repo, app_name, namespace, deployer_image,
deployer_entrypoint, app_params, image_pull_secret):
app_params, image_pull_secret):
"""Provisions KALM resource for installing the application."""
if not version_repo:
raise Exception('A valid --version_repo must be specified')
Expand Down

0 comments on commit efddaaf

Please sign in to comment.