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

[BUG] Cluster created with --network=host flag creates kubeconfig with incorrect server parameter #284

Closed
jarrett-ccg opened this issue Jun 17, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jarrett-ccg
Copy link

jarrett-ccg commented Jun 17, 2020

What did you do?

Created cluster with servicelb and traefik disabled. The generated kubeconfig would not connect to the cluster without modification.

  • How was the cluster created?
    k3d create cluster --k3s-server-arg "--disable=servicelb" --k3s-server-arg "--disable=traefik" --update-kubeconfig --no-lb --network=host

  • What did you do afterwards?

ubuntu@k3d:~$ k3d get cluster
NAME          MASTERS   WORKERS
k3s-default   1         0
ubuntu@k3d:~$ k3d get node
NAME                       ROLE     CLUSTER
k3d-k3s-default-master-0   master   k3s-default
ubuntu@k3d:~$ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS               NAMES
8200fb61dc90        rancher/k3s:v1.18.3-k3s1   "/bin/k3s server --d…"   3 minutes ago       Up 3 minutes                            k3d-k3s-default-master-0
ubuntu@k3d:~$ kubectl get node
The connection to the server 0.0.0.0:45557 was refused - did you specify the right host or port?

What did you expect to happen?

Kubectl to connect to cluster. It was fixed by changing the port in kubeconfig to 6443. (See below)

Screenshots or terminal output

ubuntu@k3d:~$ cat ~/.kube/config
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJWakNCL3FBREFnRUNBZ0VBTUFvR0NDcUdTTTQ5QkFNQ01DTXhJVEFmQmdOVkJBTU1HR3N6Y3kxelpYSjIKWlhJdFkyRkFNVFU1TWpRd016Y3dOREFlRncweU1EQTJNVGN4TkRJeE5EUmFGdzB6TURBMk1UVXhOREl4TkRSYQpNQ014SVRBZkJnTlZCQU1NR0dzemN5MXpaWEoyWlhJdFkyRkFNVFU1TWpRd016Y3dOREJaTUJNR0J5cUdTTTQ5CkFnRUdDQ3FHU000OUF3RUhBMElBQkdidUNYSEtILzRxOTU4Tk5CeG8rS2YyenQ1bVdiQndxVDFkcms2THhqakwKY0toUHFkSEFCNVNKYmo3S1I2Sm1rWlRYTW56d1c0eER0amV1Q2g3QnN2V2pJekFoTUE0R0ExVWREd0VCL3dRRQpBd0lDcERBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUFvR0NDcUdTTTQ5QkFNQ0EwY0FNRVFDSUMrQ3gwUkZ5YTNuCjhGekZtSkJNT0RZZVZPcmgzSzJTNjJyTHd4cjhEZVFLQWlCZjhTK2N5WVk3dVA1WW1wbzE1UFRvM2F4M3RHUjAKOGNzaStCcUFJckdlU2c9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
    server: https://0.0.0.0:45557
  name: k3d-k3s-default
contexts:
- context:
    cluster: k3d-k3s-default
    user: admin@k3d-k3s-default
  name: k3d-k3s-default
current-context: k3d-k3s-default
kind: Config
preferences: {}
users:
- name: admin@k3d-k3s-default
  user:
    password: e6ca6474c80c5a0ce15f4e2543821e45
    username: admin
ubuntu@k3d:~$ ss -ntlp
State       Recv-Q       Send-Q              Local Address:Port                Peer Address:Port
LISTEN      0            128                     127.0.0.1:10248                    0.0.0.0:*
LISTEN      0            128                     127.0.0.1:10249                    0.0.0.0:*
LISTEN      0            128                     127.0.0.1:6444                     0.0.0.0:*
LISTEN      0            128                     127.0.0.1:46127                    0.0.0.0:*
LISTEN      0            128                     127.0.0.1:10256                    0.0.0.0:*
LISTEN      0            128                 127.0.0.53%lo:53                       0.0.0.0:*
LISTEN      0            128                       0.0.0.0:22                       0.0.0.0:*
LISTEN      0            128                     127.0.0.1:10010                    0.0.0.0:*
LISTEN      0            128                             *:10250                          *:*
LISTEN      0            128                             *:10251                          *:*
LISTEN      0            128                             *:6443                           *:*
LISTEN      0            128                             *:10252                          *:*
LISTEN      0            128                          [::]:22                          [::]:*
ubuntu@k3d:~$ sed -i 's/45557/6443/' .kube/config
ubuntu@k3d:~$ kubectl get node
NAME                       STATUS   ROLES    AGE     VERSION
k3d-k3s-default-master-0   Ready    master   6m13s   v1.18.3+k3s1

Which OS & Architecture?
Ubuntu 18.04.4 amd64

Which version of k3d?

k3d version v3.0.0-rc.3
k3s version v1.18.3-k3s1 (default)

Which version of docker?

Client:
 Version:           19.03.6
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        369ce74a3c
 Built:             Fri Feb 28 23:45:43 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.6
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       369ce74a3c
  Built:            Wed Feb 19 01:06:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.3-0ubuntu1~18.04.2
  GitCommit:
 runc:
  Version:          spec: 1.0.1-dev
  GitCommit:
 docker-init:
  Version:          0.18.0
  GitCommit:
@jarrett-ccg jarrett-ccg added the bug Something isn't working label Jun 17, 2020
@iwilltry42 iwilltry42 self-assigned this Jun 18, 2020
@iwilltry42 iwilltry42 added this to the v3.0 - FROM scratch milestone Jun 18, 2020
@iwilltry42
Copy link
Member

Hi @jarrett-ccg , thanks for opening this issue!
You're absolutely right, the random port-choosing that's behind this issue has no effect in hostNetwork mode. This is "fixed" now. Please note, that still you can only create one cluster in hostNetwork mode, since we're not changing the backend port on the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants