Skip to content

Commit

Permalink
Replace reading admin.conf with reading output of "k0s kubeconfig admin"
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <[email protected]>
  • Loading branch information
kke committed Jun 26, 2024
1 parent 6075a89 commit 22c5bd2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion phase/get_kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"fmt"
"strings"

"github.com/alessio/shellescape"
"github.com/k0sproject/dig"
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster"
"github.com/k0sproject/rig/exec"
"gopkg.in/yaml.v2"
"k8s.io/client-go/tools/clientcmd"
)
Expand All @@ -22,7 +24,11 @@ func (p *GetKubeconfig) Title() string {
}

var readKubeconfig = func(h *cluster.Host) (string, error) {
return h.Configurer.ReadFile(h, h.Configurer.KubeconfigPath(h, h.K0sDataDir()))
output, err := h.ExecOutput(h.Configurer.K0sCmdf("kubeconfig admin --data-dir=%s", shellescape.Quote(h.K0sDataDir())), exec.Sudo(h))
if err != nil {
return "", fmt.Errorf("get kubeconfig from host: %w", err)
}
return output, nil
}

var k0sConfig = func(h *cluster.Host) (dig.Mapping, error) {
Expand Down

0 comments on commit 22c5bd2

Please sign in to comment.