mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +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
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// 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
|
||||
// - OS is not Windows
|
||||
// - if it is Windows, ContainerD is used.
|
||||
// - 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.
|
||||
mountEtcHostsFile := len(podIPs) > 0 && supportsSingleFileMapping
|
||||
// - 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.
|
||||
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) {
|
||||
mountEtcHostsFile := shouldMountHostsFile(pod, podIPs, supportsSingleFileMapping)
|
||||
klog.V(3).InfoS("Creating hosts mount for container", "pod", klog.KObj(pod), "containerName", container.Name, "podIPs", podIPs, "path", mountEtcHostsFile)
|
||||
mounts := []kubecontainer.Mount{}
|
||||
var cleanupAction func()
|
||||
|
Loading…
Reference in New Issue
Block a user