mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Add dns capability to GCE window cluster
This commit is contained in:
parent
26a381b8e1
commit
2a3ab18654
@ -805,6 +805,10 @@ function construct-linux-kubelet-flags {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Sets KUBELET_ARGS with the kubelet flags for Windows nodes.
|
# Sets KUBELET_ARGS with the kubelet flags for Windows nodes.
|
||||||
|
# Note that to configure flags with explicit empty string values, we can't escape
|
||||||
|
# double-quotes, because they still break sc.exe after expansion in the
|
||||||
|
# binPath parameter, and single-quotes get parsed as characters instead of
|
||||||
|
# string delimiters.
|
||||||
function construct-windows-kubelet-flags {
|
function construct-windows-kubelet-flags {
|
||||||
local flags="$(construct-common-kubelet-flags)"
|
local flags="$(construct-common-kubelet-flags)"
|
||||||
|
|
||||||
@ -868,11 +872,8 @@ function construct-windows-kubelet-flags {
|
|||||||
# actually log to the file
|
# actually log to the file
|
||||||
flags+=" --logtostderr=false"
|
flags+=" --logtostderr=false"
|
||||||
|
|
||||||
# Configure flags with explicit empty string values. We can't escape
|
# Configure the file path for host dns configuration
|
||||||
# double-quotes, because they still break sc.exe after expansion in the
|
flags+=" --resolv-conf=${WINDOWS_CNI_CONFIG_DIR}\hostdns.conf"
|
||||||
# binPath parameter, and single-quotes get parsed as characters instead of
|
|
||||||
# string delimiters.
|
|
||||||
flags+=" --resolv-conf="
|
|
||||||
|
|
||||||
# Both --cgroups-per-qos and --enforce-node-allocatable should be disabled on
|
# Both --cgroups-per-qos and --enforce-node-allocatable should be disabled on
|
||||||
# windows; the latter requires the former to be enabled to work.
|
# windows; the latter requires the former to be enabled to work.
|
||||||
|
@ -126,6 +126,7 @@ try {
|
|||||||
Set-PodCidr
|
Set-PodCidr
|
||||||
Configure-HostNetworkingService
|
Configure-HostNetworkingService
|
||||||
Configure-CniNetworking
|
Configure-CniNetworking
|
||||||
|
Configure-HostDnsConf
|
||||||
Configure-GcePdTools
|
Configure-GcePdTools
|
||||||
Configure-Kubelet
|
Configure-Kubelet
|
||||||
|
|
||||||
|
@ -857,7 +857,8 @@ function Configure-CniNetworking {
|
|||||||
"name": "l2bridge",
|
"name": "l2bridge",
|
||||||
"type": "win-bridge",
|
"type": "win-bridge",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"portMappings": true
|
"portMappings": true,
|
||||||
|
"dns": true
|
||||||
},
|
},
|
||||||
"ipam": {
|
"ipam": {
|
||||||
"type": "host-local",
|
"type": "host-local",
|
||||||
@ -913,6 +914,28 @@ function Configure-CniNetworking {
|
|||||||
Log-Output "CNI config:`n$(Get-Content -Raw ${l2bridge_conf})"
|
Log-Output "CNI config:`n$(Get-Content -Raw ${l2bridge_conf})"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Obtain the host dns conf and save it to a file so that kubelet/CNI
|
||||||
|
# can use it to configure dns suffix search list for pods.
|
||||||
|
# The value of DNS server is ignored right now because the pod will
|
||||||
|
# always only use cluster DNS service, but for consistency, we still
|
||||||
|
# parsed them here in the same format as Linux resolv.conf.
|
||||||
|
# This function must be called after Configure-HostNetworkingService.
|
||||||
|
function Configure-HostDnsConf {
|
||||||
|
$net_adapter = Get_MgmtNetAdapter
|
||||||
|
$server_ips = (Get-DnsClientServerAddress `
|
||||||
|
-InterfaceAlias ${net_adapter}.Name).ServerAddresses
|
||||||
|
$search_list = (Get-DnsClient).ConnectionSpecificSuffixSearchList
|
||||||
|
$conf = ""
|
||||||
|
ForEach ($ip in $server_ips) {
|
||||||
|
$conf = $conf + "nameserver $ip`r`n"
|
||||||
|
}
|
||||||
|
$conf = $conf + "search $search_list"
|
||||||
|
$hostdns_conf = "${env:CNI_CONFIG_DIR}\hostdns.conf"
|
||||||
|
New-Item -Force -ItemType file ${hostdns_conf} | Out-Null
|
||||||
|
Set-Content ${hostdns_conf} $conf
|
||||||
|
Log-Output "HOST dns conf:`n$(Get-Content -Raw ${hostdns_conf})"
|
||||||
|
}
|
||||||
|
|
||||||
# Fetches the kubelet config from the instance metadata and puts it at
|
# Fetches the kubelet config from the instance metadata and puts it at
|
||||||
# $env:KUBELET_CONFIG.
|
# $env:KUBELET_CONFIG.
|
||||||
function Configure-Kubelet {
|
function Configure-Kubelet {
|
||||||
|
Loading…
Reference in New Issue
Block a user