-
-
Notifications
You must be signed in to change notification settings - Fork 466
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
How to access services on host machine? #101
Comments
I think most of the current solutions at the moment would require some kind of support from the environment. For example, you could use a kind: Service
apiVersion: v1
metadata:
name: the-host
spec:
type: ExternalName
externalName: ds149763.mlab.com but this would require your cluster can resolve the |
Normally using |
I guess that most pods use |
Is there a way to make the cluster DNS resolve the same way as the node? |
@luisdavim , CoreDNS is quite flexible, so I guess you can tweak it in any way you like. |
Is it possible to add |
I think I have the same question – I'm connecting a Hasura deployment to a managed Postgres database which is not running inside the Kubernetes cluster. To test locally (also on macOS and using To verify I can connect, I have a pod running a I've tried:
I'm not sure if I'm even approaching the problem correctly – can anyone recommend a way to expose a host-running Postgres instance to pods inside a |
Does k3d include something comparable to |
@bitjson I'm no longer using Minikube so I can't speak as to whether it's been updated in more recent versions, but the way I tackled this when I had the problem was actually to create an alias to my I created a plist file like this and loaded it:
Then, from my pods, I just referenced 192.168.98.1 to hit services on my OS X host. Hope this helps. |
Hey @morinap – thanks for the response – to clarify, did you use this solution for accessing host machine services from a I'd prefer a cross-platform solution, but even macOS-only would be a good start. 👍 |
@bitjson Yes, that's correct - this was accessing host machine services from Definitely not a 100% ideal solution but it served as a nice stopgap for me. |
Like said above, for me editing the CoreDNS config map worked. Run: You will find the following section:
In my case I add |
@iwilltry42 would @whazor solution be a candiate implementation for #350 to consider? |
Thank you @morinap and @whazor for your help! I ended up trying both ways, and I think I've settled on something that works for now. @whazor I had trouble getting the additional For now I'm manually resolving the host IP during local deployments using helm upgrade --install release-name charts/project-name
--set postgres.externalDbUrl=postgres://user:very_insecure_postgres_password@$(docker run --rm toolbelt/dig@sha256:a39b94e87ffe3774fc37dbffab642b2817467ffa57852f740ba3eccf41afca9f +short host.docker.internal | tail -n1 | tr -d '\n'):5432/postgres Anyone know when or how often Docker for Mac changes the resolution of (Though I'd still love to be able to configure coredns to resolve |
This is how it look for me right now. I did restart the coredns pod (basically deleting it), but this was not needed. I did notice that while my pods can use the DNS, kubernetes itself does not access this host. So it is not possible to pull an image from host.docker.internal or registry.local, so I used The IP's are different per kubernetes cluster, so make sure you use the correct IP. You can double check the IP with |
While this has nothing to do with this issue, I'm curious to know, which performance issues you experience?
You're right there with your observations: all of those solutions are mostly for getting access from the outside into the cluster, not vice versa. We're sometimes using a combination of a |
I will have a look now, how we can set some value for e.g. |
@iwilltry42 I think routing to the bridge gateway should be ok, it is a prerequisite that host services are not bound to the loopback interface but usually to docker network inspect k3d-playground
[
{
"Name": "k3d-playground",
"Id": "c4e13cfa59695935752d55a97398f38bf90fff40aac8308eb76ef771b24c4a8a",
"Created": "2020-09-21T17:41:53.624705081-05:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.26.0.0/16",
"Gateway": "172.26.0.1" # this one
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {
"app": "k3d"
}
}
] |
Yep, thanks 👍 |
thanks @iwilltry42 for taking care of that issue. It's annoying ... |
Hey there 👋 Just giving an update on this: it took a little longer than usual, since I'm quite busy at work recently and yesterday I struggled setting up a proper Windows VM with nested virtualization to test the changes on Docker for Desktop. |
So by now, we're successfully adding that entry to the hosts' (i.e. k3d nodes') |
@iwilltry42 can you confirm it should allow a pod from cluster A to connect to api server in cluster B for instance ? |
@iwilltry42 sorry I missed your question last week – so far, I've noticed that bulk insert write speeds are far worse when running Postgres on Docker for Desktop when compared to the native Postgres for macOS. In my case, performance is at least 50% slower, even if I configure Docker for Desktop to use all available CPUs, memory, etc. I doubt the difference would be noticeable for most applications, but in my case, a 2x improvement in write speeds can amount to a multi-day reduction in workload processing time. So it's been important to have a host-operated Postgres instance available during development.
If I can be of any help in testing on macOS, please let me know. It looks like networking should be very similar to Docker for Desktop on Windows, but I'd be very happy to test anything you suspect may be different. |
Here's a test-release of #360 : https://github.com/rancher/k3d/releases/tag/v3.1.0-dev.0 |
Hi, I'm running
k3d
usingDocker for Mac
and i need to access a service running on the host machine (the mac). From inside a pod I can ping the dhcp address of the host, but of course this can change.Is there a static way to access the host machine?
Alternatively, I need to do this in order to access custom dns that is running on the host machine. If the dns settings of the host propagated to pods (like it does for containers running in regular docker), that would also solve my problem.
The text was updated successfully, but these errors were encountered: