From 0dafbc57f8ad3c2f339f4c8211a86cc990136e64 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 19 Apr 2018 13:49:05 -0700 Subject: [PATCH 01/25] add helmfile --- Dockerfile | 2 +- modules/helmfile/Makefile | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 modules/helmfile/Makefile diff --git a/Dockerfile b/Dockerfile index 275bc181..14548001 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN apk update && \ ADD ./ /build-harness/ RUN cd /build-harness && \ - make helm/install template/deps + make helm/install helmfile/install template/deps WORKDIR /build-harness diff --git a/modules/helmfile/Makefile b/modules/helmfile/Makefile new file mode 100644 index 00000000..0a5b3c16 --- /dev/null +++ b/modules/helmfile/Makefile @@ -0,0 +1,10 @@ +CURL := $(shell which curl) +HELMFILE_VERSION ?= 0.12.0 +HELMFILE := $(shell which helm) + +## Install helmfile +helmfile/install: + @$(CURL) --fail -sSL https://github.com/roboll/helmfile/releases/download/v$(HELMFILE_VERSION)/helmfile_$(OS)_amd64 -o /usr/local/bin/helmfile + @chmod +x /usr/local/bin/helmfile + + From 758e4d76ad08b9f3f5e654e43e11e16757b0e983 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 19 Apr 2018 13:55:33 -0700 Subject: [PATCH 02/25] Add chamber --- Dockerfile | 2 +- modules/chamber/Makefile | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 modules/chamber/Makefile diff --git a/Dockerfile b/Dockerfile index 14548001..d3ae8708 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN apk update && \ ADD ./ /build-harness/ RUN cd /build-harness && \ - make helm/install helmfile/install template/deps + make chamber/install helm/install helmfile/install template/deps WORKDIR /build-harness diff --git a/modules/chamber/Makefile b/modules/chamber/Makefile new file mode 100644 index 00000000..16b07005 --- /dev/null +++ b/modules/chamber/Makefile @@ -0,0 +1,10 @@ +CURL := $(shell which curl) +CHAMBER_VERSION ?= 2.0.0 +CHAMBER := $(shell which chamber) + +## Install chamber +chamber/install: + @$(CURL) --fail -sSL https://github.com/segmentio/chamber/releases/download/v$(CHAMBER_VERSION)/chamber-v$(CHAMBER_VERSION)-$(OS)-amd64 -o /usr/local/bin/chamber + @chmod +x /usr/local/bin/chamber + + From 89e523f35596700249b29cc49a05b4b54528f309 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 13:09:33 -0700 Subject: [PATCH 03/25] add distro --- modules/chamber/Makefile | 5 ++--- modules/helmfile/Makefile | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/chamber/Makefile b/modules/chamber/Makefile index 16b07005..8310e30a 100644 --- a/modules/chamber/Makefile +++ b/modules/chamber/Makefile @@ -3,8 +3,7 @@ CHAMBER_VERSION ?= 2.0.0 CHAMBER := $(shell which chamber) ## Install chamber -chamber/install: - @$(CURL) --fail -sSL https://github.com/segmentio/chamber/releases/download/v$(CHAMBER_VERSION)/chamber-v$(CHAMBER_VERSION)-$(OS)-amd64 -o /usr/local/bin/chamber - @chmod +x /usr/local/bin/chamber +chamber/install: distro/install/chamber + @exit 0 diff --git a/modules/helmfile/Makefile b/modules/helmfile/Makefile index 0a5b3c16..bddbe0d6 100644 --- a/modules/helmfile/Makefile +++ b/modules/helmfile/Makefile @@ -3,8 +3,7 @@ HELMFILE_VERSION ?= 0.12.0 HELMFILE := $(shell which helm) ## Install helmfile -helmfile/install: - @$(CURL) --fail -sSL https://github.com/roboll/helmfile/releases/download/v$(HELMFILE_VERSION)/helmfile_$(OS)_amd64 -o /usr/local/bin/helmfile - @chmod +x /usr/local/bin/helmfile +helmfile/install: distro/install/helmfile + @exit 0 From b428a64ec981da9168cca92a108ab53c287e6f3f Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 13:12:30 -0700 Subject: [PATCH 04/25] install distro --- modules/distro/Makefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 modules/distro/Makefile diff --git a/modules/distro/Makefile b/modules/distro/Makefile new file mode 100644 index 00000000..5478f19a --- /dev/null +++ b/modules/distro/Makefile @@ -0,0 +1,16 @@ +export INSTALL_PATH ?= $(BUILD_HARNESS_PATH)/vendor +export DISTRO_VERSION ?= init +export DISTRO_PATH ?= $(BUILD_HARNESS_PATH)/vendor/distro + +## Install distro +distro/install: + @if [ ! -d $(DISTRO_PATH) ]; then \ + echo "Installing distro $(DISTRO_VERSION)..."; \ + rm -rf $(DISTRO_PATH); \ + git clone --depth=1 -b $(DISTRO_VERSION) git@github.com:cloudposse/distro.git $(DISTRO_PATH); \ + rm -rf $(DISTRO_PATH)/.git; \ + fi + +## Install package (e.g. helm, helmfile, kubectl) +distro/install/%: distro/install + @make -C $(DISTRO_PATH)/install $(subst distro/install/,,$@) From e606fb1401e58b8aad3069708e6620b4c141ebd1 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 20:46:51 -0700 Subject: [PATCH 05/25] use yq to rewrite yaml; do not templatize yaml --- modules/helm/Makefile | 9 +++------ modules/helm/Makefile.chart | 12 +++++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/modules/helm/Makefile b/modules/helm/Makefile index 5937b231..7bb1cc1e 100644 --- a/modules/helm/Makefile +++ b/modules/helm/Makefile @@ -8,10 +8,7 @@ HELM_REPO_PATH ?= ./$(REPO_NAME) HELM_PACKAGE_PATH ?= ./packages/$(REPO_NAME) ## Install helm -helm/install: - @$(CURL) https://kubernetes-helm.storage.googleapis.com/helm-$(HELM_VERSION)-$(HELM_PLATFORM).tar.gz | tar xvz - @chmod +x $(HELM_PLATFORM)/helm - @mv $(HELM_PLATFORM)/helm /usr/local/bin/ +helm/install: distro/install/helm distro/install/yq @helm init --client-only @chmod -R 777 "$(HELM_HOME)" @helm repo remove local || true @@ -20,5 +17,5 @@ helm/install: helm/serve/index: $(call assert-set,CURRENT_REPO_URL) $(call assert-set,HELM) - @$(SELF) helm:repo:index REPO_NAME=incubator - @$(SELF) helm:repo:index REPO_NAME=stable + @$(SELF) helm/repo/index REPO_NAME=incubator + @$(SELF) helm/repo/index REPO_NAME=stable diff --git a/modules/helm/Makefile.chart b/modules/helm/Makefile.chart index 30d66845..c0ee4654 100644 --- a/modules/helm/Makefile.chart +++ b/modules/helm/Makefile.chart @@ -34,7 +34,9 @@ helm/chart/build: @rm -rf $(HELM_PACKAGE_PATH)$(CHART_NAME) @mkdir -p $(HELM_PACKAGE_PATH)$(CHART_NAME) @cp -R $(CHART_TPL)/* $(HELM_PACKAGE_PATH)$(CHART_NAME) - @find $(HELM_PACKAGE_PATH)$(CHART_NAME) -type f | xargs -I{} bash -c 'IN={} OUT={} $(SELF) -s template/build' + @echo "Pinning chart version and image.tag to $(SEMVERSION)" + @yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/Chart.yaml version $(SEMVERSION) + @yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/values.yaml image.tag $(SEMVERSION) @echo "Fetch dependencies" @$(HELM) dependency build --debug $(HELM_PACKAGE_PATH)$(CHART_NAME) @echo "Create package" @@ -49,10 +51,10 @@ helm/chart/build-all: $(call assert-set,CHART_TPL) @for version in $(SEMVERSIONS) ; do \ echo "Build chart $(CHART_NAME) version $$version"; \ - CHART_NAME=$(CHART_NAME) \ - CHART_TPL=$(CHART_TPL) \ - SEMVERSION=$$version \ - $(SELF) -s helm/chart/build; \ + $(SELF) -s helm/chart/build \ + CHART_NAME=$(CHART_NAME) \ + CHART_TPL=$(CHART_TPL) \ + SEMVERSION=$$version; \ done ## Publish chart $CHART_NAME to $REPO_GATEWAY_ENDPOINT From 079fabff4d3fb34d642ade9adff3d6818dde01cb Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 20:56:01 -0700 Subject: [PATCH 06/25] use https --- modules/distro/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/distro/Makefile b/modules/distro/Makefile index 5478f19a..91d15cee 100644 --- a/modules/distro/Makefile +++ b/modules/distro/Makefile @@ -7,7 +7,7 @@ distro/install: @if [ ! -d $(DISTRO_PATH) ]; then \ echo "Installing distro $(DISTRO_VERSION)..."; \ rm -rf $(DISTRO_PATH); \ - git clone --depth=1 -b $(DISTRO_VERSION) git@github.com:cloudposse/distro.git $(DISTRO_PATH); \ + git clone --depth=1 -b $(DISTRO_VERSION) https://github.com/cloudposse/distro.git $(DISTRO_PATH); \ rm -rf $(DISTRO_PATH)/.git; \ fi From 827c68af5a6bac3b9ab77bc8ecfdb95efd8e4c4e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 21:03:43 -0700 Subject: [PATCH 07/25] fix docker image --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d3ae8708..61245e78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,11 @@ RUN apk update && \ ADD ./ /build-harness/ -RUN cd /build-harness && \ - make chamber/install helm/install helmfile/install template/deps +ENV INSTALL_PATH /usr/local/bin WORKDIR /build-harness +RUN make -s chamber/install helm/install helmfile/install template/deps + ENTRYPOINT ["/bin/bash"] From 60d46596b0e5f1a2f61ed71332dc496dcd973366 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 21:13:26 -0700 Subject: [PATCH 08/25] concise errors --- modules/helm/Makefile.chart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/helm/Makefile.chart b/modules/helm/Makefile.chart index c0ee4654..150dc500 100644 --- a/modules/helm/Makefile.chart +++ b/modules/helm/Makefile.chart @@ -35,8 +35,8 @@ helm/chart/build: @mkdir -p $(HELM_PACKAGE_PATH)$(CHART_NAME) @cp -R $(CHART_TPL)/* $(HELM_PACKAGE_PATH)$(CHART_NAME) @echo "Pinning chart version and image.tag to $(SEMVERSION)" - @yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/Chart.yaml version $(SEMVERSION) - @yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/values.yaml image.tag $(SEMVERSION) + @set -o pipefile; yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/Chart.yaml version $(SEMVERSION) | head -1 + @set -o pipefile; yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/values.yaml image.tag $(SEMVERSION) | head -1 @echo "Fetch dependencies" @$(HELM) dependency build --debug $(HELM_PACKAGE_PATH)$(CHART_NAME) @echo "Create package" From d762e3be8084b6d3ce86331ba3db84524a98871d Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 21:46:23 -0700 Subject: [PATCH 09/25] fix typo --- modules/helm/Makefile.chart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/helm/Makefile.chart b/modules/helm/Makefile.chart index 150dc500..b872a17a 100644 --- a/modules/helm/Makefile.chart +++ b/modules/helm/Makefile.chart @@ -35,8 +35,8 @@ helm/chart/build: @mkdir -p $(HELM_PACKAGE_PATH)$(CHART_NAME) @cp -R $(CHART_TPL)/* $(HELM_PACKAGE_PATH)$(CHART_NAME) @echo "Pinning chart version and image.tag to $(SEMVERSION)" - @set -o pipefile; yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/Chart.yaml version $(SEMVERSION) | head -1 - @set -o pipefile; yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/values.yaml image.tag $(SEMVERSION) | head -1 + @set -o pipefail; yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/Chart.yaml version $(SEMVERSION) | head -1 + @set -o pipefail; yq write --inplace $(HELM_PACKAGE_PATH)$(CHART_NAME)/values.yaml image.tag $(SEMVERSION) | head -1 @echo "Fetch dependencies" @$(HELM) dependency build --debug $(HELM_PACKAGE_PATH)$(CHART_NAME) @echo "Create package" From e97e8f1774b8b3e978d34b3fe71a4caee4dec21f Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 23:05:41 -0700 Subject: [PATCH 10/25] install all dependencies --- modules/helmfile/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/helmfile/Makefile b/modules/helmfile/Makefile index bddbe0d6..799fb555 100644 --- a/modules/helmfile/Makefile +++ b/modules/helmfile/Makefile @@ -3,7 +3,7 @@ HELMFILE_VERSION ?= 0.12.0 HELMFILE := $(shell which helm) ## Install helmfile -helmfile/install: distro/install/helmfile +helmfile/install: distro/install/helmfile distro/install/kubectl distro/install/helm @exit 0 From d2df25ea34e1d41954b96d7d62b43a51c1a05456 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 22 Apr 2018 23:29:07 -0700 Subject: [PATCH 11/25] add ca-certificates --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 61245e78..cbc805ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,13 @@ FROM golang:1.9.2-alpine3.7 RUN apk update && \ apk --update add \ - jq \ - git \ - make \ - curl \ bash \ - grep + ca-certificates \ + curl \ + git \ + grep \ + jq \ + make ADD ./ /build-harness/ From 72c49dcfaae6775389b1359bad46e687b3b12695 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Apr 2018 13:16:20 -0700 Subject: [PATCH 12/25] rename distro to packages --- modules/chamber/Makefile | 2 +- modules/helm/Makefile | 2 +- modules/helmfile/Makefile | 2 +- modules/{distro => packages}/Makefile | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) rename modules/{distro => packages}/Makefile (50%) diff --git a/modules/chamber/Makefile b/modules/chamber/Makefile index 8310e30a..25b4033a 100644 --- a/modules/chamber/Makefile +++ b/modules/chamber/Makefile @@ -3,7 +3,7 @@ CHAMBER_VERSION ?= 2.0.0 CHAMBER := $(shell which chamber) ## Install chamber -chamber/install: distro/install/chamber +chamber/install: packages/install/chamber @exit 0 diff --git a/modules/helm/Makefile b/modules/helm/Makefile index 7bb1cc1e..ff1a50af 100644 --- a/modules/helm/Makefile +++ b/modules/helm/Makefile @@ -8,7 +8,7 @@ HELM_REPO_PATH ?= ./$(REPO_NAME) HELM_PACKAGE_PATH ?= ./packages/$(REPO_NAME) ## Install helm -helm/install: distro/install/helm distro/install/yq +helm/install: packages/install/helm packages/install/yq @helm init --client-only @chmod -R 777 "$(HELM_HOME)" @helm repo remove local || true diff --git a/modules/helmfile/Makefile b/modules/helmfile/Makefile index 799fb555..d5487ebd 100644 --- a/modules/helmfile/Makefile +++ b/modules/helmfile/Makefile @@ -3,7 +3,7 @@ HELMFILE_VERSION ?= 0.12.0 HELMFILE := $(shell which helm) ## Install helmfile -helmfile/install: distro/install/helmfile distro/install/kubectl distro/install/helm +helmfile/install: packages/install/helmfile packages/install/kubectl packages/install/helm @exit 0 diff --git a/modules/distro/Makefile b/modules/packages/Makefile similarity index 50% rename from modules/distro/Makefile rename to modules/packages/Makefile index 91d15cee..86445e80 100644 --- a/modules/distro/Makefile +++ b/modules/packages/Makefile @@ -1,16 +1,16 @@ export INSTALL_PATH ?= $(BUILD_HARNESS_PATH)/vendor export DISTRO_VERSION ?= init -export DISTRO_PATH ?= $(BUILD_HARNESS_PATH)/vendor/distro +export DISTRO_PATH ?= $(BUILD_HARNESS_PATH)/vendor/packages -## Install distro -distro/install: +## Install packages +packages/install: @if [ ! -d $(DISTRO_PATH) ]; then \ - echo "Installing distro $(DISTRO_VERSION)..."; \ + echo "Installing packages $(DISTRO_VERSION)..."; \ rm -rf $(DISTRO_PATH); \ - git clone --depth=1 -b $(DISTRO_VERSION) https://github.com/cloudposse/distro.git $(DISTRO_PATH); \ + git clone --depth=1 -b $(DISTRO_VERSION) https://github.com/cloudposse/packages.git $(DISTRO_PATH); \ rm -rf $(DISTRO_PATH)/.git; \ fi ## Install package (e.g. helm, helmfile, kubectl) -distro/install/%: distro/install - @make -C $(DISTRO_PATH)/install $(subst distro/install/,,$@) +packages/install/%: packages/install + @make -C $(DISTRO_PATH)/install $(subst packages/install/,,$@) From 93e483460a63371a26bb0e62135e9ab9a716c3cc Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Apr 2018 13:24:17 -0700 Subject: [PATCH 13/25] pin to release --- modules/packages/Makefile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/packages/Makefile b/modules/packages/Makefile index 86445e80..f458aafc 100644 --- a/modules/packages/Makefile +++ b/modules/packages/Makefile @@ -1,16 +1,20 @@ export INSTALL_PATH ?= $(BUILD_HARNESS_PATH)/vendor -export DISTRO_VERSION ?= init -export DISTRO_PATH ?= $(BUILD_HARNESS_PATH)/vendor/packages +export PACKAGES_VERSION ?= 0.1.0 +export PACKAGES_PATH ?= $(BUILD_HARNESS_PATH)/vendor/packages ## Install packages packages/install: - @if [ ! -d $(DISTRO_PATH) ]; then \ - echo "Installing packages $(DISTRO_VERSION)..."; \ - rm -rf $(DISTRO_PATH); \ - git clone --depth=1 -b $(DISTRO_VERSION) https://github.com/cloudposse/packages.git $(DISTRO_PATH); \ - rm -rf $(DISTRO_PATH)/.git; \ + @if [ ! -d $(PACKAGES_PATH) ]; then \ + echo "Installing packages $(PACKAGES_VERSION)..."; \ + rm -rf $(PACKAGES_PATH); \ + git clone --depth=1 -b $(PACKAGES_VERSION) https://github.com/cloudposse/packages.git $(PACKAGES_PATH); \ + rm -rf $(PACKAGES_PATH)/.git; \ fi ## Install package (e.g. helm, helmfile, kubectl) packages/install/%: packages/install - @make -C $(DISTRO_PATH)/install $(subst packages/install/,,$@) + @make -C $(PACKAGES_PATH)/install $(subst packages/install/,,$@) + +## Uninstall package (e.g. helm, helmfile, kubectl) +packages/uninstall/%: packages/install + @make -C $(PACKAGES_PATH)/uninstall $(subst packages/uninstall/,,$@) From a3adb37cc04dfa6dc83cfc893a60e78df5d52c2f Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Apr 2018 18:14:44 -0700 Subject: [PATCH 14/25] add gettext for envsubst --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index cbc805ce..20e55a94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN apk update && \ ca-certificates \ curl \ git \ + gettext \ grep \ jq \ make From 8f3d17c945e9013de0f8375fb916e57ecb595824 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Apr 2018 18:27:51 -0700 Subject: [PATCH 15/25] disable go-deps due to 404 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0bab7391..386b61e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ services: install: - make docker/login - make go/deps-build -- make go/deps-dev +#- make go/deps-dev script: - make bash/lint From 611b099a9eda4bb0cd54c24edee14ad6df8aebdc Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 25 Apr 2018 13:36:34 -0700 Subject: [PATCH 16/25] re-enable deps-dev --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 386b61e2..0bab7391 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ services: install: - make docker/login - make go/deps-build -#- make go/deps-dev +- make go/deps-dev script: - make bash/lint From d67d87c1c90888eaa5f7b364c8fb753e9034c42c Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 01:53:25 -0700 Subject: [PATCH 17/25] Upgrade helm --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index cbc805ce..4eb9b389 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ ENV INSTALL_PATH /usr/local/bin WORKDIR /build-harness +ENV HELM_VERSION=2.9.0-rc5 RUN make -s chamber/install helm/install helmfile/install template/deps ENTRYPOINT ["/bin/bash"] From ec8eb6c9f3ab13e27fc1333bc83af6d2419dfff2 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 02:00:37 -0700 Subject: [PATCH 18/25] move helm version --- Dockerfile | 1 - modules/helm/Makefile | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c411ca5..20e55a94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ ENV INSTALL_PATH /usr/local/bin WORKDIR /build-harness -ENV HELM_VERSION=2.9.0-rc5 RUN make -s chamber/install helm/install helmfile/install template/deps ENTRYPOINT ["/bin/bash"] diff --git a/modules/helm/Makefile b/modules/helm/Makefile index ff1a50af..e184298d 100644 --- a/modules/helm/Makefile +++ b/modules/helm/Makefile @@ -1,5 +1,5 @@ CURL := $(shell which curl) -HELM_VERSION ?= v2.7.2 +export HELM_VERSION ?= 2.9.0-rc5 HELM_PLATFORM ?= $(OS)-amd64 HELM := $(shell which helm) HELM_HOME ?= $(HOME)/.helm From ac176b88a8d590d765ae11f04a1deb3be4aa137e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 20:40:22 -0700 Subject: [PATCH 19/25] add upsert --- bin/helm_toolbox.sh | 70 +++++++++++++++++++++++++++++++++++++++++++ modules/helm/Makefile | 5 ++++ 2 files changed, 75 insertions(+) create mode 100755 bin/helm_toolbox.sh diff --git a/bin/helm_toolbox.sh b/bin/helm_toolbox.sh new file mode 100755 index 00000000..02652626 --- /dev/null +++ b/bin/helm_toolbox.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +export TIMEOUT=3 +export STDOUT=${STDOUT:-/dev/null} + +# helper functions +function info() { + echo -e "\e[32mINFO:\e[0m $1"; +} + +function err() { + echo -e "\e[31mERROR:\e[0m $1" ; + exit 1; +} + +function check() { + command -v "$1" >/dev/null 2>&1 || err "$1 not installed!"; +} + +# wait helm to be operational +wait_for_helm() { + info "Waiting for helm..." + while true; do + status=$(kubectl get pods -l app=helm -l name=tiller --show-all=false -o=custom-columns=STATUS:.status.phase --no-headers=true -nkube-system) + info "Helm status: $status" + if [ "$status" = "Running" ]; then + break; + fi + sleep $TIMEOUT + done +} + +function set_context() { + if [ -n "$KUBE_CONTEXT" ]; then + info "Using ${KUBE_CONTEXT} context" + kubectl config use-context ${KUBE_CONTEXT} + fi +} + +function upsert() { + helm_version=$(helm version --client --short | grep -Eo "v[0-9]\.[0-9]\.[0-9]") + tiller_version=$(timeout $TIMEOUT helm version --server --short | grep -Eo "v[0-9]\.[0-9]\.[0-9]") + + if [ -z "$tiller_version" ]; then + err "Unable to connect to helm server" + fi + + if [ "$helm_version" != "$tiller_version" ]; then + info "Helm version: $helm_version, differs with tiller version: $tiller_version" + info "Upgrarding tiller to $helm_version" + helm init --upgrade --force-upgrade > $STDOUT + wait_for_helm + sleep 3 + info "Helm version" + helm version | sed 's/^/ - /' + else + info "Helm version: $helm_version matches tiller version: $tiller_version." + info "Initializing helm client..." + helm init --client-only > $STDOUT + fi +} + +if [ "$1" == "upsert" ]; then + check kubectl + check helm + set_context + upsert +else + err "Unknown commmand" +fi diff --git a/modules/helm/Makefile b/modules/helm/Makefile index e184298d..65edbd89 100644 --- a/modules/helm/Makefile +++ b/modules/helm/Makefile @@ -19,3 +19,8 @@ helm/serve/index: $(call assert-set,HELM) @$(SELF) helm/repo/index REPO_NAME=incubator @$(SELF) helm/repo/index REPO_NAME=stable + +## Install or upgrade helm tiller +helm/toolbox/upsert: + @$(BUILD_HARNESS_PATH)/bin/helm_toolbox.sh upsert + From 3d46b7368bac608ed7247e6f065517c3e9bd7c65 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 21:57:30 -0700 Subject: [PATCH 20/25] use official release --- modules/helm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/helm/Makefile b/modules/helm/Makefile index 65edbd89..3ed8d68c 100644 --- a/modules/helm/Makefile +++ b/modules/helm/Makefile @@ -1,5 +1,5 @@ CURL := $(shell which curl) -export HELM_VERSION ?= 2.9.0-rc5 +export HELM_VERSION ?= 2.9.0 HELM_PLATFORM ?= $(OS)-amd64 HELM := $(shell which helm) HELM_HOME ?= $(HOME)/.helm From eaa06bd0d73f16c7a93c98a902cb752b5ea06251 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 22:23:34 -0700 Subject: [PATCH 21/25] add timeout --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 20e55a94..b9cd4d9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ RUN apk update && \ apk --update add \ bash \ ca-certificates \ + coreutils \ curl \ git \ gettext \ From 5f2087ebeb6bcc93f5367bd1e5077e57e3695b99 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 22:24:26 -0700 Subject: [PATCH 22/25] require timeout --- bin/helm_toolbox.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/helm_toolbox.sh b/bin/helm_toolbox.sh index 02652626..a2b2ecf5 100755 --- a/bin/helm_toolbox.sh +++ b/bin/helm_toolbox.sh @@ -63,6 +63,7 @@ function upsert() { if [ "$1" == "upsert" ]; then check kubectl check helm + check timeout set_context upsert else From 9823ca1c00e1dbd88834eaa609ffc483f338a1b0 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 22:33:55 -0700 Subject: [PATCH 23/25] use short version --- bin/helm_toolbox.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/helm_toolbox.sh b/bin/helm_toolbox.sh index a2b2ecf5..593b59fd 100755 --- a/bin/helm_toolbox.sh +++ b/bin/helm_toolbox.sh @@ -52,7 +52,7 @@ function upsert() { wait_for_helm sleep 3 info "Helm version" - helm version | sed 's/^/ - /' + helm version --short | sed 's/^/ - /' else info "Helm version: $helm_version matches tiller version: $tiller_version." info "Initializing helm client..." From e2321145250256dccfc05def2fc6c7564338cae7 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Thu, 26 Apr 2018 22:37:42 -0700 Subject: [PATCH 24/25] translate new line to comma --- bin/helm_toolbox.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/helm_toolbox.sh b/bin/helm_toolbox.sh index 593b59fd..93c9df4d 100755 --- a/bin/helm_toolbox.sh +++ b/bin/helm_toolbox.sh @@ -21,7 +21,7 @@ function check() { wait_for_helm() { info "Waiting for helm..." while true; do - status=$(kubectl get pods -l app=helm -l name=tiller --show-all=false -o=custom-columns=STATUS:.status.phase --no-headers=true -nkube-system) + status=$(kubectl get pods -l app=helm -l name=tiller --show-all=false -o=custom-columns=STATUS:.status.phase --no-headers=true -nkube-system | tr '\n' ',') info "Helm status: $status" if [ "$status" = "Running" ]; then break; From 290ffb1dd10ad3b722c649951ab9fa84c7dcc315 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 1 May 2018 10:50:12 -0700 Subject: [PATCH 25/25] Update helm_toolbox.sh --- bin/helm_toolbox.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/helm_toolbox.sh b/bin/helm_toolbox.sh index 93c9df4d..c3501842 100755 --- a/bin/helm_toolbox.sh +++ b/bin/helm_toolbox.sh @@ -17,9 +17,9 @@ function check() { command -v "$1" >/dev/null 2>&1 || err "$1 not installed!"; } -# wait helm to be operational +# wait for helm to become operational wait_for_helm() { - info "Waiting for helm..." + info "Waiting for helm tiller..." while true; do status=$(kubectl get pods -l app=helm -l name=tiller --show-all=false -o=custom-columns=STATUS:.status.phase --no-headers=true -nkube-system | tr '\n' ',') info "Helm status: $status" @@ -32,7 +32,7 @@ wait_for_helm() { function set_context() { if [ -n "$KUBE_CONTEXT" ]; then - info "Using ${KUBE_CONTEXT} context" + info "Using ${KUBE_CONTEXT} kube context" kubectl config use-context ${KUBE_CONTEXT} fi }