-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add helmfile * Add chamber * add distro * install distro * use yq to rewrite yaml; do not templatize yaml * use https * fix docker image * concise errors * fix typo * install all dependencies * add ca-certificates * rename distro to packages * pin to release * add gettext for envsubst * disable go-deps due to 404 * re-enable deps-dev * Upgrade helm * move helm version * add upsert * use official release * add timeout * require timeout * use short version * translate new line to comma * Update helm_toolbox.sh
- Loading branch information
Showing
7 changed files
with
136 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/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 for helm to become operational | ||
wait_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" | ||
if [ "$status" = "Running" ]; then | ||
break; | ||
fi | ||
sleep $TIMEOUT | ||
done | ||
} | ||
|
||
function set_context() { | ||
if [ -n "$KUBE_CONTEXT" ]; then | ||
info "Using ${KUBE_CONTEXT} kube 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 --short | 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 | ||
check timeout | ||
set_context | ||
upsert | ||
else | ||
err "Unknown commmand" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CURL := $(shell which curl) | ||
CHAMBER_VERSION ?= 2.0.0 | ||
CHAMBER := $(shell which chamber) | ||
|
||
## Install chamber | ||
chamber/install: packages/install/chamber | ||
@exit 0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CURL := $(shell which curl) | ||
HELMFILE_VERSION ?= 0.12.0 | ||
HELMFILE := $(shell which helm) | ||
|
||
## Install helmfile | ||
helmfile/install: packages/install/helmfile packages/install/kubectl packages/install/helm | ||
@exit 0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export INSTALL_PATH ?= $(BUILD_HARNESS_PATH)/vendor | ||
export PACKAGES_VERSION ?= 0.1.0 | ||
export PACKAGES_PATH ?= $(BUILD_HARNESS_PATH)/vendor/packages | ||
|
||
## Install packages | ||
packages/install: | ||
@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 $(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/,,$@) |