@@ -857,7 +857,8 @@ function Configure-CniNetworking {
857
857
"name": "l2bridge",
858
858
"type": "win-bridge",
859
859
"capabilities": {
860
- "portMappings": true
860
+ "portMappings": true,
861
+ "dns": true
861
862
},
862
863
"ipam": {
863
864
"type": "host-local",
@@ -913,6 +914,28 @@ function Configure-CniNetworking {
913
914
Log- Output " CNI config:`n $ ( Get-Content - Raw ${l2bridge_conf} ) "
914
915
}
915
916
917
+ # Obtain the host dns conf and save it to a file so that kubelet/CNI
918
+ # can use it to configure dns suffix search list for pods.
919
+ # The value of DNS server is ignored right now because the pod will
920
+ # always only use cluster DNS service, but for consistency, we still
921
+ # parsed them here in the same format as Linux resolv.conf.
922
+ # This function must be called after Configure-HostNetworkingService.
923
+ function Configure-HostDnsConf {
924
+ $net_adapter = Get_MgmtNetAdapter
925
+ $server_ips = (Get-DnsClientServerAddress `
926
+ - InterfaceAlias ${net_adapter}.Name ).ServerAddresses
927
+ $search_list = (Get-DnsClient ).ConnectionSpecificSuffixSearchList
928
+ $conf = " "
929
+ ForEach ($ip in $server_ips ) {
930
+ $conf = $conf + " nameserver $ip `r`n "
931
+ }
932
+ $conf = $conf + " search $search_list "
933
+ $hostdns_conf = " ${env: CNI_CONFIG_DIR} \hostdns.conf"
934
+ New-Item - Force - ItemType file ${hostdns_conf} | Out-Null
935
+ Set-Content ${hostdns_conf} $conf
936
+ Log- Output " HOST dns conf:`n $ ( Get-Content - Raw ${hostdns_conf} ) "
937
+ }
938
+
916
939
# Fetches the kubelet config from the instance metadata and puts it at
917
940
# $env:KUBELET_CONFIG.
918
941
function Configure-Kubelet {
0 commit comments