diff --git a/Tiltfile b/Tiltfile index 5084cd456cef..54af4fbc7292 100644 --- a/Tiltfile +++ b/Tiltfile @@ -45,6 +45,8 @@ providers = { "exp", "feature", ], + "label": "CAPI", + "manager_name": "capi-controller-manager", }, "kubeadm-bootstrap": { "context": "bootstrap/kubeadm", @@ -57,6 +59,8 @@ providers = { "../../go.mod", "../../go.sum", ], + "label": "CABPK", + "manager_name": "capi-kubeadm-bootstrap-controller-manager", }, "kubeadm-control-plane": { "context": "controlplane/kubeadm", @@ -69,6 +73,8 @@ providers = { "../../go.mod", "../../go.sum", ], + "label": "KCP", + "manager_name": "capi-kubeadm-control-plane-controller-manager", }, "docker": { "context": "test/infrastructure/docker", @@ -90,6 +96,8 @@ RUN wget -qO- https://dl.k8s.io/v1.21.2/kubernetes-client-linux-amd64.tar.gz | t "additional_docker_build_commands": """ COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl """, + "label": "CAPD", + "manager_name": "capd-controller-manager", }, } @@ -153,6 +161,7 @@ def enable_provider(name): context = p.get("context") go_main = p.get("go_main", "main.go") + label = p.get("label", name) # Prefix each live reload dependency with context. For example, for if the context is # test/infra/docker and main.go is listed as a dep, the result is test/infra/docker/main.go. This adjustment is @@ -164,9 +173,10 @@ def enable_provider(name): # Set up a local_resource build of the provider's manager binary. The provider is expected to have a main.go in # manager_build_path or the main.go must be provided via go_main option. The binary is written to .tiltbuild/manager. local_resource( - name + "_manager", + label.lower() + "_binary", cmd = "cd " + context + ';mkdir -p .tiltbuild;CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \'-extldflags "-static"\' -o .tiltbuild/manager ' + go_main, deps = live_reload_deps, + labels = [label, "ALL.binaries"], ) additional_docker_helper_commands = p.get("additional_docker_helper_commands", "") @@ -210,6 +220,14 @@ def enable_provider(name): yaml = str(kustomize_with_envsubst(context + "/config/default")) k8s_yaml(blob(yaml)) + manager_name = p.get("manager_name") + if manager_name: + k8s_resource( + workload = manager_name, + new_name = label.lower() + "_controller", + labels = [label, "ALL.controllers"], + ) + # Users may define their own Tilt customizations in tilt.d. This directory is excluded from git and these files will # not be checked in to version control. def include_user_tilt_files(): diff --git a/docs/book/src/developer/tilt.md b/docs/book/src/developer/tilt.md index ea1ab057389a..93702a42d92a 100644 --- a/docs/book/src/developer/tilt.md +++ b/docs/book/src/developer/tilt.md @@ -258,6 +258,12 @@ Set to `false` if your provider does not have a ./config folder or you do not wa **go_main** (String, default="main.go"): The go main file if not located at the root of the folder +**label** (String, default=provider name): The label to be used to group provider components in the tilt UI +in tilt version >= v0.22.2 (see https://blog.tilt.dev/2021/08/09/resource-grouping.html); as a convention, +provider abbreviation should be used (CAPD, KCP etc.). + +**manager_name** (String): If provided, it will allow tilt to move the provider controller under the above label. + ## Customizing Tilt If you need to customize Tilt's behavior, you can create files in cluster-api's `tilt.d` directory. This file is ignored