-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6b8ecd
commit f2e011e
Showing
1 changed file
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#r "nuget:Farmer" | ||
|
||
open Farmer | ||
open Farmer.Builders | ||
open Farmer.LoadBalancer | ||
open Farmer.Arm.Network | ||
open Farmer.Arm.LoadBalancer | ||
|
||
let (lb:LoadBalancer) = { | ||
Name = ResourceName "lb-test" | ||
Location = Location.EastUS | ||
Sku = { Name = Sku.Standard; Tier = Tier.Regional } | ||
FrontendIpConfigs = [ | ||
{| | ||
Name = ResourceName "LoadBalancerFrontend" | ||
PublicIp = Some (publicIPAddresses.resourceId "lb-test-pip") | ||
PrivateIpAllocationMethod = PrivateIpAddress.DynamicPrivateIp | ||
|} | ||
] | ||
BackendAddressPools = [ ResourceName "containerGroups" ] | ||
LoadBalancingRules = [ | ||
{| | ||
Name = ResourceName "hw-rule" | ||
BackendAddressPool = ResourceName "containerGroups" | ||
BackendPort = 8080us | ||
FrontendPort = 80us | ||
Protocol = Some TransmissionProtocol.TCP | ||
DisableOutboundSnat = None | ||
EnableTcpReset = None | ||
FrontendIpConfiguration = ResourceName "LoadBalancerFrontend" | ||
IdleTimeoutMinutes = None | ||
LoadDistribution = LoadDistributionPolicy.Default | ||
Probe = Some (ResourceName "checkHttp") | ||
|} | ||
] | ||
Probes = [ | ||
{| | ||
Name = ResourceName "checkHttp" | ||
Port = 8080us | ||
Protocol = LoadBalancerProbeProtocol.HTTP | ||
RequestPath = "/" | ||
IntervalInSeconds = 15 | ||
NumberOfProbes = 2 | ||
|} | ||
] | ||
Dependencies = Set.empty | ||
Tags = Map.empty | ||
} | ||
|
||
let backendPool = | ||
{ | ||
Name = ResourceName "containerGroups" | ||
LoadBalancer = lb.Name | ||
LoadBalancerBackendAddresses = [ | ||
{| | ||
Name = ResourceName "group1" | ||
IpAddress = System.Net.IPAddress.Parse "10.0.1.4" | ||
VirtualNetwork = Some (virtualNetworks.resourceId "ha-container-group-vnet") | ||
|} | ||
{| | ||
Name = ResourceName "group2" | ||
IpAddress = System.Net.IPAddress.Parse "10.0.1.5" | ||
VirtualNetwork = Some (virtualNetworks.resourceId "ha-container-group-vnet") | ||
|} | ||
] | ||
} | ||
|
||
arm { | ||
location Location.EastUS | ||
add_resources [ | ||
vnet { | ||
name "my-vnet" | ||
add_address_spaces [ "10.0.1.0/24" ] | ||
add_subnets [ | ||
subnet { | ||
name "my-services" | ||
prefix "10.0.1.0/24" | ||
add_delegations [ | ||
SubnetDelegationService.ContainerGroups | ||
] | ||
} | ||
] | ||
} | ||
loadBalancer { | ||
name "lb" | ||
sku Sku.Standard | ||
add_frontends [ | ||
frontend { | ||
name "lb-frontend" | ||
public_ip "lb-pip" | ||
} | ||
] | ||
add_backend_pools [ | ||
backendAddressPool { | ||
name "lb-backend" | ||
link_to_vnet "my-vnet" | ||
load_balancer "lb" | ||
add_ip_addresses [ | ||
"10.0.1.4" | ||
"10.0.1.5" | ||
] | ||
} | ||
] | ||
add_probes [ | ||
loadBalancerProbe { | ||
name "httpGet" | ||
protocol LoadBalancerProbeProtocol.HTTP | ||
port 8080 | ||
request_path "/" | ||
} | ||
] | ||
add_rules [ | ||
loadBalancingRule { | ||
name "rule1" | ||
frontend_ip_config "lb-frontend" | ||
backend_address_pool "lb-backend" | ||
frontend_port 80 | ||
backend_port 8080 | ||
protocol TransmissionProtocol.TCP | ||
probe "httpGet" | ||
} | ||
] | ||
add_dependencies [ | ||
Farmer.Arm.Network.virtualNetworks.resourceId "my-vnet" | ||
] | ||
} | ||
] | ||
} |> Writer.quickWrite "loadbalancer" |