Azure / draft-classic

A tool for developers to create cloud-native applications on Kubernetes.
https://draft.sh
MIT License
3.92k stars 396 forks source link

Draft connect mode that exports to env #659

Closed technosophos closed 6 years ago

technosophos commented 6 years ago

It would be cool to be able to do $(draft connect --env-export) and have DRAFT_URL set automatically so we could do:

$ $(draft connect --env-export)
$ curl $DRAFT_URL/my/path

$DRAFT_PORT might also be nice to have there.

I haven't thought through the details, given multi-connect. Maybe we'd have to do something like:

DRAFT_URL_1=http://localhost:11234
DRAFT_PORT_1=11234
DRAFT_URL_2=http://localhost:4444
DRAFT_PORT_2=4444

Or something like that.

Anyway, just a rough draft of an idea floating around as I build apps with Draft. 🎆

radu-matei commented 6 years ago

Do you want to use this in an automated way (say a Brigade job?)

bacongobbler commented 6 years ago

Yeah. We also floated an idea about something similar last week with introducing a draft connect --detach and a draft disconnect commands, which is a similar workflow to what @technosophos is describing.

My only two cents here would be

  1. draft connect --detach should keep the tunnels open in the background
  2. draft connect --detach a second time should fail saying a connection's already been opened (or just re-display the previously opened tunnels)
  3. this also needs to provide PowerShell support for Windows users

Similar commands in this space are minikube docker-env, gofish tank and docker-machine env.

bacongobbler commented 6 years ago

Oh, as for the multi-port issue, how about following the same convention Kubernetes does? e.g. draft connect --detach will export port variables as

EXAMPLE_GO_SERVICE_HOST=http://localhost
EXAMPLE_GO_SERVICE_PORT=11234
EXAMPLE_PYTHON_SERVICE_HOST=http://localhost
EXAMPLE_PYTHON_SERVICE_PORT=11235

That would make the dev experience from testing apps in-cluster to testing with Draft much smoother.

bacongobbler commented 6 years ago

closed via #701