mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Add the system verification check to the kubeadm preflight checks
This commit is contained in:
parent
dacec687a4
commit
a26cbbf3d0
@ -19,6 +19,7 @@ go_library(
|
|||||||
"//pkg/api/validation:go_default_library",
|
"//pkg/api/validation:go_default_library",
|
||||||
"//pkg/util/initsystem:go_default_library",
|
"//pkg/util/initsystem:go_default_library",
|
||||||
"//pkg/util/node:go_default_library",
|
"//pkg/util/node:go_default_library",
|
||||||
|
"//test/e2e_node/system:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package preflight
|
package preflight
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -29,6 +30,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api/validation"
|
"k8s.io/kubernetes/pkg/api/validation"
|
||||||
"k8s.io/kubernetes/pkg/util/initsystem"
|
"k8s.io/kubernetes/pkg/util/initsystem"
|
||||||
"k8s.io/kubernetes/pkg/util/node"
|
"k8s.io/kubernetes/pkg/util/node"
|
||||||
|
"k8s.io/kubernetes/test/e2e_node/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PreFlightError struct {
|
type PreFlightError struct {
|
||||||
@ -213,9 +215,26 @@ func (hst HttpProxyCheck) Check() (warnings, errors []error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SystemVerificationCheck struct{}
|
||||||
|
|
||||||
|
func (sysver SystemVerificationCheck) Check() (warnings, errors []error) {
|
||||||
|
// Create a buffered writer and choose a quite large value (1M) and suppose the output from the system verification test won't exceed the limit
|
||||||
|
bufw := bufio.NewWriterSize(os.Stdout, 1*1024*1024)
|
||||||
|
|
||||||
|
// Run the system verification check, but write to out buffered writer instead of stdout
|
||||||
|
err := system.Validate(system.DefaultSysSpec, &system.StreamReporter{WriteStream: bufw})
|
||||||
|
if err != nil {
|
||||||
|
// Only print the output from the system verification check if the check failed
|
||||||
|
fmt.Println("System verification failed. Printing the output from the verification...")
|
||||||
|
bufw.Flush()
|
||||||
|
return nil, []error{err}
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RunInitMasterChecks(cfg *kubeadmapi.MasterConfiguration) error {
|
func RunInitMasterChecks(cfg *kubeadmapi.MasterConfiguration) error {
|
||||||
// TODO: Some of these ports should come from kubeadm config eventually:
|
|
||||||
checks := []PreFlightCheck{
|
checks := []PreFlightCheck{
|
||||||
|
SystemVerificationCheck{},
|
||||||
IsRootCheck{root: true},
|
IsRootCheck{root: true},
|
||||||
HostnameCheck{},
|
HostnameCheck{},
|
||||||
ServiceCheck{Service: "kubelet"},
|
ServiceCheck{Service: "kubelet"},
|
||||||
@ -249,8 +268,8 @@ func RunInitMasterChecks(cfg *kubeadmapi.MasterConfiguration) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunJoinNodeChecks(cfg *kubeadmapi.NodeConfiguration) error {
|
func RunJoinNodeChecks(cfg *kubeadmapi.NodeConfiguration) error {
|
||||||
// TODO: Some of these ports should come from kubeadm config eventually:
|
|
||||||
checks := []PreFlightCheck{
|
checks := []PreFlightCheck{
|
||||||
|
SystemVerificationCheck{},
|
||||||
IsRootCheck{root: true},
|
IsRootCheck{root: true},
|
||||||
HostnameCheck{},
|
HostnameCheck{},
|
||||||
ServiceCheck{Service: "docker"},
|
ServiceCheck{Service: "docker"},
|
||||||
|
Loading…
Reference in New Issue
Block a user