Skip to content

Commit 10e8e4f

Browse files
authored
Merge pull request #9165 from bengentil/ben/fix-tilt-dockerfile
🐛 tilt: ensure .tiltbuild/bin directory is created early enough, add tilt troubleshooting guide
2 parents a4cd9d1 + 8eed7dd commit 10e8e4f

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

Tiltfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,15 @@ def build_go_binary(context, reload_deps, debug, go_main, binary_name, label):
248248
live_reload_deps = []
249249
for d in reload_deps:
250250
live_reload_deps.append(context + "/" + d)
251+
252+
# Ensure the {context}/.tiltbuild/bin directory before any other resources
253+
# `local` is evaluated immediately, other resources are executed later in the startup/when triggered
254+
local("mkdir -p {context}/.tiltbuild/bin".format(context = shlex.quote(context)), quiet = True)
255+
256+
# Build the go binary
251257
local_resource(
252258
label.lower() + "_binary",
253-
cmd = "cd {context};mkdir -p .tiltbuild/bin;{build_cmd}".format(
259+
cmd = "cd {context};{build_cmd}".format(
254260
context = context,
255261
build_cmd = build_cmd,
256262
),

docs/book/src/developer/tilt.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,70 @@ syntax highlighting and auto-formatting. To enable it for Tiltfile a file associ
485485

486486
[Podman](https://podman.io) can be used instead of Docker by following these actions:
487487

488-
1. Enable the podman unix socket (eg. `systemctl --user enable --now podman.socket` on Fedora)
488+
1. Enable the podman unix socket:
489+
- on Linux/systemd: `systemctl --user enable --now podman.socket`
490+
- on macOS: create a podman machine with `podman machine init`
489491
1. Set `build_engine` to `podman` in `tilt-settings.yaml` (optional, only if both Docker & podman are installed)
490-
1. Define the env variable `DOCKER_HOST` to the right socket while running tilt (eg. `DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock tilt up`)
492+
1. Define the env variable `DOCKER_HOST` to the right socket:
493+
- on Linux/systemd: `export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock`
494+
- on macOS: `export DOCKER_HOST=$(podman machine inspect <machine> | jq -r '.[0].ConnectionInfo.PodmanSocket.Path')` where `<machine>` is the podman machine name
495+
1. Run `tilt up`
491496

492497
NB: The socket defined by `DOCKER_HOST` is used only for the `hack/tools/internal/tilt-prepare` command, the image build is running the `podman build`/`podman push` commands.
498+
499+
## Troubleshooting Tilt
500+
501+
### Tilt is stuck
502+
503+
Sometimes tilt looks stuck when it's waiting on connections.
504+
505+
Ensure that docker/podman is up and running and your kubernetes cluster is reachable.
506+
507+
### Errors running tilt-prepare
508+
509+
#### `failed to get current context from the KubeConfig file`
510+
511+
- Ensure the cluster in the default context is reachable by running `kubectl cluster-info`
512+
- Switch to the right context with `kubectl config use-context`
513+
- Ensure the context is allowed, see [**allowed_contexts** field](#tilt-settings-fields)
514+
515+
#### `Cannot connect to the Docker daemon`
516+
517+
- Ensure the docker daemon is running ;) or for podman see [Using Podman](#using-podman)
518+
- If a DOCKER_HOST is specified:
519+
- check that the DOCKER_HOST has the correct prefix (usually `unix://`)
520+
- ensure docker/podman is listening on $DOCKER_HOST using `fuser` / `lsof` / `netstat -u`
521+
522+
### Errors pulling/pushing to the registry
523+
524+
#### `connection refused` / `denied` / `not found`
525+
526+
Ensure the [**default_registry** field](#tilt-settings-fields) is a valid registry where you can pull and push images.
527+
528+
#### `server gave HTTP response to HTTPS client`
529+
530+
By default all registries except localhost:5000 are accessed via HTTPS.
531+
532+
If you run a HTTP registry you may have to configure the registry in docker/podman.
533+
534+
For example, in podman a `localhost:5001` registry configuration should be declared in `/etc/containers/registries.conf.d` with this content:
535+
````
536+
[[registry]]
537+
location = "localhost:5001"
538+
insecure = true
539+
````
540+
541+
NB: on macOS this configuration should be done **in the podman machine** by running `podman machine ssh <machine>`.
542+
543+
### Errors loading images in kind
544+
545+
You may try manually to load images in kind by running:
546+
````
547+
kind load docker-image --name=<kind_cluster> <image>
548+
````
549+
550+
#### `image: "..." not present locally`
551+
552+
If you are running podman, you may have hit this bug: https://github.com/kubernetes-sigs/kind/issues/2760
553+
554+
The workaround is to create a `docker` symlink to your `podman` executable and try to load the images again.

0 commit comments

Comments
 (0)