abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
19.75k stars 397 forks source link

Unable to resolve via hostnames via Telepresence DNS #455

Open cotej opened 2 years ago

cotej commented 2 years ago

Description

Not really sure if bug or a feature request is more suitable here, but my scenario is:

Here's an example:

$ myctx='some-kube-ctx'
$ kubectl --context $myctx version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.15", GitCommit:"1d79bc3bcccfba7466c44cc2055d6e7442e140ea", GitTreeState:"clean", BuildDate:"2022-09-21T12:18:10Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.5", GitCommit:"c999fea1e6dbf111d64000dfaaff45edaa4c34d2", GitTreeState:"clean", BuildDate:"2022-01-11T12:16:14Z", GoVersion:"go1.16.12 BoringCrypto", Compiler:"gc", Platform:"linux/amd64"}

# This is expected, telepresence is not connected yet
$ curl a2.default:8081/status
curl: (6) Could not resolve host: a2.default

# Connect telepresence, verify we can get a response
$ telepresence connect --context $myctx
Connected to context some-kube-ctx (https://10.0.0.76:6443)
$ curl a2.default:8081/status
{"status":{}}%
$ wget -qO - a2.default:8081/status
{"status":{}}%

# Colima VM can't reach it
$ colima ssh -- wget -qO - a2.default:8081/status
wget: bad address 'a2.default:8081'
FATA[0000] exit status 1

# Neither can a container run by colima
$ docker run --rm alpine /bin/sh -c 'wget -qO - a2.default:8081/status'
wget: bad address 'a2.default:8081'

This works on both Docker Desktop + Rancher Desktop. I suspect there may some reasonable workaround I could do to configure the DNS for my colima VM but I'm just not sure what that might be.

Version

Colima Version:

colima version v0.4.6
git commit: 10377f3a20c2b0f7196ad5944264b69f048a3d40

runtime: docker
arch: x86_64
client: v20.10.18
server: v20.10.18

Lima Version:

limactl version 0.11.3

Qemu Version:

qemu-img version 7.1.0
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

Operating System

Reproduction Steps

See example in description above.

Expected behaviour

The colima VM and its containers should be able to resolve the host and talk to the services running inside the cluster that is connected by telepresence.

Additional context

No response

cotej commented 2 years ago

After some tinkering I've discovered that starting colima with --network-driver slirp instead of using the default gvproxy driver allows this to work. Though I'm not sure of all the implications that this carries so I'll keep this issue open for the time being.

abiosoft commented 2 years ago

@cotej there are no real implications, you can stick to slirp if it works better.

maver1ck commented 2 weeks ago

Hi @abiosoft, How this can be fixed in 2024 ? :)

abiosoft commented 1 week ago

@maver1ck what issue specifically are you having?

maver1ck commented 1 week ago

Containers in Colima are not using Kubernetes DNS when I am connected with Telepresence. This is working seamlessly in Docker desktop.

I found workaround by adding this section to Docker compose file.

    # this is needed only for colima
    dns:
      - 127.0.0.53
      - 10.0.0.10

Colima started with: colima start --vm-type vz --cpu 4 --memory 8 --network-address