diff --git a/cmd/kubeadm/app/preflight/checks_darwin.go b/cmd/kubeadm/app/preflight/checks_darwin.go index 9779a5f7427..bf06ae46a72 100644 --- a/cmd/kubeadm/app/preflight/checks_darwin.go +++ b/cmd/kubeadm/app/preflight/checks_darwin.go @@ -19,6 +19,8 @@ limitations under the License. package preflight +import utilsexec "k8s.io/utils/exec" + // This is a MacOS stub // Check number of memory required by kubeadm @@ -26,3 +28,9 @@ package preflight func (mc MemCheck) Check() (warnings, errorList []error) { return nil, nil } + +// addExecChecks adds checks that verify if certain binaries are in PATH +// No-op for Darwin (MacOS). +func addExecChecks(checks []Checker, _ utilsexec.Interface, _ string) []Checker { + return checks +} diff --git a/cmd/kubeadm/app/preflight/checks_linux.go b/cmd/kubeadm/app/preflight/checks_linux.go index 1b052487250..bc1ce2683d6 100644 --- a/cmd/kubeadm/app/preflight/checks_linux.go +++ b/cmd/kubeadm/app/preflight/checks_linux.go @@ -88,5 +88,8 @@ func addExecChecks(checks []Checker, execer utilsexec.Interface, k8sVersion stri // kubelet requires mount to be present in PATH for in-tree volume plugins. checks = append(checks, InPathCheck{executable: "mount", mandatory: true, exec: execer}) + + // kubeadm requires cp to be present in PATH for copying etcd directories. + checks = append(checks, InPathCheck{executable: "cp", mandatory: true, exec: execer}) return checks } diff --git a/cmd/kubeadm/app/preflight/checks_other.go b/cmd/kubeadm/app/preflight/checks_other.go index 171d4bf80a6..d790d7d46f3 100644 --- a/cmd/kubeadm/app/preflight/checks_other.go +++ b/cmd/kubeadm/app/preflight/checks_other.go @@ -21,7 +21,6 @@ package preflight import ( system "k8s.io/system-validators/validators" - utilsexec "k8s.io/utils/exec" ) // addOSValidator adds a new OSValidator @@ -47,9 +46,3 @@ func addIPv4Checks(checks []Checker) []Checker { func addSwapCheck(checks []Checker) []Checker { return checks } - -// addExecChecks adds checks that verify if certain binaries are in PATH -// No-op for Darwin (MacOS), Windows. -func addExecChecks(checks []Checker, _ utilsexec.Interface, _ string) []Checker { - return checks -} diff --git a/cmd/kubeadm/app/preflight/checks_windows.go b/cmd/kubeadm/app/preflight/checks_windows.go index de0d52c6eca..bb5f13d5774 100644 --- a/cmd/kubeadm/app/preflight/checks_windows.go +++ b/cmd/kubeadm/app/preflight/checks_windows.go @@ -22,6 +22,7 @@ package preflight import ( "github.com/pkg/errors" "golang.org/x/sys/windows" + utilsexec "k8s.io/utils/exec" ) // Check validates if a user has elevated (administrator) privileges. @@ -38,3 +39,10 @@ func (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error) { func (mc MemCheck) Check() (warnings, errorList []error) { return nil, nil } + +// addExecChecks adds checks that verify if certain binaries are in PATH. +func addExecChecks(checks []Checker, execer utilsexec.Interface, _ string) []Checker { + // kubeadm requires xcopy to be present in PATH for copying etcd directories. + checks = append(checks, InPathCheck{executable: "xcopy", mandatory: true, exec: execer}) + return checks +} diff --git a/cmd/kubeadm/app/util/initsystem/initsystem_unix.go b/cmd/kubeadm/app/util/initsystem/initsystem_unix.go index 04c21772127..93ba9b9becb 100644 --- a/cmd/kubeadm/app/util/initsystem/initsystem_unix.go +++ b/cmd/kubeadm/app/util/initsystem/initsystem_unix.go @@ -160,6 +160,13 @@ func GetInitSystem() (InitSystem, error) { } _, err = exec.LookPath("openrc") if err == nil { + binaries := []string{"rc-service", "rc-update"} + for _, binary := range binaries { + _, err = exec.LookPath(binary) + if err != nil { + return nil, errors.Wrapf(err, "openrc detected, but missing required binary: %s", binary) + } + } return &OpenRCInitSystem{}, nil }