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

k3d on mac "timed out waiting for cluster to start" | wrong hostname to connect to cluster #238

Open
jwmay2012 opened this issue Jun 28, 2022 · 2 comments

Comments

@jwmay2012
Copy link

Waiting 5m for Kubernetes cluster "k3d-k3s-default" to start...
timed out waiting for cluster to start: Get "https://host.docker.internal:49730/version": context deadline exceeded

When trying to start a k3d cluster on mac, ctlptl fails to detect cluster is online because it's using the docker internal name for the host machine (host.docker.internal), not the machine hostname outside of docker (localhost).

Steps to Reproduce

Install k3d and ctlptl

# https://k3d.io/v5.4.3/#installation
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
brew install tilt-dev/tap/ctlptl

ctlptl-k3d.yml

apiVersion: ctlptl.dev/v1alpha1
kind: Cluster
product: k3d
registry: ctlptl-k3d-registry
---
apiVersion: ctlptl.dev/v1alpha1
kind: Registry
name: ctlptl-k3d-registry
port: 5000

apply cluster config

ctlptl apply -f ctlptl-k3d.yml

after 5 minute timeout we get an error

...
INFO[0016] Cluster 'k3s-default' created successfully!  
INFO[0016] You can now use it like this:                
kubectl cluster-info
Switched to context "k3d-k3s-default".
Waiting 5m for Kubernetes cluster "k3d-k3s-default" to start...
timed out waiting for cluster to start: Get "https://host.docker.internal:49730/version": context deadline exceeded

However, the k8s controller is available at https://localhost:49730/version

Temporary FIx

add host.docker.internal to /etc/hosts

sudo echo "127.0.0.1  host.docker.internal" | sudo tee -a  /etc/hosts

apply command now works fully

...
INFO[0016] Cluster 'k3s-default' created successfully!  
INFO[0016] You can now use it like this:                
kubectl cluster-info
Switched to context "k3d-k3s-default".
cluster.ctlptl.dev/k3d-k3s-default created
@nicks
Copy link
Member

nicks commented Jun 28, 2022

are you able to create a cluster successfully with k3d outside of ctlptl? e.g., run k3d cluster create and kubectl cluster-info?

ctlptl uses the connection settings that k3d tells it to. The problems you're having sound a lot like this k3d bug: k3d-io/k3d#1057

@jwmay2012
Copy link
Author

I think you're right. For some reason k3d is picking host.docker.internal as a resolvable hostname for the cluster.
To get the cluster to create successfully I have to do k3d cluster create --api-port localhost:6443, or add host.docker.internal to my /etc/hosts.

My issue seems subtly different. I think their issue is that their machine is resolving host.docker.internal from the os level even with ping, but for me i get ping: cannot resolve host.docker.internal: Unknown host, which should be correct.

Is there a way to pass this --api-port option to ctlptl?
I see #224, so maybe not currently.

I guess for now, my solution is to keep the /etc/hosts fix.

sudo echo "127.0.0.1  host.docker.internal" | sudo tee -a  /etc/hosts

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