Skip to content

Commit 0043155

Browse files
authored
Merge pull request #7097 from Jont828/make-tilt
🌱 Add make targets for setting up Tilt
2 parents fc668a4 + c40decf commit 0043155

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
@@ -176,6 +176,9 @@ CLUSTERCTL_IMG ?= $(REGISTRY)/$(CLUSTERCTL_IMAGE_NAME)
176176
TEST_EXTENSION_IMAGE_NAME ?= test-extension
177177
TEST_EXTENSION_IMG ?= $(REGISTRY)/$(TEST_EXTENSION_IMAGE_NAME)
178178

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

181184
TAG ?= dev
@@ -684,6 +687,10 @@ test-capd-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integration tests
684687
kind-cluster: ## Create a new kind cluster designed for development with Tilt
685688
hack/kind-install-for-capd.sh
686689

690+
.PHONY: tilt-up
691+
tilt-up: kind-cluster ## Start tilt and build kind cluster if needed.
692+
tilt up
693+
687694
.PHONY: docker-build-e2e
688695
docker-build-e2e: ## Rebuild all Cluster API provider images to be used in the e2e tests
689696
$(MAKE) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
@@ -949,15 +956,32 @@ set-manifest-image:
949956
##@ clean:
950957

951958
.PHONY: clean
952-
clean: ## Remove all generated files
959+
clean: ## Remove generated binaries, GitBook files, Helm charts, and Tilt build files
953960
$(MAKE) clean-bin
954961
$(MAKE) clean-book
962+
$(MAKE) clean-charts
963+
$(MAKE) clean-tilt
964+
965+
.PHONY: clean-kind
966+
clean-kind: ## Cleans up the kind cluster with the name $CAPI_KIND_CLUSTER_NAME
967+
kind delete cluster --name="$(CAPI_KIND_CLUSTER_NAME)" || true
955968

956969
.PHONY: clean-bin
957970
clean-bin: ## Remove all generated binaries
958971
rm -rf $(BIN_DIR)
959972
rm -rf $(TOOLS_BIN_DIR)
960973

974+
.PHONY: clean-tilt
975+
clean-tilt: ## Remove all files generated by Tilt
976+
rm -rf ./.tiltbuild
977+
rm -rf ./controlplane/kubeadm/.tiltbuild
978+
rm -rf ./bootstrap/kubeadm/.tiltbuild
979+
rm -rf ./test/infrastructure/docker/.tiltbuild
980+
981+
.PHONY: clean-charts
982+
clean-charts: ## Remove all local copies of Helm charts in ./hack/observability
983+
(for path in "./hack/observability/*"; do rm -rf $$path/charts ; done)
984+
961985
.PHONY: clean-book
962986
clean-book: ## Remove all generated GitBook files
963987
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
@@ -273,12 +273,12 @@ With this config, the respective managers will be invoked with:
273273
manager --logging-format=json
274274
```
275275

276-
### Run Tilt!
276+
### Create a kind cluster and run Tilt!
277277

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

280280
```bash
281-
tilt up
281+
make tilt-up
282282
```
283283

284284
This will open the command-line HUD as well as a web browser interface. You can monitor Tilt's status in either
@@ -308,6 +308,22 @@ kustomize_substitutions:
308308
WORKER_MACHINE_COUNT: 3
309309
```
310310

311+
### Cleaning up your kind cluster and development environment
312+
313+
After stopping Tilt, you can clean up your kind cluster and development environment by running
314+
315+
```bash
316+
make clean-kind
317+
```
318+
319+
To remove all generated files, run
320+
321+
```bash
322+
make clean
323+
```
324+
325+
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`.
326+
311327
<h1>Use of clusterctl</h1>
312328

313329
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)