Skip to content

Commit d3db149

Browse files
feat: using localhost configuration (#28)
we don't need to setup ssh keys if we use the localhost configuration. i really don't know how i manage to get this far without realising this but this hugely simplifies the code.
1 parent 0a681ed commit d3db149

File tree

2 files changed

+11
-120
lines changed

2 files changed

+11
-120
lines changed

pkg/config/config.go

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import (
1717
"github.com/k0sproject/dig"
1818
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
1919
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster"
20+
"github.com/k0sproject/rig"
2021
"github.com/sirupsen/logrus"
2122
"gopkg.in/yaml.v2"
2223

2324
"github.com/replicatedhq/helmvm/pkg/defaults"
2425
"github.com/replicatedhq/helmvm/pkg/infra"
25-
"github.com/replicatedhq/helmvm/pkg/ssh"
2626
)
2727

2828
// ReadConfigFile reads the cluster configuration from the provided file.
@@ -307,28 +307,17 @@ func generateConfigForHosts(lb string, hosts ...*cluster.Host) (*v1beta1.Cluster
307307
// renderSingleNodeConfig renders a configuration to allow k0sctl to install in the localhost
308308
// in a single-node configuration.
309309
func renderSingleNodeConfig(ctx context.Context) (*v1beta1.Cluster, error) {
310-
usr, err := user.Current()
311-
if err != nil {
312-
return nil, fmt.Errorf("unable to get current user: %w", err)
313-
}
314-
if err := ssh.AllowLocalSSH(); err != nil {
315-
return nil, fmt.Errorf("unable to allow localhost SSH: %w", err)
316-
}
317-
ipaddr, err := defaults.PreferredNodeIPAddress()
318-
if err != nil {
319-
return nil, fmt.Errorf("unable to get preferred node IP address: %w", err)
320-
}
321-
host := &hostcfg{
322-
Address: ipaddr,
323-
Role: "controller+worker",
324-
Port: 22,
325-
User: usr.Username,
326-
KeyPath: defaults.SSHKeyPath(),
327-
}
328-
if err := host.testConnection(); err != nil {
329-
return nil, fmt.Errorf("unable to connect to %s: %w", ipaddr, err)
310+
rhost := &cluster.Host{
311+
Role: "controller+worker",
312+
UploadBinary: true,
313+
NoTaints: true,
314+
InstallFlags: []string{"--disable-components konnectivity-server"},
315+
Connection: rig.Connection{
316+
Localhost: &rig.Localhost{
317+
Enabled: true,
318+
},
319+
},
330320
}
331-
rhost := host.render()
332321
return generateConfigForHosts("", rhost)
333322
}
334323

pkg/ssh/ssh.go

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)