Skip to content

Commit c40decf

Browse files
committed
Add make targets for Tilt, kind, and clean up
1 parent 0017077 commit c40decf

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ CLUSTERCTL_IMG ?= $(REGISTRY)/$(CLUSTERCTL_IMAGE_NAME)
175175
TEST_EXTENSION_IMAGE_NAME ?= test-extension
176176
TEST_EXTENSION_IMG ?= $(REGISTRY)/$(TEST_EXTENSION_IMAGE_NAME)
177177

178+
# kind
179+
CAPI_KIND_CLUSTER_NAME ?= capi-test
180+
178181
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
179182

180183
TAG ?= dev
@@ -669,6 +672,10 @@ test-capd-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integration tests
669672
kind-cluster: ## Create a new kind cluster designed for development with Tilt
670673
hack/kind-install-for-capd.sh
671674

675+
.PHONY: tilt-up
676+
tilt-up: kind-cluster ## Start tilt and build kind cluster if needed.
677+
tilt up
678+
672679
.PHONY: docker-build-e2e
673680
docker-build-e2e: ## Rebuild all Cluster API provider images to be used in the e2e tests
674681
$(MAKE) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
@@ -934,15 +941,32 @@ set-manifest-image:
934941
##@ clean:
935942

936943
.PHONY: clean
937-
clean: ## Remove all generated files
944+
clean: ## Remove generated binaries, GitBook files, Helm charts, and Tilt build files
938945
$(MAKE) clean-bin
939946
$(MAKE) clean-book
947+
$(MAKE) clean-charts
948+
$(MAKE) clean-tilt
949+
950+
.PHONY: clean-kind
951+
clean-kind: ## Cleans up the kind cluster with the name $CAPI_KIND_CLUSTER_NAME
952+
kind delete cluster --name="$(CAPI_KIND_CLUSTER_NAME)" || true
940953

941954
.PHONY: clean-bin
942955
clean-bin: ## Remove all generated binaries
943956
rm -rf $(BIN_DIR)
944957
rm -rf $(TOOLS_BIN_DIR)
945958

959+
.PHONY: clean-tilt
960+
clean-tilt: ## Remove all files generated by Tilt
961+
rm -rf ./.tiltbuild
962+
rm -rf ./controlplane/kubeadm/.tiltbuild
963+
rm -rf ./bootstrap/kubeadm/.tiltbuild
964+
rm -rf ./test/infrastructure/docker/.tiltbuild
965+
966+
.PHONY: clean-charts
967+
clean-charts: ## Remove all local copies of Helm charts in ./hack/observability
968+
(for path in "./hack/observability/*"; do rm -rf $$path/charts ; done)
969+
946970
.PHONY: clean-book
947971
clean-book: ## Remove all generated GitBook files
948972
rm -rf ./docs/book/_book

docs/book/src/developer/tilt.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ With this config, the respective managers will be invoked with:
262262
manager --logging-format=json
263263
```
264264

265-
### Run Tilt!
265+
### Create a kind cluster and run Tilt!
266266

267-
To launch your development environment, run
267+
To create a pre-configured kind cluster (if you have not already done so) and launch your development environment, run
268268

269269
```bash
270-
tilt up
270+
make tilt-up
271271
```
272272

273273
This will open the command-line HUD as well as a web browser interface. You can monitor Tilt's status in either
@@ -297,6 +297,22 @@ kustomize_substitutions:
297297
WORKER_MACHINE_COUNT: 3
298298
```
299299

300+
### Cleaning up your kind cluster and development environment
301+
302+
After stopping Tilt, you can clean up your kind cluster and development environment by running
303+
304+
```bash
305+
make clean-kind
306+
```
307+
308+
To remove all generated files, run
309+
310+
```bash
311+
make clean
312+
```
313+
314+
Note that you must run `make clean` or `make clean-charts` to fetch new versions of charts deployed using `deploy_observability` in `tilt-settings.yaml`.
315+
300316
<h1>Use of clusterctl</h1>
301317

302318
When the worker cluster has been created using tilt, `clusterctl` should not be used for management

hack/kind-install-for-capd.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ set -o errexit
2626
set -o nounset
2727
set -o pipefail
2828

29-
NAME=${CAPI_KIND_CLUSTER_NAME:-"capi-test"}
29+
KIND_CLUSTER_NAME=${CAPI_KIND_CLUSTER_NAME:-"capi-test"}
30+
31+
if [[ "$(kind get clusters)" =~ .*"${KIND_CLUSTER_NAME}".* ]]; then
32+
echo "kind cluster already exists, moving on"
33+
exit 0
34+
fi
3035

3136
# create registry container unless it already exists
3237
reg_name='kind-registry'
@@ -39,7 +44,7 @@ if [ "${running}" != 'true' ]; then
3944
fi
4045

4146
# create a cluster with the local registry enabled in containerd
42-
cat <<EOF | kind create cluster --name="$NAME" --config=-
47+
cat <<EOF | kind create cluster --name="$KIND_CLUSTER_NAME" --config=-
4348
kind: Cluster
4449
apiVersion: kind.x-k8s.io/v1alpha4
4550
nodes:

0 commit comments

Comments
 (0)