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

feat: Enable local docker ip in for communication with outside k3d #11350

Conversation

devops-42
Copy link
Contributor

Motivation

This PR introduces the possibility to connect to services outside the k3d cluster used in DevContainer by setting up a distinct hostname.

Modifications

The magic hostname host.docker.internal is re-used and injected in the devcontainer.json and the CoreDNS configmap.

Verification

Within the same Docker environment a Web container running nginx has been created. After that, VSCode with DevContainer is started. When DevContainer is up and running, exec a shell in a pod and issue:

kubectl exec -ti deploy/minio -- curl -v telnet://host.docker.internal:80
* Rebuilt URL to: telnet://host.docker.internal:80/
*   Trying 172.17.0.1...
* TCP_NODELAY set
* Connected to host.docker.internal (172.17.0.1) port 80 (#0)

Signed-off-by: Matthias Dietz <m.dietz@ewerk.com>
Signed-off-by: Matthias Dietz <m.dietz@ewerk.com>
@devops-42 devops-42 changed the title Feature/enable local docker ip in for communication with outside k3d feat: Enable local docker ip in for communication with outside k3d Jul 13, 2023
Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Joibel @tczhao Could you help review this?

@terrytangyuan
Copy link
Member

@devops-42 Please sign-off your commits.

@devops-42 devops-42 force-pushed the feature/enable-local-docker-ip-in-for-communication-with-outside-k3d branch from 1e6356a to 27999f7 Compare July 13, 2023 13:49
@devops-42
Copy link
Contributor Author

@terrytangyuan Commits are signed off now.

@terrytangyuan
Copy link
Member

Thanks. Let's wait for others to review.

Copy link
Member

@Joibel Joibel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks sane enough, but I think there should be some documentation added to docs/running-locally.md to explain that this is possible and why you might want to use it.

I suppose I'm not sure of the use case that this really helps with that just running the same thing inside k3d doesn't. Documentation is needed anyway, but explaining when to use it may help me understand it too.

Signed-off-by: Matthias Dietz <m.dietz@ewerk.com>
Signed-off-by: Matthias Dietz <m.dietz@ewerk.com>
@devops-42
Copy link
Contributor Author

@Joibel Thanks for your comments! I have added some documentation which hopefully should clarify the use-case.

Copy link
Member

@Joibel Joibel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Joibel
Copy link
Member

Joibel commented Jul 13, 2023

@devops-42 thank you for contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants