tilt-dev / tilt

Define your dev environment as code. For microservice apps on Kubernetes.
https://tilt.dev/
Apache License 2.0
7.68k stars 302 forks source link

tilt ci and port_forwards #5964

Open roma-glushko opened 2 years ago

roma-glushko commented 2 years ago

My tilt setup includes port-forwarding to access microservices locally. That works great with tilt up.

When I tried to run this setup via tilt ci in the CI pipeline to get a cluster there and run some end-to-end tests, I have found out that port forwarding doesn't work and mservices are inaccessible.

After digging more into this, I can see that as long as tilt ci is running the port forwarding work, but once it's done, there is nothing that listens to the needed ports.

The current workaround is to use kubectl port-forward right after tilt ci (https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/), but I would like to know how was this case intended to work.

Expected Behavior

There is a way to keep port forwarding in CI

Current Behavior

Port forwarding seem to work for tiny bit when tilt ci is running. Then, it stops working.

Steps to Reproduce

nicks commented 2 years ago

Yes, this is what I would expect -- once tilt ci ends, all port-forwards are torn down, because there is no longer a local orchestrator to run them. Similarly, local_resource processes also halt.

Meemaw commented 1 year ago

Want to echo that running tilt ci is a fairly common pattern in CI, and having an option to keep the port forwards open after the main tilt ci command exits would be superb.

Currently, we need to workaround this by first running tilt ci, and then doing tilt up and waiting for ports to open.

jonaskello commented 1 year ago

I have a similar setup, running end-to-end tests in GitLab CI using a local DinD service. Took me a while to figure out why the ports were not open. Would be nice to have it documented in the tilt ci page that port forwards are not active after the command completes successfully.

I'm currently trying to work around it using kubectl port-forward deployment/backend 3001:3001 & to start kubectl port forwarding in the background.

I saw that tilt will start a docker container using socat if it detects that the docker daemon is remote. Perhaps there could there be something similar for local docker, like a persistent docker container that keeps the kubectl portforwards after tilt ci has exited?