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

Questions on connecting local docker containers to remote k8s services #3811

Closed
sexyxlyWAol opened this issue Mar 6, 2025 · 4 comments
Closed

Comments

@sexyxlyWAol
Copy link

I am trying to implement the following case:

Some services on the local docker environment, ideally configured by docker-compose. I would like to give them access to the services running on the remote k8s cluster, using :.

I have tried to use "telepresence" network (created by telepresence connect --docker --namespace xxx) for the local containers, but they didn't have access to the cluster (dns not working, and ips in the care luster also not reachable)

I have also tried telepresence docker-run to start the local containers, the containers could access the cluster, but they could not access each other.

I know there is a telepresence intercept command, but it is for directing the traffic from the cluster to local (correct me if I am wrong), but I only want local -> cluster in my use case, like a vpn.

I wonder if it is possible to achieve my requirements with telepresence. It would be great if someone can give me some instructions.

Thank you so much!

@thallgren
Copy link
Member

The containers should be able to access each-other. when started with telepresence docker-run. They all share the same network setup with --network container:<daemon container>. They also share the hybrid telepresence network.

You do need to start the containers after doing telepresence connect --docker though, because that's when the network is created. If you disconnect and reconnect, the containers must be restarted.

@sexyxlyWAol
Copy link
Author

sexyxlyWAol commented Mar 6, 2025

Thanks for your reply!

Is there a way to start the containers with docker-compose after starting telepresence? It would be much easier to manage local services. I tried setting network to telepresence, but it could not communicate to k8s. I also tried setting network mode to "container:", but it would conflict with the port exposure settings...

And, I tried adding -p for telepresence docker-run, and seems like the port binding settings are ignored. I am using version 1.21.1

Thanks again!

@thallgren
Copy link
Member

Where a docker run uses the syntax --network container:tp_xyz, you must use network-mode in compose, like this:

network-mode:
  container: tp_xyz

After a telepresence connect --docker, you can use telepresence status to see the name of the network. You can also use telepresence connect --docker --name xyz to get a shorter network name then the generated one.

@thallgren
Copy link
Member

Closing this, because this is not the forum for questions and discussion. @sexyxlyWAol you're welcome to discuss with the community in our #telepresence-oss CNCF Slack channel.

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

No branches or pull requests

2 participants