Azure剛剛釋出在同一個Cloud Service下支援多個公網IP地址的功能。
這個功能主要是用於:
當相同的埠需要公用相同的LoadBalance時。
比如:
一種使用場景是多組Web伺服器被一組安全裝置保護,每組伺服器有自己獨立的IP地址,如下圖:
這時需要:
-
為CloudService新增多個VIP地址:
PS C:\Users\hengz> Add-AzureVirtualIP -ServiceName hwmvip -VirtualIPName vip1
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Add-AzureVirtualIP 14a912b8-5f03-4ecd-aecb-f97e679553e1 SucceededPS C:\Users\hengz> Add-AzureVirtualIP -ServiceName hwmvip -VirtualIPName vip2
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Add-AzureVirtualIP f9014c8f-d72d-4bad-ae3d-2ffa28e24ce1 Succeeded -
建立三組不同的SLB和LBS,分別用原有的VIP和新增加的VIP
PS C:\Users\hengz> Get-AzureVM -ServiceName hwmvip -Name hwmvip01 | Add-AzureEndpoint -Name myEndpoint01 -LoadBalancedEndpointSetName myLBSet01 -Protocol tcp -LocalPort 80 -PublicPort 80 -VirtualIPName vip1 -DefaultProbe | Update-AzureVM
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Update-AzureVM 20ec6266-ad18-4dd3-b6c3-35643e32ed16 Succeeded
PS C:\Users\hengz> Get-AzureVM -ServiceName hwmvip -Name hwmvip02 | add-AzureEndpoint -Name myEndpoint00 -LBSetName myLBSet01 -Protocol tcp -LocalPort 80 -PublicPort 80 -DefaultProbe -VirtualIPName vip1 | Update-AzureVM
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Update-AzureVM fd406797-3d41-4b74-b030-40c5674e6364 Succeeded
PS C:\Users\hengz> Get-AzureVM -ServiceName hwmvip -Name hwmvip01 | add-AzureEndpoint -Name myEndpoint02 -LBSetName myLBSet02 -Protocol tcp -PublicPort 80 -LocalPort 81 -DefaultProbe | Update-AzureVM
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Update-AzureVM 57df6a8b-473d-48e3-8b93-44d6e80f5b6e Succeeded
PS C:\Users\hengz> Get-AzureVM -ServiceName hwmvip -Name hwmvip02 | add-AzureEndpoint -Name myEndpoint02 -LBSetName myLBSet02 -Protocol tcp -PublicPort 80 -LocalPort 81 -DefaultProbe | Update-AzureVM
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Update-AzureVM 8f304e3b-0745-430a-ad2d-b112d0883e16 Succeeded
PS C:\Users\hengz> Get-AzureVM -ServiceName hwmvip -Name hwmvip01 | Add-AzureEndpoint -Name myEndpoint03 -LoadBalancedEndpointSetName myLBSet03 -Protocol tcp -LocalPort 82 -PublicPort 80 -VirtualIPName vip2 -DefaultProbe | Update-AzureVM
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Update-AzureVM 57f7bcc3-b09e-482d-85f7-704c552c69f9 Succeeded
PS C:\Users\hengz> Get-AzureVM -ServiceName hwmvip -Name hwmvip02 | Add-AzureEndpoint -Name myEndpoint013 -LoadBalancedEndpointSetName myLBSet03 -Protocol tcp -LocalPort 82 -PublicPort 80 -VirtualIPName vip2 -DefaultProbe | Update-AzureVM
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Update-AzureVM 14bc4198-5ba5-445d-8682-40c779e253ea Succeeded
3. 檢視配置情況:
PS C:\Users\hengz> $mvip = Get-AzureDeployment -ServiceName hwmvip
PS C:\Users\hengz> $mvip.VirtualIPs
Address : 42.159.28.150
IsDnsProgrammed : True
Name : hwmvip01ContractContract
ReservedIPName :
ExtensionData :
Address : 42.159.29.129
IsDnsProgrammed :
Name : vip1
ReservedIPName :
ExtensionData :
Address : 42.159.29.4
IsDnsProgrammed :
Name : vip2
ReservedIPName :
ExtensionData :
PS C:\Users\hengz> get-azurevm -ServiceName hwmvip -Name hwmvip01 | Get-AzureEndpoint
LBSetName : myLBSet01
LocalPort : 80
Name : myEndpoint01
Port : 80
Protocol : tcp
Vip : 42.159.29.129
ProbePath :
ProbePort : 80
ProbeProtocol : tcp
ProbeIntervalInSeconds : 15
ProbeTimeoutInSeconds : 31
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : vip1
LBSetName : myLBSet02
LocalPort : 81
Name : myEndpoint02
Port : 80
Protocol : tcp
Vip : 42.159.28.150
ProbePath :
ProbePort : 81
ProbeProtocol : tcp
ProbeIntervalInSeconds : 15
ProbeTimeoutInSeconds : 31
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : hwmvip01ContractContract
LBSetName : myLBSet03
LocalPort : 82
Name : myEndpoint03
Port : 80
Protocol : tcp
Vip : 42.159.29.4
ProbePath :
ProbePort : 82
ProbeProtocol : tcp
ProbeIntervalInSeconds : 15
ProbeTimeoutInSeconds : 31
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : vip2
LBSetName :
LocalPort : 22
Nme : SSH
Port : 22122
Protocol : tcp
Vip : 42.159.28.150
ProbePath :
ProbePort : 0
ProbeProtocol :
ProbeIntervalInSeconds :
ProbeTimeoutInSeconds :
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : hwmvip01ContractContract
PS C:\Users\hengz> get-azurevm -ServiceName hwmvip -Name hwmvip02 | Get-AzureEndpoint
LBSetName : myLBSet01
LocalPort : 80
Name : myEndpoint00
Port : 80
Protocol : tcp
Vip :
ProbePath :
ProbePort : 80
ProbeProtocol : tcp
ProbeIntervalInSeconds : 15
ProbeTimeoutInSeconds : 31
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : vip1
LBSetName : myLBSet03
LocalPort : 82
Name : myEndpoint013
Port : 80
Protocol : tcp
Vip :
ProbePath :
ProbePort : 82
ProbeProtocol : tcp
ProbeIntervalInSeconds : 15
ProbeTimeoutInSeconds : 31
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : vip2
LBSetName : myLBSet02
LocalPort : 81
Name : myEndpoint02
Port : 80
Protocol : tcp
Vip : 42.159.28.150
ProbePath :
ProbePort : 81
ProbeProtocol : tcp
ProbeIntervalInSeconds : 15
ProbeTimeoutInSeconds : 31
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : hwmvip01ContractContract
LBSetName :
LocalPort : 22
Name : SSH
Port : 22222
Protocol : tcp
Vip : 42.159.28.150
ProbePath :
ProbePort : 0
ProbeProtocol :
ProbeIntervalInSeconds :
ProbeTimeoutInSeconds :
EnableDirectServerReturn : False
Acl : {}
InternalLoadBalancerName :
IdleTimeoutInMinutes :
LoadBalancerDistribution :
VirtualIPName : hwmvip01ContractContract
可以看到我們預期的配置在兩臺伺服器上實現了。兩臺伺服器各屬於3個不同的負載均衡組,三個負載均衡組各對應一個IP地址,對外發布的埠號都是80。
至此配置結束。