Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ providers = {
"exp",
"feature",
],
"label": "CAPI",
"manager_name": "capi-controller-manager",
},
"kubeadm-bootstrap": {
"context": "bootstrap/kubeadm",
Expand All @@ -57,6 +59,8 @@ providers = {
"../../go.mod",
"../../go.sum",
],
"label": "CABPK",
"manager_name": "capi-kubeadm-bootstrap-controller-manager",
},
"kubeadm-control-plane": {
"context": "controlplane/kubeadm",
Expand All @@ -69,6 +73,8 @@ providers = {
"../../go.mod",
"../../go.sum",
],
"label": "KCP",
"manager_name": "capi-kubeadm-control-plane-controller-manager",
},
"docker": {
"context": "test/infrastructure/docker",
Expand All @@ -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",
},
}

Expand Down Expand Up @@ -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
Expand All @@ -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", "")
Expand Down Expand Up @@ -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():
Expand Down
6 changes: 6 additions & 0 deletions docs/book/src/developer/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down