Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix kubeconfig not pointing to correct host when using docker-machine #137

Merged
merged 1 commit into from
Nov 4, 2019

Conversation

M3t0r
Copy link

@M3t0r M3t0r commented Nov 4, 2019

The kubeconfig generated by docker.io/rancher/k3s:v0.10.2 or earlier sets the cluster.server address to 127.0.0.1. Previously this seems to have been localhost. And we only replace localhost with the correct address for our local kubeconfig.

The error I encountered:

$ k3d --version
k3d version v1.3.4
$ docker-machine --version
docker-machine version 0.16.1, build cce350d7
$ docker --version
Docker version 19.03.1, build 74b1e89
$ k3d create
INFO[0000] Created cluster network with ID 649d6f34b84a4df16d2524f0ea0ce69cd4f964a79ae56e2a07bb1ee11d1fce50
INFO[0001] Add TLS SAN for 192.168.99.100
INFO[0001] Created docker volume  k3d-k3s-default-images
INFO[0001] Creating cluster [k3s-default]
INFO[0001] Creating server using docker.io/rancher/k3s:v0.10.2...
INFO[0001] Pulling image docker.io/rancher/k3s:v0.10.2...
INFO[0018] SUCCESS: created cluster [k3s-default]
INFO[0018] You can now use the cluster with:

export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
kubectl cluster-info
$ export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
$ kubectl cluster-info

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server 127.0.0.1:6443 was refused - did you specify the right host or port?

The kubeconfig generated by docker.io/rancher/k3s:v0.10.2 or earlier
sets the cluster.server address to 127.0.0.1. Previously this seems to
have been localhost. And we only replace localhost with the correct
address for our local kubeconfig.

The error this can lead to:
```
$ k3d --version
k3d version v1.3.4
$ docker-machine --version
docker-machine version 0.16.1, build cce350d7
$ docker --version
Docker version 19.03.1, build 74b1e89
$ k3d create
INFO[0000] Created cluster network with ID 649d6f34b84a4df16d2524f0ea0ce69cd4f964a79ae56e2a07bb1ee11d1fce50
INFO[0001] Add TLS SAN for 192.168.99.100
INFO[0001] Created docker volume  k3d-k3s-default-images
INFO[0001] Creating cluster [k3s-default]
INFO[0001] Creating server using docker.io/rancher/k3s:v0.10.2...
INFO[0001] Pulling image docker.io/rancher/k3s:v0.10.2...
INFO[0018] SUCCESS: created cluster [k3s-default]
INFO[0018] You can now use the cluster with:

export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
kubectl cluster-info
$ export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
$ kubectl cluster-info

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server 127.0.0.1:6443 was refused - did you specify the right host or port?
```
Copy link
Contributor

@andyz-dev andyz-dev left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for contributing.

@andyz-dev andyz-dev merged commit 3fd1061 into k3d-io:master Nov 4, 2019
@M3t0r M3t0r deleted the fix-127-0-0-1-not-replaced branch November 4, 2019 20:02
@iwilltry42 iwilltry42 added the enhancement New feature or request label Nov 4, 2019
@jcrist
Copy link

jcrist commented Dec 4, 2019

Any ETA on a new release containing this fix? Currently I'm patching around it with a quick bash script, but it'd be nice to have.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants