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] - Incorrect server key in ./kube/config, no matter what #876

Closed
armenr opened this issue Dec 5, 2021 · 9 comments · Fixed by #879
Closed

[BUG] - Incorrect server key in ./kube/config, no matter what #876

armenr opened this issue Dec 5, 2021 · 9 comments · Fixed by #879
Assignees
Labels
bug Something isn't working priority/high
Milestone

Comments

@armenr
Copy link

armenr commented Dec 5, 2021

What did you do

Create the following config:

## k3d_local.yml
##
## Top-level k3d configs
apiVersion: k3d.io/v1alpha3
kind: Simple
name: localOps

## Cluster configs
servers: 3
agents: 3
kubeAPI:
  host: "myendpoint.mysubdomain.ngrok.io"
  hostIP: "127.0.0.1"
  hostPort: "6445"
image: rancher/k3s:v1.21.7-k3s1 # LATEST Kubernetes 1.22 release is v1.22.4+k3s1

## Options
options:
  ## K3D runtime settings
  k3d:
    wait: true # wait for cluster to be usable before returining; same as `--wait` (default: true)
    disableLoadbalancer: true # same as `--no-lb`
  ## K3S Options
  k3s:
    extraArgs:
      - arg: --tls-san=kube.armenr.ngrok.io
        nodeFilters:
          - server:*
  • How was the cluster created?

    • k3d cluster create --config k3d_local.yml
  • What did you do afterwards?

    • kubectl cluster-info
    • cat ~/kube/config

What did you expect to happen

  1. Expected kubectl cluster-info to return output
  2. Expected to see server: https://myendpoint.mysubdomain.ngrok.io:6445 in ~/.kube/config

Screenshots or terminal output

Checking ~/.kube/config -- you can see the problem under cluster --> server

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <REDACTED>
    server: https://host.docker.internal:6445      #!!!! This should be https://myendpoint.mysubdomain.ngrok.io:6445
  name: k3d-localops-5k
contexts:
- context:
    cluster: k3d-localops-5k
    user: admin@k3d-localops-5k
  name: k3d-localops-5k
current-context: k3d-localops-5k
kind: Config
preferences: {}
users:
- name: admin@k3d-localops-5k
  user:
    client-certificate-data: <REDACTED>
    client-key-data: <REDACTED>

Which OS & Architecture

  • MacOS 12.0.1
  • MacBook Pro 2021 - M1 Pro CPU
  • 16 GB RAM

Which version of k3d

  • output of k3d version
    k3d version v5.2.0
    k3s version v1.21.7-k3s1 (default)
    

Which version of docker

  • output of docker version and docker info
      Client:
      Cloud integration: v1.0.22
      Version:           20.10.11
      API version:       1.41
      Go version:        go1.16.10
      Git commit:        dea9396
      Built:             Thu Nov 18 00:36:09 2021
      OS/Arch:           darwin/arm64
      Context:           default
      Experimental:      true
    
      Server: Docker Engine - Community
      Engine:
        Version:          20.10.11
        API version:      1.41 (minimum version 1.12)
        Go version:       go1.16.9
        Git commit:       847da18
        Built:            Thu Nov 18 00:34:44 2021
        OS/Arch:          linux/arm64
        Experimental:     false
      containerd:
        Version:          1.4.12
        GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
      runc:
        Version:          1.0.2
        GitCommit:        v1.0.2-0-g52b36a2
      docker-init:
        Version:          0.19.0
        GitCommit:        de40ad0
    
@armenr armenr added the bug Something isn't working label Dec 5, 2021
@b-palaniappan
Copy link

I am having same issue in Windows 10. My k3d config yaml,

apiVersion: k3d.io/v1alpha3
kind: Simple
name: local-k8s
servers: 1
agents: 0
kubeAPI:
  host: "localhost"
  hostIP: "127.0.0.1"
  hostPort: "6555"
ports:
  - port: 80:80
    nodeFilters:
      - loadbalancer
options:
  kubeconfig:
    updateDefaultKubeconfig: true
    switchCurrentContext: true

and in my kube context file,

- cluster:
    certificate-authority-data: ****
    server: https://host.docker.internal:6555                        *** instead of https://localhost:6555
  name: k3d-local-k8s
$ k3d version
k3d version v5.2.0
k3s version v1.21.7-k3s1 (default)

@armenr
Copy link
Author

armenr commented Dec 6, 2021

@b-palaniappan -- if it helps at all, I'm using a small script to spin up my environment, so I just use this one-liner as a workaround for now...all you need is the yq command-line utility. :)

yq -i e '(.clusters[].cluster.server | select(. == "https://host.docker.internal:6445")) = "https://your-desired-hostname.somedomain:6445"' ~/.kube/config

@iwilltry42 iwilltry42 added this to the v5.2.1 milestone Dec 6, 2021
@iwilltry42 iwilltry42 self-assigned this Dec 6, 2021
@iwilltry42
Copy link
Member

Hi @armenr , thanks for opening this issue!
This seems to be an issue introduced just in v5.2.0 and I know where to start fixing it.
I'll release v5.2.1 today with a fix 👍

@armenr
Copy link
Author

armenr commented Dec 7, 2021

Thank you @iwilltry42 ! I'll pull down an update to test & confirm.

I appreciate the care and expedience with which you got back to us! :)

@iwilltry42
Copy link
Member

@armenr , here you go: https://github.com/rancher/k3d/releases/tag/v5.2.1-rc.0

@iwilltry42
Copy link
Member

@armenr , can you confirm that it's fixed in the RC?

@b-palaniappan
Copy link

@iwilltry42 I validated v5.2.1-rc.0 on my windows machine. Its setting up correct hostname in the kube context file in ~/.kube/config.

@iwilltry42
Copy link
Member

Thanks @b-palaniappan 🙏
Fix will then land in the next patch release 👍

@armenr
Copy link
Author

armenr commented Dec 8, 2021

Looks good! @iwilltry42

Thank you again :)

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

Successfully merging a pull request may close this issue.

3 participants