integ/kubernetes/helm/centos/files/helm-upload
Jim Gauld e0bf31f63f Add support for Helm v3, chartmuseum, and armada chart
This adds support for Helm v3:
- 'helm init' and 'helm serv' were removed in v3, and helm
  initialization was simplified so that is not required in build.
- chart validation and version checking is enforced with 'helm lint',
  so all Charts require the tag: apiVersion: v1 (or v2).
- 'chartmuseum' is a drop-in replacement for 'helm serv', and is
  currently used for building charts only. It is not part of ISO
  image.
- armada chart is built and installed to /opt/extracharts. This
  provides a Kubernetes pod with armada-api and tiller containers.

This provides a Helm v2 client (i.e., helmv2-cli) that gives access
to containerized armada/tiller managed charts. This can be used as
an interactive shell, or as a wrapper for single helm v2 commands.

Change-Id: Iff2b219ea765cf9278c6e80c6aeb5b98cc9a0626
Depends-On: https://review.opendev.org/732731
Story: 2007000
Task: 38893
Signed-off-by: Jim Gauld <james.gauld@windriver.com>
2020-06-10 03:44:59 -04:00

69 lines
1.5 KiB
Bash

#!/bin/bash
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# This script takes the names of packaged helm charts as arguments.
# It installs them in the on-node helm chart repository and regenerates
# the repository index.
# We want to run as the "www" user and scripts can't be setuid. The
# sudoers permissions are set up to allow sysadmin to run this script
# as the "www" user without a password.
WWW_ID=$(id -u www)
if [ ${UID} -ne ${WWW_ID} ]; then
exec sudo -u www -g www "$0" "$@"
fi
RETVAL=0
REINDEX=0
REPO_BASE='/www/pages/helm_charts'
# First argument is always the repo where the charts need to be placed
if [ $# -lt 2 ]; then
echo "Usage: helm-upload <repo name> <chart 1> .. <chart N>"
exit 1
fi
# Make sure the repo directory exists
REPO_DIR="${REPO_BASE}/$1"
if [ ! -e $REPO_DIR ]; then
echo "$REPO_DIR doesn't exist."
exit 1
fi
shift 1
for FILE in "$@"; do
if [ -r $FILE ]; then
# QUESTION: should we disallow overwriting an existing file?
# The versions are embedded in the filename, so it shouldn't
# cause problems.
cp $FILE $REPO_DIR
if [ $? -ne 0 ]; then
echo Problem adding $FILE to helm chart registry.
RETVAL=1
else
REINDEX=1
fi
else
echo Cannot read file ${FILE}.
RETVAL=1
fi
done
# Now re-index the helm repository if we successfully copied in
# any new charts.
if [ $REINDEX -eq 1 ]; then
/usr/sbin/helm repo index $REPO_DIR
fi
exit $RETVAL