Skip to content

Commit

Permalink
vagrant: Local cluster enhancements (#110)
Browse files Browse the repository at this point in the history
* Ensure image from current build is used
* Fix vagrant destroy logic
  • Loading branch information
bzub authored Aug 8, 2017
1 parent cbfe8e3 commit 1a71a12
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ kube-router: $(shell find . -name \*.go) ## Builds kube-router.

test: gofmt ## Runs code quality pipelines (gofmt, tests, coverage, lint, etc)

vagrant-up-single-node: all vagrant-destroy ## Test the current codebase in a local VM single-node cluster
@docker="$(DOCKER)" hack/vagrant-up.sh
vagrant-up: export docker=$(DOCKER)
vagrant-up: export DEV_IMG=$(REGISTRY_DEV):$(IMG_TAG)
vagrant-up: all vagrant-destroy
@hack/vagrant-up.sh

vagrant-up-multi-node: all vagrant-destroy ## Test the current codebase in a local VM multi-node cluster
@docker="$(DOCKER)" HACK_MULTI_NODE="true" hack/vagrant-up.sh
vagrant-up-single-node: vagrant-up ## Test the current codebase in a local VM single-node cluster

vagrant-up-multi-node: export HACK_MULTI_NODE=true
vagrant-up-multi-node: vagrant-up ## Test the current codebase in a local VM multi-node cluster

vagrant: ## Run vagrant against a previously up'd cluster. Example: make vagrant status
@hack/vagrant.sh $(VAGRANT_RUN_ARGS)
Expand Down
1 change: 1 addition & 0 deletions hack/vagrant-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ HACK_TMP_DIR="${HACK_DIR}/_cache"
HACK_MANIFEST_DIRS="${REPO_DIR}/contrib/bootkube"
export HACK_MANIFEST_DIRS

[ -z "${DEV_IMG}" ] && DEV_IMG="cloudnativelabs/kube-router-git:latest"
[ -z "${BK_VERSION}" ] && BK_VERSION="v0.6.0_kube-router"
[ -z "${BK_CLONE_URL}" ] && BK_CLONE_URL="https://github.com/bzub/bootkube.git"
[ -z "${BK_CLONE_DIR}" ] && BK_CLONE_DIR="${HACK_TMP_DIR}/bootkube"
Expand Down
17 changes: 7 additions & 10 deletions hack/vagrant-destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ export HACK_DIR
# shellcheck source=vagrant-common.sh
. "${HACK_DIR}/vagrant-common.sh"

if [ ! -d "${BK_SHORTCUT_DIR}" ]; then
echo "INFO: bootkube hack shortcut not found."
exit 0
fi
for i in "${BK_CLONE_DIR}/hack/single-node" "${BK_CLONE_DIR}/hack/multi-node"; do
echo "INFO: Running vagrant destroy -f in ${i}"
cd "${i}"
vagrant destroy -f

echo "INFO: Running vagrant destroy -f"
cd "${BK_SHORTCUT_DIR}"
vagrant destroy -f

echo "INFO: Removing cluster assets."
rm -rf "${BK_SHORTCUT_DIR}/cluster"
echo "INFO: Removing cluster assets in ${i}"
rm -rf "${i}/cluster"
done

echo "INFO: Removing symbolic link to Bootkube hack directory"
rm -rf "${BK_SHORTCUT_DIR}"
4 changes: 2 additions & 2 deletions hack/vagrant-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fi
# Export the kube-router container image
echo "INFO: Exporting your kube-router container image."
mkdir -p "${HACK_IMG_CACHE_DIR}"
"${docker}" tag cloudnativelabs/kube-router-git:latest "${KR_IMAGE_TAG}"
"${docker}" save "${KR_IMAGE_TAG}" -o "${HACK_IMG_CACHE_DIR}/kube-router.docker"
eval "${docker} tag ${DEV_IMG} ${KR_IMAGE_TAG}"
eval "${docker} save ${KR_IMAGE_TAG} -o ${HACK_IMG_CACHE_DIR}/kube-router.docker"

# Copy cached images to Bootkube local-images directory
echo "INFO: Caching hyperkube images to Bootkube local-images directory."
Expand Down

0 comments on commit 1a71a12

Please sign in to comment.