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

k0sctl kubeconfig does not use custom dataDir #510

Closed
maxkochubey opened this issue Jun 29, 2023 · 2 comments · Fixed by #536
Closed

k0sctl kubeconfig does not use custom dataDir #510

maxkochubey opened this issue Jun 29, 2023 · 2 comments · Fixed by #536
Labels
bug Something isn't working

Comments

@maxkochubey
Copy link

In case if there's custom dataDir defined for hosts[*] in k0s.yaml cluster config, for example:

k0s.yaml:

apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
  name: testk0s
spec:
  hosts:
  - role: single
    dataDir: /data/k0s
    uploadBinary: true
    files:
    - name: containerd-config
      src: ./containerd.toml
      dstDir: /etc/k0s/
      perm: "0644"
      dirPerm: null
    installFlags:
    - --debug
    ssh:
      user: testuser
      keyPath: ~/.ssh/id_ed25519
      address: k0s-single.example.com
  k0s:
    version: 1.27.2+k0s.0
    config:
      apiVersion: k0s.k0sproject.io/v1beta1
      kind: ClusterConfig
      metadata:
        name: testk0s
      spec:
        telemetry:
          enabled: false
        network:
          provider: calico
          podCIDR: 10.201.0.0/16
          serviceCIDR: 10.200.0.0/17

, k0sctl kubeconfig command fails with an error, trying to get the kubelet.conf file in default dataDir location:

# k0sctl kubeconfig --config k0s.yaml
level=fatal msg="read kubeconfig from host: remote exec error: failed to read file /var/lib/k0s/kubelet.conf: command failed: client exec: ssh session wait: Process exited with status 1"

k0sctl kubeconfig should respect the dataDir parameter values for control-plane host(s) or have the argument to override it.

For now, the only option to get a kubeconfig after the cluster have been deployed is something like

ssh -i ~/.ssh/id_ed25519 [email protected] \
"sudo /usr/local/bin/k0s kubeconfig --data-dir /data/k0s admin" > kube.config
@kke kke added the bug Something isn't working label Jun 29, 2023
@kke
Copy link
Contributor

kke commented Jun 29, 2023

This may or may not fix itself for upcoming k0s versions due to k0sproject/k0s#3072 but of course it should be made to work for other versions through k0sctl.

@kke
Copy link
Contributor

kke commented Aug 7, 2023

Note to self, check if #527 is related

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

Successfully merging a pull request may close this issue.

2 participants