From f3842f9fe199cb9f326a49c1db13527a584ca45f Mon Sep 17 00:00:00 2001 From: Sean Eagan Date: Tue, 27 Jul 2021 13:46:52 -0500 Subject: [PATCH] Use helm 3 in chart build `helm serve` is removed in helm 3 so this moves to using local `file://` dependencies [0] instead. [0]: https://helm.sh/docs/chart_best_practices/dependencies/#repository-urls Signed-off-by: Sean Eagan Change-Id: I2282e231591a89073e65d9db3f59e1baea707380 --- .gitignore | 12 +++--- Makefile | 14 +++---- charts/armada/requirements.yaml | 2 +- charts/deps/.gitkeep | 0 charts/tiller/requirements.yaml | 2 +- tools/helm_install.sh | 2 +- tools/helm_tk.sh | 66 +++++---------------------------- 7 files changed, 23 insertions(+), 75 deletions(-) create mode 100644 charts/deps/.gitkeep diff --git a/.gitignore b/.gitignore index 0bb45a47..24e3b8a6 100644 --- a/.gitignore +++ b/.gitignore @@ -94,13 +94,11 @@ ENV/ # Rope project settings .ropeproject -# Helm internals -*.lock -*/*.lock -*.tgz -**/*.tgz -**/_partials.tpl -**/_globals.tpl +# Chart artifacts +/charts/*.tgz +/charts/*/charts +/charts/*/requirements.lock +/charts/deps/*/ # OSX .DS_STORE diff --git a/Makefile b/Makefile index 876589d3..6e97aa0d 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ PUSH_IMAGE ?= false LABEL ?= org.airshipit.build=community COMMIT ?= $(shell git rev-parse HEAD) PYTHON = python3 -CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.)) +CHARTS := $(filter-out deps, $(patsubst charts/%/.,%,$(wildcard charts/*/.))) DISTRO ?= ubuntu_bionic IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO} UBUNTU_BASE_IMAGE ?= @@ -41,8 +41,6 @@ GIT_SHA = $(shell git rev-parse --short HEAD) GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean") -HELM_PIDFILE ?= $(abspath ./.helm-pid) - ifdef VERSION DOCKER_VERSION = $(VERSION) endif @@ -167,12 +165,12 @@ charts: $(CHARTS) helm-init: $(addprefix helm-init-,$(CHARTS)) -helm-init-%: helm-serve +helm-init-%: helm-toolkit @echo Initializing chart $* - cd charts;if [ -s $*/requirements.yaml ]; then echo "Initializing $*";$(HELM) dep up $*; fi + cd charts;if [ -s $*/requirements.yaml ]; then echo "Initializing $*";$(HELM) dep up --skip-refresh $*; fi -helm-serve: helm-install - ./tools/helm_tk.sh $(HELM) $(HELM_PIDFILE) +helm-toolkit: helm-install + ./tools/helm_tk.sh $(HELM) helm-lint: $(addprefix helm-lint-,$(CHARTS)) @@ -196,5 +194,5 @@ helm-install: .PHONY: $(CHARTS) all bootstrap bootstrap-all build build_armada \ build_docs charts check-docker check-tox clean docs dry-run \ dry-run-% format helm-init helm-init-% helm-install helm-lint \ - helm-lint-% helm-serve images lint protoc run_armada run_images \ + helm-lint-% helm-toolkit images lint protoc run_armada run_images \ test-all test-bandit test-coverage test-pep8 tests test-unit diff --git a/charts/armada/requirements.yaml b/charts/armada/requirements.yaml index c81c2135..f0eabffd 100644 --- a/charts/armada/requirements.yaml +++ b/charts/armada/requirements.yaml @@ -14,5 +14,5 @@ dependencies: - name: helm-toolkit - repository: http://localhost:8879/charts + repository: file://../deps/helm-toolkit version: ">= 0.1.0" diff --git a/charts/deps/.gitkeep b/charts/deps/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/charts/tiller/requirements.yaml b/charts/tiller/requirements.yaml index a76251fd..704ebe65 100644 --- a/charts/tiller/requirements.yaml +++ b/charts/tiller/requirements.yaml @@ -14,5 +14,5 @@ dependencies: - name: helm-toolkit - repository: http://localhost:8879/charts + repository: file://../deps/helm-toolkit version: ">= 0.1.0" diff --git a/tools/helm_install.sh b/tools/helm_install.sh index 02ead5f7..730d1413 100755 --- a/tools/helm_install.sh +++ b/tools/helm_install.sh @@ -17,7 +17,7 @@ set -x HELM=$1 -HELM_ARTIFACT_URL=${HELM_ARTIFACT_URL:-"https://get.helm.sh/helm-v2.16.9-linux-amd64.tar.gz"} +HELM_ARTIFACT_URL=${HELM_ARTIFACT_URL:-"https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz"} function install_helm_binary { diff --git a/tools/helm_tk.sh b/tools/helm_tk.sh index d8100730..f4651011 100755 --- a/tools/helm_tk.sh +++ b/tools/helm_tk.sh @@ -12,68 +12,20 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# -# Script to setup helm-toolkit and helm dep up the armada chart -# + set -eux -HELM=${1} -HELM_PIDFILE=${2} -SERVE_DIR=$(mktemp -d) +HTK_REPO=${HTK_REPO:-"https://opendev.org/openstack/openstack-helm-infra.git"} +HTK_STABLE_COMMIT=${HTK_COMMIT:-"2d1fe882bb751c03ee741a6166c9c8a5fad8f926"} -HTK_STABLE_COMMIT=${HTK_COMMIT:-"4fe6212dad6e3f07d43122485d60ab8f38642293"} - -${HELM} init --client-only --skip-refresh - -if [[ -s ${HELM_PIDFILE} ]]; then - HELM_PID=$(cat "${HELM_PIDFILE}") - if ps "${HELM_PID}"; then - kill "${HELM_PID}" - sleep 0.5 - if ps "${HELM_PID}"; then - echo Failed to terminate Helm, PID = "${HELM_PID}" - exit 1 - fi - fi -fi - -${HELM} serve & > /dev/null -HELM_PID=${!} -echo Started Helm, PID = "${HELM_PID}" -echo "${HELM_PID}" > "${HELM_PIDFILE}" - -set +x -if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then - while [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; do - sleep 1 - echo "Waiting for Helm Repository" - done -else - echo "Helm serve already running" -fi -set -x - -if ${HELM} repo list | grep -q "^stable" ; then - ${HELM} repo remove stable -fi - -${HELM} repo add local http://localhost:8879/charts - - -#OSH Makefile is bugged, so ensure helm is in the path -if [[ ${HELM} != "helm" ]] -then - export PATH=${PATH}:$(dirname ${HELM}) -fi +TMP_DIR=$(mktemp -d) { - cd "${SERVE_DIR}" - git clone https://git.openstack.org/openstack/openstack-helm-infra.git || true - cd openstack-helm-infra - git reset --hard "${HTK_STABLE_COMMIT}" - - make helm-toolkit + HTK_REPO_DIR=$TMP_DIR/htk + git clone "$HTK_REPO" "$HTK_REPO_DIR" + (cd "$HTK_REPO_DIR" && git reset --hard "${HTK_STABLE_COMMIT}") + cp -r "${HTK_REPO_DIR}/helm-toolkit" charts/deps/ } -rm -rf "${SERVE_DIR}" +rm -rf "${TMP_DIR}"