code: func ensureHostsFile(fileName, hostIP, hostName, hostDomainName string, hostAliases []v1.HostAlias, useHostNetwork bool) error {
  	var hostsFileContent []byte
  	var err error
  
  	if useHostNetwork {
  		// if Pod is using host network, read hosts file from the node's filesystem.
  		// `etcHostsPath` references the location of the hosts file on the node.
  		// `/etc/hosts` for *nix systems.
  		hostsFileContent, err = nodeHostsFileContent(etcHostsPath, hostAliases)
  		if err != nil {
  			return err
  		}
  	} else {
  		// if Pod is not using host network, create a managed hosts file with Pod IP and other information.
  		hostsFileContent = managedHostsFileContent(hostIP, hostName, hostDomainName, hostAliases)
  	}
  
  	return ioutil.WriteFile(fileName, hostsFileContent, 0644)
  }
docs: // ensureHostsFile ensures that the given host file has an up-to-date ip, host
  // name, and domain name.