kubernetes: Windows containers do not have entries in the hosts file

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:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 48 (39 by maintainers)

Most upvoted comments

@kbruner we are waiting on a Windows OS fix from Microsoft to proceed here. If that fix comes in time for us to validate this functionality in 1.19 we would like it to be included in 1.19.

/milestone v1.17 We won’t be able to do this until containerd is ready. It might work in 1.17