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

kubeconfig files generated by k0sctl 0.18.0 use private IP of cluster nodes and ignore cluster name #734

Closed
byDimasik opened this issue Jun 24, 2024 · 3 comments

Comments

@byDimasik
Copy link

Description

k0sctl kubeconfig command on 0.18.0 generates a kubeconfig file significantly different from
the one generated by previous versions. The file generated by 0.18.0 uses the private IP of the controller node
in the server address, which makes it impossible to use the kubeconfig file to access the cluster from remote machines.

In addition, kubeconfig files generated by 0.18.0 ignore the cluster name in k0sctl.yaml file and
use Default as the context name while previous versions used the cluster name as the context name.

Steps to reproduce

  1. Deploy a k0s cluster with k0sctl (either 0.17.x or 0.18.0).
  2. Using k0sctl 0.18.0, generate a kubeconfig file with k0sctl kubeconfig.

Expected behavior

  • The resulting kubeconfig file should use the public IP of the controller node to be able to connect to the cluster
    from remote machines.
  • The resulting kubeconfig file uses context with the name equal to the cluster name in k0sctl.yaml metadata.name.

Actual behavior

  • On 0.18.0, the resulting kubeconfig file uses the private IP of the controller node,
    which makes it impossible to connect to the cluster from remote machines.
  • The context name in the kubeconfig file is Default instead of the cluster name in k0sctl.yaml metadata.name.

Comparison

Below is the k0sctl.yaml file and two kubeconfig files generated by k0sctl kubeconfig command of different k0sctl versions using that k0sctl.yaml.

apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
  name: k0s-cluster
spec:
  hosts:
    - ssh:
        address: 18.224.27.120
        keyPath: ./ssh_keys/key.pem
        port: 22
        user: ubuntu
      role: controller+worker
    - ssh:
        address: 3.14.12.211
        keyPath: ./ssh_keys/key.pem
        port: 22
        user: ubuntu
      role: worker
  k0s:
    config:
      apiVersion: k0s.k0sproject.io/v1beta1
      kind: Cluster
      metadata:
        name: k0s
      spec:
        network:
          provider: calico
        api:
          sans:
            - 5n7wa8-mke-lb-6f914ea413b1e219.elb.us-east-2.amazonaws.com
k0sctl 0.17.4 k0sctl 0.18.0
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tL<redacted>0tLQo=
    server: https://18.224.27.120:6443
  name: k0s-cluster
contexts:
- context:
    cluster: k0s-cluster
    user: admin
  name: k0s-cluster
current-context: k0s-cluster
kind: Config
preferences: {}
users:
- name: admin
  user:
    client-certificate-data: LS0tL<redacted>S0tLQo=
    client-key-data: LS0tL<redacted>0tCg==
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tL<redacted>0tLQo=
    server: https://172.31.34.85:6443
  name: local
contexts:
- context:
    cluster: local
    user: user
  name: Default
current-context: Default
kind: Config
preferences: {}
users:
- name: user
  user:
    client-certificate-data: LS0tL<redacted>0tLQo=
    client-key-data: LS0tL<redacted>0tCg==

The highlights are:

  • clusters[0].cluster.server uses the public IP from k0sctl.yaml file on 0.17.4 and the private IP on 0.18.0.
  • clusters[0].name is equal to the metadata.name in k0sctl.yaml file on 0.17.4 and local on 0.18.0.
  • contexts[0].name is equal to the metadata.name in k0sctl.yaml file on 0.17.4 and Default on 0.18.0.
  • contexts[0].context.user is admin on 0.17.4 and user on 0.18.0
@twz123
Copy link
Member

twz123 commented Jun 25, 2024

/cc #719 (comment) and following

@kke
Copy link
Contributor

kke commented Jun 25, 2024

Will be fixed by #732 once the CI problems are solved.

@kke
Copy link
Contributor

kke commented Jun 28, 2024

Fixed in 0.18.1

@kke kke closed this as completed Jun 28, 2024
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

3 participants