diff --git a/cmd/kubeadm/app/util/system/kernel_validator_test.go b/cmd/kubeadm/app/util/system/kernel_validator_test.go index a967ad5ec01..7c303ae6c55 100644 --- a/cmd/kubeadm/app/util/system/kernel_validator_test.go +++ b/cmd/kubeadm/app/util/system/kernel_validator_test.go @@ -31,7 +31,7 @@ func TestValidateKernelVersion(t *testing.T) { // they may be different. // This is fine, because the test mainly tests the kernel version validation logic, // not the DefaultSysSpec. The DefaultSysSpec should be tested with node e2e. - testRegex := []string{`3\.[1-9][0-9].*`, `4\..*`} + testRegex := []string{`^3\.[1-9][0-9].*$`, `^([4-9]|[1-9][0-9]+)\.([0-9]+)\.([0-9]+).*$`} for _, test := range []struct { name string version string @@ -53,9 +53,19 @@ func TestValidateKernelVersion(t *testing.T) { err: true, }, { - name: "5.0.0 no version regex matches", + name: "5.0.0 one of version regexes matches", version: "5.0.0", - err: true, + err: false, + }, + { + name: "10.21.1 one of version regexes matches", + version: "10.21.1", + err: false, + }, + { + name: "99.12.12 one of version regexes matches", + version: "99.12.12", + err: false, }, { name: "3.9.0 no version regex matches", diff --git a/cmd/kubeadm/app/util/system/types_unix.go b/cmd/kubeadm/app/util/system/types_unix.go index a401bbac113..6c255b2235b 100644 --- a/cmd/kubeadm/app/util/system/types_unix.go +++ b/cmd/kubeadm/app/util/system/types_unix.go @@ -30,7 +30,7 @@ const dockerEndpoint = "unix:///var/run/docker.sock" var DefaultSysSpec = SysSpec{ OS: "Linux", KernelSpec: KernelSpec{ - Versions: []string{`3\.[1-9][0-9].*`, `4\..*`, `5\..*`}, // Requires 3.10+, 4+ or 5+ + Versions: []string{`^3\.[1-9][0-9].*$`, `^([4-9]|[1-9][0-9]+)\.([0-9]+)\.([0-9]+).*$`}, // Requires 3.10+, or newer // TODO(random-liu): Add more config // TODO(random-liu): Add description for each kernel configuration: Required: []KernelConfig{