How to: configure K2 NLB port rules with PowerShell

Long time ago I did a video and blog post on configuring Windows NLB K2 cluster. I know that those materials are not perfect, but thanks to blogging you not only can be subject of mockeries for mistakes and naivety in your old posts, but also you can review and improve on them over time 🙂

Anyhow my old blog post on creating K2 NLB cluster contained this neat picture of required port rules:

As I tread my test K2 environments as “wipe and load”-ready and subject them to all sort of experiments leading to wipe and load and rebuilds I grow tired of creating this rules via GUI. Thanks to PowerShell and Microsoft Community it is not a problem to find a sample script to create Windows NLB cluster. I actually wanted to rewrite it with minor improvements and K2 specifics to spin off K2 NLB cluster quicker but due to endless lack of time this idea moved on the back-burner. What I did instead though is prepared PS script to create port rules:

$InterfaceName = "Ethernet"
$ClusterPrimaryIP = "192.168.100.116"

#Removing default port rule for the NLB Cluster
Write-Host "Removing default port rule..." -ForegroundColor yellow
Get-NlbClusterPortRule -HostName . -ErrorAction SilentlyContinue | `
Remove-NlbClusterPortRule -Force -ErrorAction SilentlyContinue
#Adding SmartForms/Workspace rule for port 80 HTTP
Write-Host "Adding port rule for HTTP (TCP 80)" -ForegroundColor yellow
Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 80 `
-EndPort 80 -Timeout 1 -InterfaceName $InterfaceName -IP $ClusterPrimaryIP| Out-Null
#Adding SmartForms/Workspace rule for port 443
Write-Host "Adding port rule for HTTPS (TCP 443)" -ForegroundColor yellow
Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 443 `
-EndPort 443 -Timeout 1 -InterfaceName $InterfaceName -IP $ClusterPrimaryIP| Out-Null
#Adding blackpearl rule for port 5252 - K2 workflow client connections
Write-Host "Adding blackpearl port rule for port 5252" -ForegroundColor yellow
Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity None -StartPort 5252 `
-EndPort 5252 -InterfaceName $InterfaceName -IP $ClusterPrimaryIP| Out-Null
#Adding blackpearl rule for port 5555 - K2 Host Server connections from client assemblies
Write-Host "Adding blackpearl port rule for port 5555" -ForegroundColor yellow
Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity None -StartPort 5555 `
-EndPort 5555 -InterfaceName $InterfaceName -IP $ClusterPrimaryIP| Out-Null
Write-Host "Rules configuration compoleted" -ForegroundColor green

That’s help a bit when I rebuilding my test environment. You can grab this script from GitHub too.

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *