Skip to content

Commit

Permalink
Merge pull request #7097 from Jont828/make-tilt
Browse files Browse the repository at this point in the history
🌱 Add make targets for setting up Tilt
  • Loading branch information
k8s-ci-robot authored Sep 2, 2022
2 parents fc668a4 + c40decf commit 0043155
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ CLUSTERCTL_IMG ?= $(REGISTRY)/$(CLUSTERCTL_IMAGE_NAME)
TEST_EXTENSION_IMAGE_NAME ?= test-extension
TEST_EXTENSION_IMG ?= $(REGISTRY)/$(TEST_EXTENSION_IMAGE_NAME)

# kind
CAPI_KIND_CLUSTER_NAME ?= capi-test

# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971

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

.PHONY: tilt-up
tilt-up: kind-cluster ## Start tilt and build kind cluster if needed.
tilt up

.PHONY: docker-build-e2e
docker-build-e2e: ## Rebuild all Cluster API provider images to be used in the e2e tests
$(MAKE) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
Expand Down Expand Up @@ -949,15 +956,32 @@ set-manifest-image:
##@ clean:

.PHONY: clean
clean: ## Remove all generated files
clean: ## Remove generated binaries, GitBook files, Helm charts, and Tilt build files
$(MAKE) clean-bin
$(MAKE) clean-book
$(MAKE) clean-charts
$(MAKE) clean-tilt

.PHONY: clean-kind
clean-kind: ## Cleans up the kind cluster with the name $CAPI_KIND_CLUSTER_NAME
kind delete cluster --name="$(CAPI_KIND_CLUSTER_NAME)" || true

.PHONY: clean-bin
clean-bin: ## Remove all generated binaries
rm -rf $(BIN_DIR)
rm -rf $(TOOLS_BIN_DIR)

.PHONY: clean-tilt
clean-tilt: ## Remove all files generated by Tilt
rm -rf ./.tiltbuild
rm -rf ./controlplane/kubeadm/.tiltbuild
rm -rf ./bootstrap/kubeadm/.tiltbuild
rm -rf ./test/infrastructure/docker/.tiltbuild

.PHONY: clean-charts
clean-charts: ## Remove all local copies of Helm charts in ./hack/observability
(for path in "./hack/observability/*"; do rm -rf $$path/charts ; done)

.PHONY: clean-book
clean-book: ## Remove all generated GitBook files
rm -rf ./docs/book/_book
Expand Down
22 changes: 19 additions & 3 deletions docs/book/src/developer/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ With this config, the respective managers will be invoked with:
manager --logging-format=json
```

### Run Tilt!
### Create a kind cluster and run Tilt!

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

```bash
tilt up
make tilt-up
```

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

### Cleaning up your kind cluster and development environment

After stopping Tilt, you can clean up your kind cluster and development environment by running

```bash
make clean-kind
```

To remove all generated files, run

```bash
make clean
```

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`.

<h1>Use of clusterctl</h1>

When the worker cluster has been created using tilt, `clusterctl` should not be used for management
Expand Down
9 changes: 7 additions & 2 deletions hack/kind-install-for-capd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ set -o errexit
set -o nounset
set -o pipefail

NAME=${CAPI_KIND_CLUSTER_NAME:-"capi-test"}
KIND_CLUSTER_NAME=${CAPI_KIND_CLUSTER_NAME:-"capi-test"}

if [[ "$(kind get clusters)" =~ .*"${KIND_CLUSTER_NAME}".* ]]; then
echo "kind cluster already exists, moving on"
exit 0
fi

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

# create a cluster with the local registry enabled in containerd
cat <<EOF | kind create cluster --name="$NAME" --config=-
cat <<EOF | kind create cluster --name="$KIND_CLUSTER_NAME" --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
Expand Down

0 comments on commit 0043155

Please sign in to comment.