Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KnicKnic committed Jun 16, 2020
1 parent 3b19047 commit 8d7a486
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Launch",
"type": "go",
Expand All @@ -12,6 +13,22 @@
"program": "${fileDirname}",
"env": {"KUBE_NETWORK":"cbr0", "PATH": "C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Docker;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Go\\bin;C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Administrator\\go\\bin;C:\\ProgramData\\chocolatey\\lib\\mingw\\tools\\install\\mingw64\\bin;C:\\Users\\Administrator\\go\\src\\github.com\\rancher\\k3s"},
"args": ["server", "-d", "c:\\tmp\\k3s", "", "--flannel-backend", "host-gw", "--docker", "--disable-network-policy", "--pause-image", "mcr.microsoft.com/k8s/core/pause:1.0.0", "--disable", "servicelb,traefik,local-storage,metrics-server"]
},
{ "useApiV1": false,
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 400,
"maxArrayValues": 64,
"maxStructFields": -1
},
"name": "Overlay",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {"KUBE_NETWORK":"vxlan0", "PATH": "C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Docker;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Go\\bin;C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Administrator\\go\\bin;C:\\ProgramData\\chocolatey\\lib\\mingw\\tools\\install\\mingw64\\bin;C:\\Users\\Administrator\\go\\src\\github.com\\rancher\\k3s"},
"args": ["server", "-d", "c:\\tmp\\k3s", "", "--flannel-backend", "vxlan", "--docker", "--disable-network-policy", "--pause-image", "mcr.microsoft.com/k8s/core/pause:1.0.0", "--disable", "servicelb,traefik,local-storage,metrics-server"]
}
]
}
23 changes: 13 additions & 10 deletions pkg/agent/flannel/hns_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ function Get-HNSSourceVip($nodeDir, $hostLocalDir, $NetworkName)
If(!(Test-Path "$nodeDir\sourceVip.json")){
Get-Content "$nodeDir\sourceVipRequest.json" | &"$hostLocalDir\host-local.exe" | Out-File "$nodeDir\sourceVip.json"
}
$sourceVipJSON = Get-Content sourceVip.json | ConvertFrom-Json
$sourceVipJSON = Get-Content $nodeDir\sourceVip.json | ConvertFrom-Json
$sourceVip = $sourceVipJSON.ip4.ip.Split("/")[0]
$sourceVip
Expand Down Expand Up @@ -582,16 +582,17 @@ func setupOverlay(scriptDirectory string, interfaceName string) {
)
}


func setupOverlayVip(scriptDirectory string, hostLocalDir string, networkName string) string{
func SetupOverlayVip(scriptDirectory string, hostLocalDir string, networkName string) string {
hnsLocation := saveHnsScript(scriptDirectory)
return = run("ipmo " + hnsLocation + fmt.Sprintf(`; Get-HNSSourceVip -nodeDir "%s" -hostLocalDir "%s" -NetworkName "%s"`,
scriptDirectory,
hostLocalDir,
networkName),
_ = run("ipmo " + hnsLocation + fmt.Sprintf(`; Get-HNSSourceVip -nodeDir "%s" -hostLocalDir "%s" -NetworkName "%s"`,
scriptDirectory,
hostLocalDir,
networkName),
)
}

return run(fmt.Sprintf(`$sourceVipJSON = Get-Content %s\sourceVip.json | ConvertFrom-Json ; $sourceVipJSON.ip4.ip.Split("/")[0]`, scriptDirectory))

}

func setupL2bridge(scriptDirectory string, interfaceName string) {
hnsLocation := saveHnsScript(scriptDirectory)
Expand All @@ -614,13 +615,15 @@ func resetHnsNetwork(scriptDirectory string) {
func run(command string) string {
logrus.Info(command)
cmd := exec.Command("powershell", "-Command", command)
cmd.Stdout = os.Stdout
r, w, _ := os.Pipe()
cmd.Stdout = w
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
logrus.Fatalf("Error running command: %v", err)
}

w.Close()
var buf bytes.Buffer
io.Copy(&buf, cmd.Stdout)
io.Copy(&buf, r)
return buf.String()
}
3 changes: 0 additions & 3 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
return err
}

// *note if we are windows we need to setup flannel before starting kube-proxy
// kube-proxy setup is in agent code

if err := agent.Agent(&nodeConfig.AgentConfig); err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/daemons/agent/kubeproxy_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package agent
import (
// "path/filepath"
"os"
"strings"
// "github.com/rancher/k3s/pkg/agent/util"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/executor"

"github.com/rancher/k3s/pkg/agent/flannel"
"github.com/sirupsen/logrus"

_ "k8s.io/component-base/metrics/prometheus/restclient" // for client metric registration
Expand Down Expand Up @@ -50,7 +53,7 @@ func startKubeProxy(cfg *config.Agent) error {
if kubeNetwork == "" || kubeNetwork == "vxlan0" {
argsMap["network-name"] = "vxlan0"
argsMap["feature-gates"] = "WinOverlay=true"
// argsMap["source-vip"] = "10.42.0.8"
argsMap["source-vip"] = strings.TrimSpace(flannel.SetupOverlayVip("c:\\etc\\rancher\\node", "C:\\Users\\Administrator\\go\\src\\github.com\\rancher\\k3s", argsMap["network-name"]))
}

// if cfg.
Expand Down

0 comments on commit 8d7a486

Please sign in to comment.