mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 06:15:45 +00:00
e2e tests: Enables should test kubelet managed /etc/hosts file for Windows
We previously skipped this test because Docker did not support mounting individual files in Containers. Since then, support for Docker has been removed, and containerd on Windows supports this feature. We can run this test on Windows.
This commit is contained in:
parent
8e5b26b4c3
commit
844426f5e0
5
test/conformance/testdata/conformance.yaml
vendored
5
test/conformance/testdata/conformance.yaml
vendored
@ -2221,15 +2221,14 @@
|
||||
file: test/e2e/common/node/kubelet.go
|
||||
- testname: Kubelet, managed etc hosts
|
||||
codename: '[sig-node] KubeletManagedEtcHosts should test kubelet managed /etc/hosts
|
||||
file [LinuxOnly] [NodeConformance] [Conformance]'
|
||||
file [NodeConformance] [Conformance]'
|
||||
description: Create a Pod with containers with hostNetwork set to false, one of
|
||||
the containers mounts the /etc/hosts file form the host. Create a second Pod with
|
||||
hostNetwork set to true. 1. The Pod with hostNetwork=false MUST have /etc/hosts
|
||||
of containers managed by the Kubelet. 2. The Pod with hostNetwork=false but the
|
||||
container mounts /etc/hosts file from the host. The /etc/hosts file MUST not be
|
||||
managed by the Kubelet. 3. The Pod with hostNetwork=true , /etc/hosts file MUST
|
||||
not be managed by the Kubelet. This test is marked LinuxOnly since Windows cannot
|
||||
mount individual files in Containers.
|
||||
not be managed by the Kubelet.
|
||||
release: v1.9
|
||||
file: test/e2e/common/node/kubelet_etc_hosts.go
|
||||
- testname: lease API should be available
|
||||
|
@ -31,11 +31,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
etcHostsPodName = "test-pod"
|
||||
etcHostsHostNetworkPodName = "test-host-network-pod"
|
||||
etcHostsPartialContent = "# Kubernetes-managed hosts file."
|
||||
etcHostsPath = "/etc/hosts"
|
||||
etcHostsOriginalPath = "/etc/hosts-original"
|
||||
etcHostsPodName = "test-pod"
|
||||
etcHostsHostNetworkPodName = "test-host-network-pod"
|
||||
etcHostsPartialContent = "# Kubernetes-managed hosts file."
|
||||
etcHostsPathLinux = "/etc/hosts"
|
||||
etcHostsPathWindows = `C:\Windows\System32\drivers\etc\hosts`
|
||||
etcHostsOriginalPathLinux = "/etc/hosts-original"
|
||||
etcHostsOriginalPathWindows = `C:\Windows\System32\drivers\etc\hosts-original`
|
||||
)
|
||||
|
||||
// KubeletManagedHostConfig defines the types for running managed etc hosts test cases
|
||||
@ -59,9 +61,8 @@ var _ = SIGDescribe("KubeletManagedEtcHosts", func() {
|
||||
1. The Pod with hostNetwork=false MUST have /etc/hosts of containers managed by the Kubelet.
|
||||
2. The Pod with hostNetwork=false but the container mounts /etc/hosts file from the host. The /etc/hosts file MUST not be managed by the Kubelet.
|
||||
3. The Pod with hostNetwork=true , /etc/hosts file MUST not be managed by the Kubelet.
|
||||
This test is marked LinuxOnly since Windows cannot mount individual files in Containers.
|
||||
*/
|
||||
framework.ConformanceIt("should test kubelet managed /etc/hosts file [LinuxOnly]", f.WithNodeConformance(), func(ctx context.Context) {
|
||||
framework.ConformanceIt("should test kubelet managed /etc/hosts file", f.WithNodeConformance(), func(ctx context.Context) {
|
||||
ginkgo.By("Setting up the test")
|
||||
config.setup(ctx)
|
||||
|
||||
@ -112,6 +113,7 @@ func assertManagedStatus(
|
||||
|
||||
retryCount := 0
|
||||
etcHostsContent := ""
|
||||
etcHostsPath, etcHostsOriginalPath := getEtcHostsPath()
|
||||
|
||||
for startTime := time.Now(); time.Since(startTime) < retryTimeout; {
|
||||
etcHostsContent = config.getFileContents(podName, name, etcHostsPath)
|
||||
@ -155,6 +157,7 @@ func (config *KubeletManagedHostConfig) getFileContents(podName, containerName,
|
||||
func (config *KubeletManagedHostConfig) createPodSpec(podName string) *v1.Pod {
|
||||
hostPathType := new(v1.HostPathType)
|
||||
*hostPathType = v1.HostPathType(string(v1.HostPathFileOrCreate))
|
||||
etcHostsPath, etcHostsOriginalPath := getEtcHostsPath()
|
||||
mounts := []v1.VolumeMount{
|
||||
{
|
||||
Name: "host-etc-hosts",
|
||||
@ -198,6 +201,7 @@ func (config *KubeletManagedHostConfig) createPodSpec(podName string) *v1.Pod {
|
||||
func (config *KubeletManagedHostConfig) createPodSpecWithHostNetwork(podName string) *v1.Pod {
|
||||
hostPathType := new(v1.HostPathType)
|
||||
*hostPathType = v1.HostPathType(string(v1.HostPathFileOrCreate))
|
||||
etcHostsPath, etcHostsOriginalPath := getEtcHostsPath()
|
||||
mounts := []v1.VolumeMount{
|
||||
{
|
||||
Name: "host-etc-hosts",
|
||||
@ -230,3 +234,10 @@ func (config *KubeletManagedHostConfig) createPodSpecWithHostNetwork(podName str
|
||||
}
|
||||
return pod
|
||||
}
|
||||
|
||||
func getEtcHostsPath() (string, string) {
|
||||
if framework.NodeOSDistroIs("windows") {
|
||||
return etcHostsPathWindows, etcHostsOriginalPathWindows
|
||||
}
|
||||
return etcHostsPathLinux, etcHostsOriginalPathLinux
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user