Skip to content

Commit 1a71a12

Browse files
authored
vagrant: Local cluster enhancements (#110)
* Ensure image from current build is used * Fix vagrant destroy logic
1 parent cbfe8e3 commit 1a71a12

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ kube-router: $(shell find . -name \*.go) ## Builds kube-router.
2323

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

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

29-
vagrant-up-multi-node: all vagrant-destroy ## Test the current codebase in a local VM multi-node cluster
30-
@docker="$(DOCKER)" HACK_MULTI_NODE="true" hack/vagrant-up.sh
31+
vagrant-up-single-node: vagrant-up ## Test the current codebase in a local VM single-node cluster
32+
33+
vagrant-up-multi-node: export HACK_MULTI_NODE=true
34+
vagrant-up-multi-node: vagrant-up ## Test the current codebase in a local VM multi-node cluster
3135

3236
vagrant: ## Run vagrant against a previously up'd cluster. Example: make vagrant status
3337
@hack/vagrant.sh $(VAGRANT_RUN_ARGS)

hack/vagrant-common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ HACK_TMP_DIR="${HACK_DIR}/_cache"
1818
HACK_MANIFEST_DIRS="${REPO_DIR}/contrib/bootkube"
1919
export HACK_MANIFEST_DIRS
2020

21+
[ -z "${DEV_IMG}" ] && DEV_IMG="cloudnativelabs/kube-router-git:latest"
2122
[ -z "${BK_VERSION}" ] && BK_VERSION="v0.6.0_kube-router"
2223
[ -z "${BK_CLONE_URL}" ] && BK_CLONE_URL="https://github.com/bzub/bootkube.git"
2324
[ -z "${BK_CLONE_DIR}" ] && BK_CLONE_DIR="${HACK_TMP_DIR}/bootkube"

hack/vagrant-destroy.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ export HACK_DIR
88
# shellcheck source=vagrant-common.sh
99
. "${HACK_DIR}/vagrant-common.sh"
1010

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

16-
echo "INFO: Running vagrant destroy -f"
17-
cd "${BK_SHORTCUT_DIR}"
18-
vagrant destroy -f
19-
20-
echo "INFO: Removing cluster assets."
21-
rm -rf "${BK_SHORTCUT_DIR}/cluster"
16+
echo "INFO: Removing cluster assets in ${i}"
17+
rm -rf "${i}/cluster"
18+
done
2219

2320
echo "INFO: Removing symbolic link to Bootkube hack directory"
2421
rm -rf "${BK_SHORTCUT_DIR}"

hack/vagrant-up.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ fi
4242
# Export the kube-router container image
4343
echo "INFO: Exporting your kube-router container image."
4444
mkdir -p "${HACK_IMG_CACHE_DIR}"
45-
"${docker}" tag cloudnativelabs/kube-router-git:latest "${KR_IMAGE_TAG}"
46-
"${docker}" save "${KR_IMAGE_TAG}" -o "${HACK_IMG_CACHE_DIR}/kube-router.docker"
45+
eval "${docker} tag ${DEV_IMG} ${KR_IMAGE_TAG}"
46+
eval "${docker} save ${KR_IMAGE_TAG} -o ${HACK_IMG_CACHE_DIR}/kube-router.docker"
4747

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

0 commit comments

Comments
 (0)