kube-proxy 日志
...
E0409 13:34:34.816950 3560 proxier.go:998] "Source Vip endpoint creation failed" err="hcnCreateEndpoint failed in Win32: An address provided is invalid or reserved. (0x803b002f) {\"Success\":false,\"Error\":\"An address provided is invalid or reserved. \",\"ErrorCode\":2151350319}"
...
解决
1.把下面的脚本保存为 c:\k\GetSourceVip.ps1
<#
#>
Param(
[parameter(HelpMessage="network name")]
[string] $NetworkName = "flannel.4096"
)
function GetSourceVip($ipaddress, $NetworkName) {
$hnsNetwork = Get-HnsNetwork | ? Name -EQ $NetworkName.ToLower()
$subnet = $hnsNetwork.Subnets[0].AddressPrefix
$ipamConfig = @"
{"cniVersion": "0.2.0", "name": "vxlan0", "ipam":{"type":"host-local","ranges":[[{"subnet":"$subnet"}]],"dataDir":"/var/lib/cni/networks"}}
"@
$ipamConfig | Out-File "C:\k\sourceVipRequest.json"
$env:CNI_COMMAND="ADD"
$env:CNI_CONTAINERID="dummy"
$env:CNI_NETNS="dummy"
$env:CNI_IFNAME="dummy"
$env:CNI_PATH="c:\opt\cni" #path to host-local.exe
If(!(Test-Path c:/k/sourceVip.json)) {
Get-Content sourceVipRequest.json | c:\opt\cni\bin\host-local.exe | Out-File sourceVip.json
}
Remove-Item env:CNI_COMMAND
Remove-Item env:CNI_CONTAINERID
Remove-Item env:CNI_NETNS
Remove-Item env:CNI_IFNAME
Remove-Item env:CNI_PATH
}
GetSourceVip "" $NetworkName
2.运行脚本
cd c:\k
.\GetSourceVip.ps1
修改 kube-proxy.yml
内容见 官方文件。
修改获取 sourceVip 的代码:
#$sourceVip = ($env:POD_IP -split "\.")[0..2] + 2 -join "."
$sourceVipJSON = (Get-Content "/host/k/sourceVip.json" | ConvertFrom-Json)
$sourceVip = $sourceVipJSON.ip4.ip.Split("/")[0]
重新创建 windows节点的 kube-proxy
利用 kubectl 先删除,再创建即可。
参考
https://github.com/kubernetes/kubernetes/issues/100962