Merge pull request #130045 from carlory/kubeadm-exec-check

kubeadm: update preflight check
This commit is contained in:
Kubernetes Prow Robot 2025-02-11 01:21:57 -08:00 committed by GitHub
commit 3e4e2437e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 7 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}