Skip to content

Commit

Permalink
Merge pull request #260 from ksubrmnn/overlay
Browse files Browse the repository at this point in the history
Updating scripts for Flannel Overlay
  • Loading branch information
madhanrm committed Oct 9, 2018
2 parents b43e7d5 + e494f14 commit 4475ce1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 11 deletions.
9 changes: 5 additions & 4 deletions Kubernetes/flannel/overlay/README.md
Expand Up @@ -15,12 +15,13 @@ There are several pending PRs, because of which the bins are published here
* cni\overlay.exe

# What works
* Pod to Pod connectivity will work
* Pod to Pod connectivity will work (Windows to Windows)
* Outbound Internet connectivity will work
* Node port access
* Service Vip access

# Pending Validation
* Node port access
* Kubeproxy support for Overlay mode

# What will not work
* Service Vip access (There might be a workaround for this, which will be documented soon)
* Kubeproxy currently is meant for L2Bridge only. It doesnt support Overlay mode. Needs some minor work there.
* Pod to Pod connectivity (Linux to Windows)
16 changes: 16 additions & 0 deletions Kubernetes/flannel/overlay/start-kubeproxy.ps1
@@ -0,0 +1,16 @@
Param(
$NetworkName = "vxlan0",
$ManagementIP

)

$env:KUBE_NETWORK=$NetworkName.ToLower()

$sourceVipJSON = Get-Content sourceVip.json | ConvertFrom-Json
$env:SOURCE_VIP= $sourceVipJSON.ip4.ip.Split("/")[0]

$env:HOST_MAC=(Get-NetAdapter -InterfaceAlias (Get-NetIPAddress -IPAddress $ManagementIP).InterfaceAlias).MacAddress

ipmo c:\k\hns.psm1
Get-HnsPolicyList | Remove-HnsPolicyList
c:\k\kube-proxy.exe --v=4 --proxy-mode=kernelspace --hostname-override=$(hostname) --kubeconfig=c:\k\config
11 changes: 4 additions & 7 deletions Kubernetes/flannel/overlay/start.ps1
Expand Up @@ -30,9 +30,9 @@ function DownloadWindowsKubernetesScripts()
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/windows/hns.psm1 -Destination $BaseDir\hns.psm1
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/windows/InstallImages.ps1 -Destination $BaseDir\InstallImages.ps1
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/windows/Dockerfile -Destination $BaseDir\Dockerfile
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/windows/stop.ps1 -Destination $BaseDir\Stop.ps1
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/flannel/overlay/stop.ps1 -Destination $BaseDir\Stop.ps1
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/flannel/overlay/start-kubelet.ps1 -Destination $BaseDir\start-Kubelet.ps1
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/flannel/l2bridge/start-kubeproxy.ps1 -Destination $BaseDir\start-Kubeproxy.ps1
DownloadFile -Url https://github.com/Microsoft/SDN/raw/master/Kubernetes/flannel/overlay/start-kubeproxy.ps1 -Destination $BaseDir\start-Kubeproxy.ps1
}

function DownloadAllFiles()
Expand Down Expand Up @@ -79,10 +79,7 @@ if(!(Get-HnsNetwork | ? Name -EQ "External"))
# Start Flannel only after this node is registered
StartFlanneld -ipaddress $ManagementIP -NetworkName $NetworkName

GetSourceVip -ipAddress $ManagementIP -NetworkName $NetworkName
Start powershell -ArgumentList "-File $BaseDir\start-kubelet.ps1 -clusterCIDR $clusterCIDR -NetworkName $NetworkName"

# Remote endpoint should be programmed by Flanneld

# Wait for sometime to start Proxy, as it would race with Flanneld VXLan agent to program the RemoteEndpoint.
#Start-Sleep 60
#start powershell -ArgumentList " -File $BaseDir\start-kubeproxy.ps1 -NetworkName $NetworkName"
start powershell -ArgumentList " -File $BaseDir\start-kubeproxy.ps1 -NetworkName $NetworkName -ManagementIP $ManagementIP"
32 changes: 32 additions & 0 deletions Kubernetes/windows/helper.psm1
Expand Up @@ -91,9 +91,41 @@ function StartFlanneld($ipaddress, $NetworkName)
WaitForNetwork $NetworkName
}

function GetSourceVip($ipaddress, $NetworkName)
{

ipmo C:\k\HNS.V2.psm1
$hnsNetwork = Get-HnsNetwork | ? Name -EQ $NetworkName.ToLower()
$subnet = $hnsNetwork.Subnets[0].AddressPrefix

$ipamConfig = @"
{"ipam":{"type":"host-local","ranges":[[{"subnet":"$subnet"}]],"dataDir":"/var/lib/cni/networks/$NetworkName"}}
"@

$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:\k\cni" #path to host-local.exe

If(!(Test-Path c:/k/sourceVip.json)){
Get-Content sourceVipRequest.json | .\cni\host-local.exe | Out-File sourceVip.json
}

$sourceVipJSON = Get-Content sourceVip.json | ConvertFrom-Json
New-HNSEndpoint -NetworkId $hnsNetwork.ID `
-IPAddress $sourceVipJSON.ip4.ip.Split("/")[0] `
-MacAddress "00-11-22-33-44-55" `
-PAPolicy @{"PA" = $ipaddress; } `
-Verbose
}

Export-ModuleMember DownloadFile
Export-ModuleMember CleanupOldNetwork
Export-ModuleMember IsNodeRegistered
Export-ModuleMember RegisterNode
Export-ModuleMember WaitForNetwork
Export-ModuleMember GetSourceVip
Export-ModuleMember StartFlanneld

0 comments on commit 4475ce1

Please sign in to comment.