mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #53730 from bsteciuk/kubeadm-windows-e2e_node
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add Windows support to the system verification check **What this PR does / why we need it**: This PR (in conjunction with https://github.com/kubernetes/kubernetes/pull/53553 ) adds initial support for adding a Windows worker node to a Kubernetes cluster using kubeadm. It was suggested on that PR to open a separate PR for the changes in test/e2e_node for review by sig-node devs. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #364 in conjuction with #53553 **Special notes for your reviewer**: **Release note**: ```release-note Add Windows support to the system verification check ```
This commit is contained in:
commit
931bc9edf4
@ -12,12 +12,19 @@ go_library(
|
|||||||
"cgroup_validator.go",
|
"cgroup_validator.go",
|
||||||
"docker_validator.go",
|
"docker_validator.go",
|
||||||
"kernel_validator.go",
|
"kernel_validator.go",
|
||||||
|
"kernel_validator_helper.go",
|
||||||
"os_validator.go",
|
"os_validator.go",
|
||||||
"package_validator.go",
|
"package_validator.go",
|
||||||
"report.go",
|
"report.go",
|
||||||
"types.go",
|
"types.go",
|
||||||
|
"types_unix.go",
|
||||||
"validators.go",
|
"validators.go",
|
||||||
],
|
] + select({
|
||||||
|
"@io_bazel_rules_go//go/platform:windows_amd64": [
|
||||||
|
"types_windows.go",
|
||||||
|
],
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
importpath = "k8s.io/kubernetes/test/e2e_node/system",
|
importpath = "k8s.io/kubernetes/test/e2e_node/system",
|
||||||
deps = [
|
deps = [
|
||||||
"//vendor/github.com/blang/semver:go_default_library",
|
"//vendor/github.com/blang/semver:go_default_library",
|
||||||
|
@ -37,7 +37,6 @@ func (d *DockerValidator) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dockerEndpoint = "unix:///var/run/docker.sock"
|
|
||||||
dockerConfigPrefix = "DOCKER_"
|
dockerConfigPrefix = "DOCKER_"
|
||||||
maxDockerValidatedVersion = "17.03"
|
maxDockerValidatedVersion = "17.03"
|
||||||
)
|
)
|
||||||
@ -49,6 +48,7 @@ func (d *DockerValidator) Validate(spec SysSpec) (error, error) {
|
|||||||
// docker, skip the docker configuration validation.
|
// docker, skip the docker configuration validation.
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := client.NewClient(dockerEndpoint, "", nil, nil)
|
c, err := client.NewClient(dockerEndpoint, "", nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create docker client: %v", err)
|
return nil, fmt.Errorf("failed to create docker client: %v", err)
|
||||||
|
@ -61,14 +61,18 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (k *KernelValidator) Validate(spec SysSpec) (error, error) {
|
func (k *KernelValidator) Validate(spec SysSpec) (error, error) {
|
||||||
release, err := exec.Command("uname", "-r").CombinedOutput()
|
helper := KernelValidatorHelperImpl{}
|
||||||
|
release, err := helper.GetKernelReleaseVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get kernel release: %v", err)
|
return nil, fmt.Errorf("failed to get kernel release: %v", err)
|
||||||
}
|
}
|
||||||
k.kernelRelease = strings.TrimSpace(string(release))
|
k.kernelRelease = release
|
||||||
var errs []error
|
var errs []error
|
||||||
errs = append(errs, k.validateKernelVersion(spec.KernelSpec))
|
errs = append(errs, k.validateKernelVersion(spec.KernelSpec))
|
||||||
errs = append(errs, k.validateKernelConfig(spec.KernelSpec))
|
// only validate kernel config when necessary (currently no kernel config for windows)
|
||||||
|
if len(spec.KernelSpec.Required) > 0 || len(spec.KernelSpec.Forbidden) > 0 || len(spec.KernelSpec.Optional) > 0 {
|
||||||
|
errs = append(errs, k.validateKernelConfig(spec.KernelSpec))
|
||||||
|
}
|
||||||
return nil, errors.NewAggregate(errs)
|
return nil, errors.NewAggregate(errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
test/e2e_node/system/kernel_validator_helper.go
Normal file
23
test/e2e_node/system/kernel_validator_helper.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package system
|
||||||
|
|
||||||
|
// KernelValidatorHelper is an interface intended to help with os specific kernel validation
|
||||||
|
type KernelValidatorHelper interface {
|
||||||
|
// GetKernelReleaseVersion gets the current kernel release version of the system
|
||||||
|
GetKernelReleaseVersion() (string, error)
|
||||||
|
}
|
@ -122,45 +122,3 @@ type SysSpec struct {
|
|||||||
// versions for an OS distro.
|
// versions for an OS distro.
|
||||||
PackageSpecOverrides []PackageSpecOverride `json:"packageSpecOverrides,omitempty"`
|
PackageSpecOverrides []PackageSpecOverride `json:"packageSpecOverrides,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultSysSpec is the default SysSpec.
|
|
||||||
var DefaultSysSpec = SysSpec{
|
|
||||||
OS: "Linux",
|
|
||||||
KernelSpec: KernelSpec{
|
|
||||||
Versions: []string{`3\.[1-9][0-9].*`, `4\..*`}, // Requires 3.10+ or 4+
|
|
||||||
// TODO(random-liu): Add more config
|
|
||||||
// TODO(random-liu): Add description for each kernel configuration:
|
|
||||||
Required: []KernelConfig{
|
|
||||||
{Name: "NAMESPACES"},
|
|
||||||
{Name: "NET_NS"},
|
|
||||||
{Name: "PID_NS"},
|
|
||||||
{Name: "IPC_NS"},
|
|
||||||
{Name: "UTS_NS"},
|
|
||||||
{Name: "CGROUPS"},
|
|
||||||
{Name: "CGROUP_CPUACCT"},
|
|
||||||
{Name: "CGROUP_DEVICE"},
|
|
||||||
{Name: "CGROUP_FREEZER"},
|
|
||||||
{Name: "CGROUP_SCHED"},
|
|
||||||
{Name: "CPUSETS"},
|
|
||||||
{Name: "MEMCG"},
|
|
||||||
{Name: "INET"},
|
|
||||||
{Name: "EXT4_FS"},
|
|
||||||
{Name: "PROC_FS"},
|
|
||||||
{Name: "NETFILTER_XT_TARGET_REDIRECT", Aliases: []string{"IP_NF_TARGET_REDIRECT"}},
|
|
||||||
{Name: "NETFILTER_XT_MATCH_COMMENT"},
|
|
||||||
},
|
|
||||||
Optional: []KernelConfig{
|
|
||||||
{Name: "OVERLAY_FS", Aliases: []string{"OVERLAYFS_FS"}, Description: "Required for overlayfs."},
|
|
||||||
{Name: "AUFS_FS", Description: "Required for aufs."},
|
|
||||||
{Name: "BLK_DEV_DM", Description: "Required for devicemapper."},
|
|
||||||
},
|
|
||||||
Forbidden: []KernelConfig{},
|
|
||||||
},
|
|
||||||
Cgroups: []string{"cpu", "cpuacct", "cpuset", "devices", "freezer", "memory"},
|
|
||||||
RuntimeSpec: RuntimeSpec{
|
|
||||||
DockerSpec: &DockerSpec{
|
|
||||||
Version: []string{`1\.1[1-3]\..*`, `17\.03\..*`}, // Requires [1.11, 17.03]
|
|
||||||
GraphDriver: []string{"aufs", "overlay", "overlay2", "devicemapper"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
83
test/e2e_node/system/types_unix.go
Normal file
83
test/e2e_node/system/types_unix.go
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// +build !windows
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// dockerEndpoint is the os specific endpoint for docker communication
|
||||||
|
const dockerEndpoint = "unix:///var/run/docker.sock"
|
||||||
|
|
||||||
|
// DefaultSysSpec is the default SysSpec for Linux
|
||||||
|
var DefaultSysSpec = SysSpec{
|
||||||
|
OS: "Linux",
|
||||||
|
KernelSpec: KernelSpec{
|
||||||
|
Versions: []string{`3\.[1-9][0-9].*`, `4\..*`}, // Requires 3.10+ or 4+
|
||||||
|
// TODO(random-liu): Add more config
|
||||||
|
// TODO(random-liu): Add description for each kernel configuration:
|
||||||
|
Required: []KernelConfig{
|
||||||
|
{Name: "NAMESPACES"},
|
||||||
|
{Name: "NET_NS"},
|
||||||
|
{Name: "PID_NS"},
|
||||||
|
{Name: "IPC_NS"},
|
||||||
|
{Name: "UTS_NS"},
|
||||||
|
{Name: "CGROUPS"},
|
||||||
|
{Name: "CGROUP_CPUACCT"},
|
||||||
|
{Name: "CGROUP_DEVICE"},
|
||||||
|
{Name: "CGROUP_FREEZER"},
|
||||||
|
{Name: "CGROUP_SCHED"},
|
||||||
|
{Name: "CPUSETS"},
|
||||||
|
{Name: "MEMCG"},
|
||||||
|
{Name: "INET"},
|
||||||
|
{Name: "EXT4_FS"},
|
||||||
|
{Name: "PROC_FS"},
|
||||||
|
{Name: "NETFILTER_XT_TARGET_REDIRECT", Aliases: []string{"IP_NF_TARGET_REDIRECT"}},
|
||||||
|
{Name: "NETFILTER_XT_MATCH_COMMENT"},
|
||||||
|
},
|
||||||
|
Optional: []KernelConfig{
|
||||||
|
{Name: "OVERLAY_FS", Aliases: []string{"OVERLAYFS_FS"}, Description: "Required for overlayfs."},
|
||||||
|
{Name: "AUFS_FS", Description: "Required for aufs."},
|
||||||
|
{Name: "BLK_DEV_DM", Description: "Required for devicemapper."},
|
||||||
|
},
|
||||||
|
Forbidden: []KernelConfig{},
|
||||||
|
},
|
||||||
|
Cgroups: []string{"cpu", "cpuacct", "cpuset", "devices", "freezer", "memory"},
|
||||||
|
RuntimeSpec: RuntimeSpec{
|
||||||
|
DockerSpec: &DockerSpec{
|
||||||
|
Version: []string{`1\.1[1-3]\..*`, `17\.03\..*`}, // Requires [1.11, 17.03]
|
||||||
|
GraphDriver: []string{"aufs", "overlay", "overlay2", "devicemapper"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// KernelValidatorHelperImpl is the 'linux' implementation of KernelValidatorHelper
|
||||||
|
type KernelValidatorHelperImpl struct{}
|
||||||
|
|
||||||
|
var _ KernelValidatorHelper = &KernelValidatorHelperImpl{}
|
||||||
|
|
||||||
|
// GetKernelReleaseVersion returns the kernel release version (ex. 4.4.0-96-generic) as a string
|
||||||
|
func (o *KernelValidatorHelperImpl) GetKernelReleaseVersion() (string, error) {
|
||||||
|
releaseVersion, err := exec.Command("uname", "-r").CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(releaseVersion)), nil
|
||||||
|
}
|
60
test/e2e_node/system/types_windows.go
Normal file
60
test/e2e_node/system/types_windows.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// +build windows
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// dockerEndpoint is the os specific endpoint for docker communication
|
||||||
|
const dockerEndpoint = "npipe:////./pipe/docker_engine"
|
||||||
|
|
||||||
|
// DefaultSysSpec is the default SysSpec for Windows
|
||||||
|
var DefaultSysSpec = SysSpec{
|
||||||
|
OS: "Microsoft Windows Server 2016",
|
||||||
|
KernelSpec: KernelSpec{
|
||||||
|
Versions: []string{`10\.0\.1439[3-9]`, `10\.0\.14[4-9][0-9]{2}`, `10\.0\.1[5-9][0-9]{3}`, `10\.0\.[2-9][0-9]{4}`, `10\.[1-9]+\.[0-9]+`}, //requires >= '10.0.14393'
|
||||||
|
Required: []KernelConfig{},
|
||||||
|
Optional: []KernelConfig{},
|
||||||
|
Forbidden: []KernelConfig{},
|
||||||
|
},
|
||||||
|
Cgroups: []string{},
|
||||||
|
RuntimeSpec: RuntimeSpec{
|
||||||
|
DockerSpec: &DockerSpec{
|
||||||
|
Version: []string{`17\.03\..*`}, //Requires [17.03] or later
|
||||||
|
GraphDriver: []string{"windowsfilter"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// KernelValidatorHelperImpl is the 'windows' implementation of KernelValidatorHelper
|
||||||
|
type KernelValidatorHelperImpl struct{}
|
||||||
|
|
||||||
|
var _ KernelValidatorHelper = &KernelValidatorHelperImpl{}
|
||||||
|
|
||||||
|
// GetKernelRelease returns the windows release version (ex. 10.0.14393) as a string
|
||||||
|
func (o *KernelValidatorHelperImpl) GetKernelReleaseVersion() (string, error) {
|
||||||
|
args := []string{"(Get-CimInstance Win32_OperatingSystem).Version"}
|
||||||
|
releaseVersion, err := exec.Command("powershell", args...).Output()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(releaseVersion)), nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user