mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #103434 from perithompson/windows-etchostcreate-skip
Explicitly skip host file mounting for Windows when HostProcess pod
This commit is contained in:
commit
57716897eb
@ -139,16 +139,25 @@ func (kl *Kubelet) makeBlockVolumes(pod *v1.Pod, container *v1.Container, podVol
|
|||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shouldMountHostsFile checks if the nodes /etc/hosts should be mounted
|
||||||
|
// Kubernetes only mounts on /etc/hosts if:
|
||||||
|
// - container is not an infrastructure (pause) container
|
||||||
|
// - container is not already mounting on /etc/hosts
|
||||||
|
// - if it is Windows and ContainerD is used.
|
||||||
|
// Kubernetes will not mount /etc/hosts if:
|
||||||
|
// - when the Pod sandbox is being created, its IP is still unknown. Hence, PodIP will not have been set.
|
||||||
|
// - Windows pod contains a hostProcess container
|
||||||
|
func shouldMountHostsFile(pod *v1.Pod, podIPs []string, supportsSingleFileMapping bool) bool {
|
||||||
|
shouldMount := len(podIPs) > 0 && supportsSingleFileMapping
|
||||||
|
if runtime.GOOS == "windows" && utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostProcessContainers) {
|
||||||
|
return shouldMount && !kubecontainer.HasWindowsHostProcessContainer(pod)
|
||||||
|
}
|
||||||
|
return shouldMount
|
||||||
|
}
|
||||||
|
|
||||||
// makeMounts determines the mount points for the given container.
|
// makeMounts determines the mount points for the given container.
|
||||||
func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, hostDomain string, podIPs []string, podVolumes kubecontainer.VolumeMap, hu hostutil.HostUtils, subpather subpath.Interface, expandEnvs []kubecontainer.EnvVar, supportsSingleFileMapping bool) ([]kubecontainer.Mount, func(), error) {
|
func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, hostDomain string, podIPs []string, podVolumes kubecontainer.VolumeMap, hu hostutil.HostUtils, subpather subpath.Interface, expandEnvs []kubecontainer.EnvVar, supportsSingleFileMapping bool) ([]kubecontainer.Mount, func(), error) {
|
||||||
// Kubernetes only mounts on /etc/hosts if:
|
mountEtcHostsFile := shouldMountHostsFile(pod, podIPs, supportsSingleFileMapping)
|
||||||
// - container is not an infrastructure (pause) container
|
|
||||||
// - container is not already mounting on /etc/hosts
|
|
||||||
// - OS is not Windows
|
|
||||||
// - if it is Windows, ContainerD is used.
|
|
||||||
// Kubernetes will not mount /etc/hosts if:
|
|
||||||
// - when the Pod sandbox is being created, its IP is still unknown. Hence, PodIP will not have been set.
|
|
||||||
mountEtcHostsFile := len(podIPs) > 0 && supportsSingleFileMapping
|
|
||||||
klog.V(3).InfoS("Creating hosts mount for container", "pod", klog.KObj(pod), "containerName", container.Name, "podIPs", podIPs, "path", mountEtcHostsFile)
|
klog.V(3).InfoS("Creating hosts mount for container", "pod", klog.KObj(pod), "containerName", container.Name, "podIPs", podIPs, "path", mountEtcHostsFile)
|
||||||
mounts := []kubecontainer.Mount{}
|
mounts := []kubecontainer.Mount{}
|
||||||
var cleanupAction func()
|
var cleanupAction func()
|
||||||
|
Loading…
Reference in New Issue
Block a user