Skip to content

Change the default behavior to forward ports? #4163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ashconnell opened this issue May 13, 2020 · 16 comments · Fixed by #4832 or #5554
Closed

Change the default behavior to forward ports? #4163

ashconnell opened this issue May 13, 2020 · 16 comments · Fixed by #4832 or #5554
Assignees
Labels
area/portforward fixit kind/feature-request kind/friction Issues causing user pain that do not have a workaround needs-design-proposal priority/p1 High impact feature/bug.
Milestone

Comments

@ashconnell
Copy link

Expected behavior

Running skaffold dev would bind user-defined port-forwarding by default - OR - allow you to configure it to be bound automatically without the need for the --port-forward argument.

Actual behavior

I couldn't find a way to do this. Additionally, I tried defining them in a profile that auto-activates but the ports still don't forward without adding the --port-forward argument.

Information

Running skaffold dev is expected to start a development environment, but the default functionality is that you can't interact with any of the services you are developing and the user-defined port forwarding rules are ignored?

I may have missed the intended way of doing this

@dgageot
Copy link
Contributor

dgageot commented May 13, 2020

--port-forward has to be set to true manually, on the command line. Is that pointless, I don't know... It used to be on by default but people found that too intrusive.

@ashconnell
Copy link
Author

ashconnell commented May 13, 2020

I wonder if the reason they find it intrusive was due to auto port forwarding as opposed to the user defined port forwards.

I'm curious how people are developing applications if they can't access them.

The two common use cases I would have assumed are Websites and API's

Websites need a port forwarded so that you can view it in the browser while developing.

API's need the port forwarded so the website can make requests to it.

So when I say pointless, i'm thinking from this point of view. skaffold dev does nothing for almost everything i've ever built without the --port-forward arg.

I might be in the minority and people are using skaffold for completely different use-cases?

@dgageot
Copy link
Contributor

dgageot commented May 13, 2020

For eg, users that develop with Docker Desktop have automatic port forwarding so they don't need skaffold to start its own.

@ashconnell
Copy link
Author

ashconnell commented May 14, 2020

FWIW I would prefer skaffold dev to:

  1. By default forward no ports
  2. If there are user defined ports in the skaffold.yaml file then forward them (if you don't want them don't add them)
  3. If autoPortForwarding (or some other field) is true in skaffold.yaml then forward ports for all services automatically (if you don't want this don't enable it)

All of this helps to create a simple workflow. You configure everything in the skaffold file and then a simple skaffold dev lets you start developing and skaffold run lets you deploy a production build.

I guess i'm spoiled by the npm ecosystem, javascript devs set things up in their package.json file, hide all the configuration in source control and use simple commands for development and deployment

@thclark
Copy link

thclark commented May 14, 2020

Oh my god! Finally! I could no figure out for the life of me why I couldn't access any of my services.

Yup, absolutely second @ashconnell - if skaffold aims to be simple enough for junior developers (and senior developers like me 😢 ), rather than devops engineers, I think this'd be helpful as a default. Because I was looking at all the files in my k8s directory and going "But the ports are mapped! Why no worky!!!".

If not possible (or wise) to reintroduce as a default, making this settable (like option 3 in the above comment) and adding that to the getting-started examples (so people like me pick up on that being a thing we need to do) would be a very good compromise :)

@tstromberg tstromberg changed the title Skaffold dev has pointless default? Change the default behavior to forward ports? May 18, 2020
@nkubala nkubala removed the triage/discuss Items for discussion label Jun 15, 2020
@nkubala
Copy link
Contributor

nkubala commented Jun 15, 2020

I think we probably want to keep the default the way it is right now (port forwarding OFF by default), but I also understand that it isn't great UX to have to provide the --port-forward flag just to get any forwarding to happen. I'd be ok adding a portForward or autoPortForward boolean to the deploy section of the skaffold.yaml to give devs a "happy path" for running skaffold dev with the behavior they expect.

@briandealwis also had the idea of changing the --port-forward flag to accept the list of resources users want to see automatically forwarded - so something like --port-forward=pods,services to automatically forward all pods and services, or --port-forward=services,manual to honor user-defined forwarding supplemented with automatic forwarding of all services. something that can happen independently of configuring port forwarding through the skaffold.yaml though.

@nkubala nkubala added area/portforward help wanted We would love to have this done, but don't have the bandwidth, need help from contributors kind/feature-request priority/p2 May take a couple of releases and removed kind/design discussion labels Jun 15, 2020
@ashconnell
Copy link
Author

I'm all for this improvement :P

Every time i come back to a skaffold project i run skaffold dev and then stumble around remembering whether it was --forward-ports or --port-forwarding or something just to get the dev environment up.

Much better to have this configuration in the code itself!

@briandealwis
Copy link
Member

briandealwis commented Jul 20, 2020

We could also add a debug option to allow forwarding debug ports (these are identified in the debug metadata added as an annotation). That would avoid us magically port-forwarding all pod containerPorts when in debug mode (e.g., port 8080).

My suggested values would be:

  • "pods": all containerPorts
  • services
  • user: the portForwards listed in the skaffold.yaml
  • debug: an internal port strategy
  • none: no ports are ever forwarded

I'd suggest that we'd default to user. Maybe service too?

@briandealwis briandealwis self-assigned this Jul 20, 2020
@tejal29
Copy link
Contributor

tejal29 commented Jul 21, 2020

Note: This issue GoogleCloudPlatform/cloud-code-vscode-internal#2155 is p1 and we should probably also mark it as p1.

@briandealwis briandealwis added kind/friction Issues causing user pain that do not have a workaround needs-design-proposal priority/p1 High impact feature/bug. and removed july-chill help wanted We would love to have this done, but don't have the bandwidth, need help from contributors priority/p2 May take a couple of releases labels Jul 31, 2020
@blaggacao
Copy link

blaggacao commented Aug 31, 2020

I thought for more than one week now this was a bug. Glad that it's just friction, though. 😄 — based on my intuitive judgment of what skaffold dev would do.

When somebody decides to work on this: as a collateral, those should be valid URLs — so they are clickable in some terminals:
image

@nkubala nkubala added this to the Backlog [P0/P1] milestone Sep 1, 2020
@nkubala nkubala modified the milestones: Backlog [P0/P1], v1.21.0-rc Feb 16, 2021
@briandealwis briandealwis modified the milestones: v1.21.0, v1.22.0 Mar 22, 2021
@maingoh
Copy link

maingoh commented Oct 4, 2021

What about the autoPortForward boolean in the skaffold.yaml, do you have any plan to add it ? It is not so confortable to specify the flag everytime :(
I would be open to contribute !

@briandealwis
Copy link
Member

@maingoh what flag are you having to specify?

If you are wanting to forward specific resources, you can setup user-defined portForward entries in your skaffold.yaml

@maingoh
Copy link

maingoh commented Oct 4, 2021

From my understanding, the user defined entries is not automatic, in the sense that I have to tell which service and which port to use. Ideally I would like to tell in the yaml that when I run skaffold dev it automatically exposes the services as well, just like when doing skaffold dev --port-forward but is a bit long to type.

@briandealwis
Copy link
Member

briandealwis commented Oct 4, 2021

The user-defined port-forwards are automatically enabled, but you do have to configure them up-front. I've opened the following issue:

@maingoh
Copy link

maingoh commented Oct 4, 2021

Exactly, I would like to avoid to configure them. The issue seem to perfectly address my need :)

@tejal29
Copy link
Contributor

tejal29 commented Oct 14, 2021

Closing this as dupe of #6672

@tejal29 tejal29 reopened this Oct 14, 2021
@tejal29 tejal29 closed this as completed Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/portforward fixit kind/feature-request kind/friction Issues causing user pain that do not have a workaround needs-design-proposal priority/p1 High impact feature/bug.
Projects
None yet
9 participants