diff --git a/instructions.ps1 b/instructions.ps1 index f88c50966a4c..f5c3f5d1b525 100644 --- a/instructions.ps1 +++ b/instructions.ps1 @@ -7,12 +7,17 @@ nameserver 8.8.8.8 """ > /etc/resolv.conf #add paths, #note k3s is where my host-local files are -$env:KUBECONFIG="C:\tmp\k3s\server\cred\admin.kubeconfig" +# $env:KUBECONFIG="C:\tmp\k3s\server\cred\admin.kubeconfig" +$env:KUBECONFIG="C:\Users\Administrator\.kube\k3s.yaml" $env:Path +=";C:\Users\Administrator\go\src\github.com\rancher\k3s" $env:Path +=";C:\tmp" #optional resolve-conf --resolv-conf C:\etc\resolv.conf +$hostNetwork = get-NetIPAddress -InterfaceAlias "vEthernet (Ethernet)"| ?{$_.AddressFamily -eq "IPv4"} +$env:hostIp = $hostNetwork.IpAddress +$env:hostCidr = "{0}/{1}" -f $hostNetwork.IpAddress, $hostNetwork.PrefixLength + #for host-gw #eventually need to get rid of KUBE_NETWORK $env:KUBE_NETWORK="cbr0" @@ -54,4 +59,5 @@ ipmo C:\etc\rancher\node\hns.psm1 Get-HNSEndpoint | Remove-HNSEndpoint Get-HNSNetwork | ? Name -Like "cbr0" | Remove-HNSNetwork Get-HNSNetwork | ? Name -Like "vxlan0" | Remove-HNSNetwork +# Get-HnsNetwork |?{$_.name -eq "External"} |Remove-HnsNetwork Get-HnsPolicyList | Remove-HnsPolicyList diff --git a/pkg/agent/flannel/hns_windows.go b/pkg/agent/flannel/hns_windows.go index 3bb3c6091b29..88dac57dbc97 100644 --- a/pkg/agent/flannel/hns_windows.go +++ b/pkg/agent/flannel/hns_windows.go @@ -607,11 +607,6 @@ func resetHnsNetwork(scriptDirectory string) { _ = run("ipmo " + hnsLocation + `; Reset-HNSNetwork`) } -func resetHnsNetwork(scriptDirectory string) { - hnsLocation := saveHnsScript(scriptDirectory) - _ = run("ipmo " + hnsLocation + `; Reset-HNSNetwork`) -} - func run(command string) string { logrus.Info(command) cmd := exec.Command("powershell", "-Command", command) diff --git a/pkg/agent/flannel/setup_windows.go b/pkg/agent/flannel/setup_windows.go index 921af3314010..e5bf5de19dae 100644 --- a/pkg/agent/flannel/setup_windows.go +++ b/pkg/agent/flannel/setup_windows.go @@ -3,6 +3,7 @@ package flannel import ( "context" "fmt" + "os" "path/filepath" "strings" "time" @@ -171,10 +172,33 @@ func createCNIConf(nodeConfig *config.Node) error { return fmt.Errorf("Cannot configure unknown flannel backend '%s'", nodeConfig.FlannelBackend) } confJSON := strings.Replace(cniConf, "%CLUSTERCIDR%", nodeConfig.AgentConfig.ClusterCIDR.String(), -1) + + // ideally I should not be lazy and query hostCidr & ip + // flannelIface := "Ethernet" + // if nodeConfig.FlannelIface != nil { + // if nodeConfig.FlannelIface.Name != "" { + // flannelIface = nodeConfig.FlannelIface.Name + // } + // } + // hostCidr := getHostCidr(nodeConfig.AgentConfig.NodeConfigPath, flannelIface) + // hostIp := getHostIp(nodeConfig.AgentConfig.NodeConfigPath, flannelIface) + + // lets default them to some random computer, and load them with environment variables + hostCidr := "10.231.120.177/24" + if os.Getenv("hostCidr") != "" { + hostCidr = os.Getenv("hostCidr") + } + + hostIp := "10.231.120.177" + if os.Getenv("hostIp") != "" { + hostIp = os.Getenv("hostIp") + } + // ideally I should write this function, lets be lazy ... + // TODO: figure out how to fetch service cidr confJSON = strings.Replace(confJSON, "%SERVICECIDR%", "10.43.0.0/16", -1) - confJSON = strings.Replace(confJSON, "%HOSTCIDR%", "10.231.120.177/24", -1) - confJSON = strings.Replace(confJSON, "%HOSTIPCIDR%", "10.231.120.177/32", -1) + confJSON = strings.Replace(confJSON, "%HOSTCIDR%", hostCidr, -1) + confJSON = strings.Replace(confJSON, "%HOSTIPCIDR%", hostIp+"/32", -1) return util.WriteFile(p, confJSON) }