mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
kubeadm: update preflight check
Co-authored-by: Yusuke Abe <chansuke0@gmail.com> Signed-off-by: carlory <baofa.fan@daocloud.io>
This commit is contained in:
parent
69ab91a5c5
commit
4facb87224
@ -19,6 +19,8 @@ limitations under the License.
|
|||||||
|
|
||||||
package preflight
|
package preflight
|
||||||
|
|
||||||
|
import utilsexec "k8s.io/utils/exec"
|
||||||
|
|
||||||
// This is a MacOS stub
|
// This is a MacOS stub
|
||||||
|
|
||||||
// Check number of memory required by kubeadm
|
// Check number of memory required by kubeadm
|
||||||
@ -26,3 +28,9 @@ package preflight
|
|||||||
func (mc MemCheck) Check() (warnings, errorList []error) {
|
func (mc MemCheck) Check() (warnings, errorList []error) {
|
||||||
return nil, nil
|
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
|
||||||
|
}
|
||||||
|
@ -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.
|
// kubelet requires mount to be present in PATH for in-tree volume plugins.
|
||||||
checks = append(checks, InPathCheck{executable: "mount", mandatory: true, exec: execer})
|
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
|
return checks
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package preflight
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
system "k8s.io/system-validators/validators"
|
system "k8s.io/system-validators/validators"
|
||||||
utilsexec "k8s.io/utils/exec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// addOSValidator adds a new OSValidator
|
// addOSValidator adds a new OSValidator
|
||||||
@ -47,9 +46,3 @@ func addIPv4Checks(checks []Checker) []Checker {
|
|||||||
func addSwapCheck(checks []Checker) []Checker {
|
func addSwapCheck(checks []Checker) []Checker {
|
||||||
return checks
|
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
|
|
||||||
}
|
|
||||||
|
@ -22,6 +22,7 @@ package preflight
|
|||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
|
utilsexec "k8s.io/utils/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check validates if a user has elevated (administrator) privileges.
|
// 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) {
|
func (mc MemCheck) Check() (warnings, errorList []error) {
|
||||||
return nil, nil
|
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
|
||||||
|
}
|
||||||
|
@ -160,6 +160,13 @@ func GetInitSystem() (InitSystem, error) {
|
|||||||
}
|
}
|
||||||
_, err = exec.LookPath("openrc")
|
_, err = exec.LookPath("openrc")
|
||||||
if err == nil {
|
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
|
return &OpenRCInitSystem{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user