Skip to content
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

Multiple containers in docker deploy result in extra ports being forwarded #9006

Closed
jcscottiii opened this issue Aug 10, 2023 · 1 comment · Fixed by #9008
Closed

Multiple containers in docker deploy result in extra ports being forwarded #9006

jcscottiii opened this issue Aug 10, 2023 · 1 comment · Fixed by #9008

Comments

@jcscottiii
Copy link
Contributor

I am seeing the same/similar issue reported in https://stackoverflow.com/q/73533579.
Look there for more details.

Expected behavior

Given the following config, I expect two ports to be forwarded. One for bert and one for ernie.

...
portForward:
- resourceType: container
  resourceName: bert
  port: 8080
  localPort: 9000
- resourceType: container
  resourceName: ernie
  port: 8081
  localPort: 9001

Expected output

[bert] Forwarding container port 8080 -> local port http://127.0.0.1:9000
[ernie] Forwarding container port 8081 -> local port http://127.0.0.1:9001

Actual behavior

In the output below, there are four ports exposed. Two for each container. Also the second container is exposed correctly because the first container used the port. As I add more services that are port forwarded, this problem increases.

$ skaffold dev
WARN[0000] failed to detect active kubernetes cluster node platform. Specify the correct build platform in the `skaffold.yaml` file or using the `--platform` flag  subtask=-1 task=DevLoop
Generating tags...
 - bert -> bert:bc4100080
 - ernie -> ernie:bc4100080
Checking cache...
 - bert: Found Locally
 - ernie: Found Locally
Tags used in deployment:
 - bert -> bert:ccb36787e044aaf4fc46cc0b3282771c73724e7405da67e4794e91cf25317644
 - ernie -> ernie:a85231d544a06b0bbdbe8c7603b3b14488f8611f952148a4d6b37d1ee46830a2
Starting deploy...
[bert] Forwarding container port 8080 -> local port http://127.0.0.1:9000
[bert] Forwarding container port 8081 -> local port http://127.0.0.1:9001
[ernie] Forwarding container port 8080 -> local port http://127.0.0.1:9002
[ernie] Forwarding container port 8081 -> local port http://127.0.0.1:9003
Listing files to watch...
 - bert
 - ernie
Press Ctrl+C to exit
Watching for changes...
[ernie] Hey there Bert!
[bert] Oh hey Ernie.

Information

  • Skaffold version: v2.6.0
  • Operating system: Linux
  • Installed via: skaffold.dev
  • Contents of skaffold.yaml:

https://github.com/jcscottiii/skaffold/blob/1a747b1b32c7a70d3f0f733374cd1526dbf34828/examples/docker-deploy/skaffold.yaml

Steps to reproduce the behavior

  1. a clonable repository with the sample skaffold project - I modified the examples/docker-deploy to portforward in my fork
  2. cd examples/docker-deploy && skaffold dev
jcscottiii added a commit to jcscottiii/skaffold that referenced this issue Aug 10, 2023
The tests are more brittle though
@jcscottiii
Copy link
Contributor Author

jcscottiii commented Aug 10, 2023

I have made a fix to deploy.go in a PR: #9008

And it works.

jcscottiii added a commit to jcscottiii/skaffold that referenced this issue Aug 10, 2023
Add a filter function to only send port resource resources for that particular container into AllocatePort
ericzzzzzzz pushed a commit that referenced this issue Aug 14, 2023
Add a filter function to only send port resource resources for that particular container into AllocatePort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants