mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
♻️ Don't use ngrok for Tilt
ngrok now requires an account to serve HTML content. We won't use ngrok anymore for the Tilt UI (and we'll suggest to use a NodePort service instead, when running in a Pod).
This commit is contained in:
@@ -48,20 +48,25 @@ k8s_yaml('../k8s/dockercoins.yaml')
|
||||
# The following line lets Tilt run with the default kubeadm cluster-admin context.
|
||||
allow_k8s_contexts('kubernetes-admin@kubernetes')
|
||||
|
||||
# This will run an ngrok tunnel to expose Tilt to the outside world.
|
||||
# This is intended to be used when Tilt runs on a remote machine.
|
||||
local_resource(name='ngrok:tunnel', serve_cmd='ngrok http 10350')
|
||||
# Note: the whole section below (to set up ngrok tunnels) is disabled,
|
||||
# because ngrok now requires to set up an account to serve HTML
|
||||
# content. So we can still use ngrok for e.g. webhooks and "raw" APIs,
|
||||
# but not to serve web pages like the Tilt UI.
|
||||
|
||||
# This will wait until the ngrok tunnel is up, and show its URL to the user.
|
||||
# We send the output to /dev/tty so that it doesn't get intercepted by
|
||||
# Tilt, and gets displayed to the user's terminal instead.
|
||||
# Note: this assumes that the ngrok instance will be running on port 4040.
|
||||
# If you have other ngrok instances running on the machine, this might not work.
|
||||
local_resource(name='ngrok:showurl', cmd='''
|
||||
while sleep 1; do
|
||||
TUNNELS=$(curl -fsSL http://localhost:4040/api/tunnels | jq -r .tunnels[].public_url)
|
||||
[ "$TUNNELS" ] && break
|
||||
done
|
||||
printf "\nYou should be able to connect to the Tilt UI with the following URL(s): %s\n" "$TUNNELS" >/dev/tty
|
||||
'''
|
||||
)
|
||||
# # This will run an ngrok tunnel to expose Tilt to the outside world.
|
||||
# # This is intended to be used when Tilt runs on a remote machine.
|
||||
# local_resource(name='ngrok:tunnel', serve_cmd='ngrok http 10350')
|
||||
|
||||
# # This will wait until the ngrok tunnel is up, and show its URL to the user.
|
||||
# # We send the output to /dev/tty so that it doesn't get intercepted by
|
||||
# # Tilt, and gets displayed to the user's terminal instead.
|
||||
# # Note: this assumes that the ngrok instance will be running on port 4040.
|
||||
# # If you have other ngrok instances running on the machine, this might not work.
|
||||
# local_resource(name='ngrok:showurl', cmd='''
|
||||
# while sleep 1; do
|
||||
# TUNNELS=$(curl -fsSL http://localhost:4040/api/tunnels | jq -r .tunnels[].public_url)
|
||||
# [ "$TUNNELS" ] && break
|
||||
# done
|
||||
# printf "\nYou should be able to connect to the Tilt UI with the following URL(s): %s\n" "$TUNNELS" >/dev/tty
|
||||
# '''
|
||||
# )
|
||||
|
||||
@@ -210,25 +210,54 @@ Ah, right ...
|
||||
|
||||
## Running Tilt on a remote machine
|
||||
|
||||
- If Tilt runs remotely, we can't access http://localhost:10350
|
||||
- If Tilt runs remotely, we can't access `http://localhost:10350`
|
||||
|
||||
- Our Tiltfile includes an ngrok tunnel, let's use that
|
||||
- We'll need to tell Tilt to listen to `0.0.0.0`
|
||||
|
||||
- Start Tilt:
|
||||
```bash
|
||||
tilt up
|
||||
```
|
||||
(instead of just `localhost`)
|
||||
|
||||
- The ngrok URL should appear in the Tilt output
|
||||
- If we run Tilt in a Pod, we need to expose port 10350 somehow
|
||||
|
||||
(something like `https://xxxx-aa-bb-cc-dd.ngrok.io/`)
|
||||
|
||||
- Open that URL in your browser
|
||||
|
||||
*Note: it's also possible to run `tilt up --host=0.0.0.0`.*
|
||||
(and Tilt needs to listen on `0.0.0.0`, too)
|
||||
|
||||
---
|
||||
|
||||
## Telling Tilt to listen in `0.0.0.0`
|
||||
|
||||
- This can be done with the `--host` flag:
|
||||
```bash
|
||||
tilt --host=0.0.0.0
|
||||
```
|
||||
|
||||
- Or by setting the `TILT_HOST` environment variable:
|
||||
```bash
|
||||
export TILT_HOST=0.0.0.0
|
||||
tilt up
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Running Tilt in a Pod
|
||||
|
||||
If you use `shpod`, you can use the following command:
|
||||
|
||||
```bash
|
||||
kubectl patch service shpod --namespace shpod -p "
|
||||
spec:
|
||||
ports:
|
||||
- name: tilt
|
||||
port: 10350
|
||||
targetPort: 10350
|
||||
nodePort: 30150
|
||||
protocol: TCP
|
||||
"
|
||||
```
|
||||
|
||||
Then connect to port 30150 on any of your nodes.
|
||||
|
||||
If you use something else than `shpod`, adapt these instructions!
|
||||
|
||||
---
|
||||
class: extra-details
|
||||
|
||||
## Kubernetes contexts
|
||||
|
||||
Reference in New Issue
Block a user