Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows containers do not have entries in the hosts file #70189

Closed
claudiubelu opened this issue Oct 24, 2018 · 48 comments · Fixed by #83730
Closed

Windows containers do not have entries in the hosts file #70189

claudiubelu opened this issue Oct 24, 2018 · 48 comments · Fixed by #83730
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/windows Categorizes an issue or PR as relevant to SIG Windows.
Milestone

Comments

@claudiubelu
Copy link
Contributor

claudiubelu commented Oct 24, 2018

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

/sig windows

What happened:

When deploying Kubernetes pods, the Linux containers will contain the following entries in the /etc/hosts file:

# Kubernetes-managed hosts file.
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.240.0.67     dns-querier-1.dns-test-service.e2e-tests-dns-x649p.svc.cluster.local    dns-querier-1

However, these are not set on Windows containers; the container's C:\Windows\System32\drivers\etc\hosts file does not contain any entry. This can be attributed to the fact that individual files cannot be mounted on Windows containers the same way they are on Linux containers.

It can be fixed with a change to the kubelet once Windows Server 2019 has shipped, and once CRI-ContainerD is enabled on Windows. We cannot fix it for Windows Server 1803 or earlier with dockershim.

What you expected to happen:

The :\Windows\System32\drivers\etc\hosts file should be managed and populated by Kubelet.

How to reproduce it (as minimally and precisely as possible):

Spawn a Windows pod, and check its container's :\Windows\System32\drivers\etc\hosts file.

kubectl create namespace e2e-tests-dns-x649p
kubectl create -f windows_pod.yaml  # https://paste.ubuntu.com/p/ZgfQS9Wgcf/
kubectl exec -n e2e-tests-dns-x649p dns-test-2ed58282-6d85-11e8-89cc-000c29738e2c -c querier -- cmd /S /C type C:\\Windows\\System32\\drivers\\etc\\hosts

Compare the result with a Linux pod's container's /etc/hosts file.

kubectl create namespace e2e-tests-dns-x649p
kubectl create -f linux_pod.yaml  # https://paste.ubuntu.com/p/kcFcfxYjm3/

kubectl exec -n e2e-tests-dns-x649p dns-test-2ed58282-6d85-11e8-89cc-000c29738e2c -c querier -- cat /etc/hosts

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): 1.12
  • Cloud provider or hardware configuration: N/A
  • OS (e.g. from /etc/os-release): Windows Server 1803 (10.0.17134.48)
  • Install tools: acs-engine v0.24.0
  • Others:
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. sig/windows Categorizes an issue or PR as relevant to SIG Windows. labels Oct 24, 2018
@PatrickLang
Copy link
Contributor

This requires single-file mapping, which won't work in Windows Server version 1803. It should be possible with Windows Server 2019 along with ContainerD

@feiskyer
Copy link
Member

Will it work with Docker on Windows Server 2019?

@PatrickLang
Copy link
Contributor

Not in 18.09 or earlier. I'm not sure what release it will be in because it will require migrating to containerd.

@AishSundar
Copy link
Contributor

@PatrickLang should this issue be tracked for 1.13 in addition to #65016? If so please apply the appropriate priority and milestone labels please.

@nikopen

@PatrickLang
Copy link
Contributor

This one needs to be in v1.14. We need to get cri-containerd working first to fix this.

@AishSundar
Copy link
Contributor

Thanks
/milestone v1.14

@k8s-ci-robot k8s-ci-robot added this to the v1.14 milestone Oct 29, 2018
@daschott
Copy link
Contributor

By default, hosts file are not being used in Windows, it is all registry based. What features is this blocking?

CC @madhanrm

@claudiubelu
Copy link
Contributor Author

The hosts file entries are still taken into account on Windows when it has to resolve a DNS name. This is blocking DNS conformance tests, like [sig-network] DNS should provide DNS for the cluster [Conformance].

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 28, 2019
@bgrant0607 bgrant0607 removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 29, 2019
@neolit123
Copy link
Member

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Feb 19, 2019
@soggiest
Copy link

soggiest commented Mar 5, 2019

Hello!
1.14 code freeze is coming in about 3 days, is this intended to be implemented in the following week?

@claudiubelu
Copy link
Contributor Author

No. It is meant to be fixed in the next release, when the Containerd support will be introduced.

@nikopen
Copy link
Contributor

nikopen commented Mar 5, 2019

/milestone v1.15

@k8s-ci-robot
Copy link
Contributor

@marosset: The provided milestone is not valid for this repository. Milestones in this repository: [next-candidate, v1.13, v1.14, v1.15, v1.16, v1.17, v1.18, v1.19, v1.20, v1.21, v1.22, v2.0]

Use /milestone clear to clear the milestone.

In response to this:

/milestone 1.20

The OS fix is now expect to be available as part of August Windows patches and then changes to the kubelet will need to follow.

/cc @immuzz

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@k8s-ci-robot
Copy link
Contributor

@marosset: The provided milestone is not valid for this repository. Milestones in this repository: [next-candidate, v1.13, v1.14, v1.15, v1.16, v1.17, v1.18, v1.19, v1.20, v1.21, v1.22, v2.0]

Use /milestone clear to clear the milestone.

In response to this:

/milestone 1.20

The OS fix is now expect to be available as part of August Windows patches and then changes to the kubelet will need to follow.

/cc @immuzz

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kbruner
Copy link

kbruner commented Jun 19, 2020

/milestone v1.20

@k8s-ci-robot k8s-ci-robot modified the milestones: v1.19, v1.20 Jun 19, 2020
@immuzz
Copy link
Contributor

immuzz commented Jun 22, 2020

@marosset yes it is expected be part of August Windows release

@bai
Copy link

bai commented Oct 23, 2020

Hey 👋 Bug Triage here. Wanted to follow up on the status of this issue as we're approaching code freeze on 12.11.2020. This issue is tagged for 1.20, is it still planned for this release?

@marosset
Copy link
Contributor

@bai - Yes, we'd like to make it into 1.20.
We were waiting on some bugfixes in the Windows OS and those bugfixes are now available (as of Oct 20 2020).

@marosset
Copy link
Contributor

/remove-lifecycle frozen

@k8s-ci-robot k8s-ci-robot removed the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Oct 23, 2020
@marosset
Copy link
Contributor

/priority important-soon

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Oct 23, 2020
@marosset
Copy link
Contributor

I believe the work involved here is to

  • update
    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) ([]kubecontainer.Mount, func(), error) {
    // 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
    // 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 && runtime.GOOS != "windows"
    klog.V(3).Infof("container: %v/%v/%v podIPs: %q creating hosts mount: %v", pod.Namespace, pod.Name, container.Name, podIPs, mountEtcHostsFile)
    to enable this fucntionality for WIndows if container-runtime == remote (still disable this for DockerShim)
  • Update/Add test coverage
  • Update documentation - possible this section https://kubernetes.io/docs/setup/production-environment/windows/intro-windows-in-kubernetes/#feature-restrictions ?

@marosset marosset moved this from Backlog to Backlog (v1.20) in SIG-Windows Oct 23, 2020
@marosset
Copy link
Contributor

/milestone v1.21

Moving to 1.21 since the required OS fixes were not available in time to implement this functionality in v1.20

@k8s-ci-robot k8s-ci-robot modified the milestones: v1.20, v1.21 Nov 12, 2020
@immuzz immuzz moved this from Backlog (v1.20) to Done (v1.21) in SIG-Windows Dec 3, 2020
@immuzz immuzz moved this from Done (v1.21) to Backlog (v1.21) in SIG-Windows Dec 3, 2020
@immuzz immuzz moved this from Backlog (v1.21) to In Progress (v1.21) in SIG-Windows Dec 17, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 10, 2021
@kcmartin
Copy link

kcmartin commented Mar 5, 2021

Hello! I am from the Bug Triage team! This issue has not been updated for a long time, so I'd like to check on the status. The code freeze is starting March 9th, 2021 (about 1 week from now). We want to ensure that each PR has a chance to be merged before code freeze.

As the Issue is tagged for 1.21, is it still planned for this release?

SIG-Windows automation moved this from In Progress (v1.21) to Done (v1.21) Mar 5, 2021
Windows CRI-ContainerD Bring-up automation moved this from Known OS issues - document until patch released to Done Mar 5, 2021
@brandongarcia-ms
Copy link

brandongarcia-ms commented Aug 5, 2022

Can this be reopened? From a related problem I have experienced using HostAlias for Windows pod deployments, this issue does not seem to be resolved. Instead, it looks as if it was closed by accident because the conversation went cold.

@claudiubelu
Copy link
Contributor Author

Can this be reopened? From a related problem I have experienced using HostAlias for Windows pod deployments, this issue does not seem to be resolved. Instead, it looks as if it was closed by accident because the conversation went cold.

Hello. What Kubernetes version are you running? Also, on the Windows nodes, do you use docker, or containerd? This is only supported on Windows nodes with containerd, since it supports single file mapping, which is required in order to mount single files into Windows containers.

@brandongarcia-ms
Copy link

Hello. What Kubernetes version are you running? Also, on the Windows nodes, do you use docker, or containerd? This is only supported on Windows nodes with containerd, since it supports single file mapping, which is required in order to mount single files into Windows containers.

We have experimented with both 1.22.11 and a 1.23 release and yea, the container runtime is containerd. Any other ideas to check up on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/windows Categorizes an issue or PR as relevant to SIG Windows.
Development

Successfully merging a pull request may close this issue.