Skip to content

Commit

Permalink
add archlinux support
Browse files Browse the repository at this point in the history
Signed-off-by: erdii <[email protected]>
  • Loading branch information
erdii committed Aug 9, 2021
1 parent 9a52d76 commit 92ae1b0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
16 changes: 16 additions & 0 deletions config/cluster/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,22 @@ func (h *Host) NeedIPTables() bool {
return !h.Configurer.CommandExist(h, "iptables")
}

// NeedInetUtils returns true when the inetutils package is needed on the host to run `hostname`.
// Placing this check here is kind of meh because this package probably only exists on arch.
func (h *Host) NeedInetUtils() bool {
// Windows does not need inetutils
if h.Configurer.Kind() == "windows" {
return false
}

// Only arch has/needs this package.
if h.OSVersion.IDLike != "arch" {
return false
}

return !h.Configurer.CommandExist(h, "inetutils")
}

// WaitKubeAPIReady blocks until the local kube api responds to /version
func (h *Host) WaitKubeAPIReady() error {
// If the anon-auth is disabled on kube api the version endpoint will give 401
Expand Down
25 changes: 25 additions & 0 deletions configurer/linux/archlinux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package linux

import (
"github.com/k0sproject/k0sctl/configurer"
"github.com/k0sproject/rig"
"github.com/k0sproject/rig/os/linux"
"github.com/k0sproject/rig/os/registry"
)

// ArchlinuxARM provides OS support for ArchlinuxARM systems
type ArchlinuxARM struct {
linux.ArchlinuxARM
configurer.Linux
}

func init() {
registry.RegisterOSModule(
func(os rig.OSVersion) bool {
return os.IDLike == "arch"
},
func() interface{} {
return &ArchlinuxARM{}
},
)
}
4 changes: 4 additions & 0 deletions phase/prepare_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (p *PrepareHosts) prepareHost(h *cluster.Host) error {
pkgs = append(pkgs, "iptables")
}

if h.NeedInetUtils() {
pkgs = append(pkgs, "inetutils")
}

if len(pkgs) > 0 {
log.Infof("%s: installing packages (%s)", h, strings.Join(pkgs, ", "))
if err := h.Configurer.InstallPackage(h, pkgs...); err != nil {
Expand Down

0 comments on commit 92ae1b0

Please sign in to comment.