Skip to content

Commit 607900a

Browse files
author
kumarvna
committed
initial commit
1 parent 701414b commit 607900a

File tree

1 file changed

+199
-0
lines changed

1 file changed

+199
-0
lines changed

examples/README.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Azure Virtual Machines Scale Sets
2+
3+
Azure virtual machine scale sets let you create and manage a group of identical, load balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule. Scale sets provide high availability to your applications, and allow you to centrally manage, configure, and update a large number of VMs.
4+
5+
This module deploys Windows or Linux virtual machine scale sets with Public / Private Load Balancer support and many other features.
6+
7+
## Module Usage
8+
9+
### Linux Virtual Machines Scale Sets
10+
11+
Following example to create Linux virtual machine scale sets with load balancer and auto scaling features.
12+
13+
```hcl
14+
module "vmscaleset" {
15+
source = "kumarvna/vm-scale-sets/azurerm"
16+
version = "1.0.0"
17+
18+
# Resource Group and location, VNet and Subnet detials (Required)
19+
resource_group_name = "rg-hub-demo-internal-shared-westeurope-001"
20+
virtual_network_name = "vnet-default-hub-westeurope"
21+
subnet_name = "snet-management-default-hub-westeurope"
22+
vmscaleset_name = "testvmss"
23+
24+
# (Optional) To enable Azure Monitoring and install log analytics agents
25+
log_analytics_workspace_name = var.log_analytics_workspace_id
26+
hub_storage_account_name = var.hub_storage_account_id
27+
28+
# This module support multiple Pre-Defined Linux and Windows Distributions.
29+
# These distributions support the Automatic OS image upgrades in virtual machine scale sets
30+
# Linux images: ubuntu1804, ubuntu1604, centos75, coreos
31+
# Windows Images: windows2012r2dc, windows2016dc, windows2019dc, windows2016dccore
32+
# Specify the RSA key for production workloads and set generate_admin_ssh_key argument to false
33+
# When you use Autoscaling feature, instances_count will become default and minimum instance count.
34+
os_flavor = "linux"
35+
windows_distribution_name = "ubuntu1804"
36+
generate_admin_ssh_key = false
37+
admin_ssh_key_data = "~/.ssh/id_rsa.pub"
38+
instances_count = 2
39+
40+
# Public and private load balancer support for VM scale sets
41+
# Specify health probe port to allow LB to detect the backend endpoint status
42+
# Standard Load Balancer helps load-balance TCP and UDP flows on all ports simultaneously
43+
# Specify the list of ports based on your requirement for Load balanced ports
44+
# for additional data disks, provide the list for required size for the disk.
45+
load_balancer_type = "public"
46+
load_balancer_health_probe_port = 80
47+
load_balanced_port_list = [80, 443]
48+
additional_data_disks = [100, 200]
49+
50+
# Enable Auto scaling feature for VM scaleset by set argument to true. P
51+
# Instances_count in VMSS will become default and minimum instance count.
52+
# Automatically scale out the number of VM instances based on CPU Average only.
53+
enable_autoscale_for_vmss = true
54+
minimum_instances_count = 2
55+
maximum_instances_count = 5
56+
scale_out_cpu_percentage_threshold = 80
57+
scale_in_cpu_percentage_threshold = 20
58+
59+
# Network Seurity group port allow definitions for each Virtual Machine
60+
# NSG association to be added automatically for all network interfaces.
61+
# SSH port 22 and 3389 is exposed to the Internet recommended for only testing.
62+
# For production environments, we recommend using a VPN or private connection
63+
nsg_inbound_rules = [
64+
{
65+
name = "http"
66+
destination_port_range = "80"
67+
source_address_prefix = "*"
68+
},
69+
70+
{
71+
name = "https"
72+
destination_port_range = "443"
73+
source_address_prefix = "*"
74+
},
75+
]
76+
77+
# Adding TAG's to your Azure resources (Required)
78+
# ProjectName and Env are already declared above, to use them here, create a varible.
79+
tags = {
80+
ProjectName = "demo-internal"
81+
Env = "dev"
82+
83+
BusinessUnit = "CORP"
84+
ServiceClass = "Gold"
85+
}
86+
}
87+
```
88+
89+
### Windows Virtual Machines Scale Sets
90+
91+
Following example to create Windows virtual machine scale sets with load balancer and auto scaling features.
92+
93+
```hcl
94+
module "vmscaleset" {
95+
source = "kumarvna/vm-scale-sets/azurerm"
96+
version = "1.0.0"
97+
98+
# Resource Group and location, VNet and Subnet detials (Required)
99+
resource_group_name = "rg-hub-demo-internal-shared-westeurope-001"
100+
virtual_network_name = "vnet-default-hub-westeurope"
101+
subnet_name = "snet-management-default-hub-westeurope"
102+
vmscaleset_name = "testvmss"
103+
104+
# (Optional) To enable Azure Monitoring and install log analytics agents
105+
log_analytics_workspace_name = var.log_analytics_workspace_id
106+
hub_storage_account_name = var.hub_storage_account_id
107+
108+
# This module support multiple Pre-Defined Linux and Windows Distributions.
109+
# These distributions support the Automatic OS image upgrades in virtual machine scale sets
110+
# Linux images: ubuntu1804, ubuntu1604, centos75, coreos
111+
# Windows Images: windows2012r2dc, windows2016dc, windows2019dc, windows2016dccore
112+
# Specify the RSA key for production workloads and set generate_admin_ssh_key argument to false
113+
# When you use Autoscaling feature, instances_count will become default and minimum instance count.
114+
os_flavor = "windows"
115+
windows_distribution_name = "windows2019dc"
116+
instances_count = 2
117+
admin_username = "azureadmin"
118+
admin_password = "complex_password"
119+
120+
# Public and private load balancer support for VM scale sets
121+
# Specify health probe port to allow LB to detect the backend endpoint status
122+
# Standard Load Balancer helps load-balance TCP and UDP flows on all ports simultaneously
123+
# Specify the list of ports based on your requirement for Load balanced ports
124+
# for additional data disks, provide the list for required size for the disk.
125+
load_balancer_type = "public"
126+
load_balancer_health_probe_port = 80
127+
load_balanced_port_list = [80, 443]
128+
additional_data_disks = [100, 200]
129+
130+
# Enable Auto scaling feature for VM scaleset by set argument to true.
131+
# Instances_count in VMSS will become default and minimum instance count.
132+
# Automatically scale out the number of VM instances based on CPU Average only.
133+
enable_autoscale_for_vmss = true
134+
minimum_instances_count = 2
135+
maximum_instances_count = 5
136+
scale_out_cpu_percentage_threshold = 80
137+
scale_in_cpu_percentage_threshold = 20
138+
139+
# Network Seurity group port allow definitions for each Virtual Machine
140+
# NSG association to be added automatically for all network interfaces.
141+
# SSH port 22 and 3389 is exposed to the Internet recommended for only testing.
142+
# For production environments, we recommend using a VPN or private connection
143+
nsg_inbound_rules = [
144+
{
145+
name = "http"
146+
destination_port_range = "80"
147+
source_address_prefix = "*"
148+
},
149+
150+
{
151+
name = "https"
152+
destination_port_range = "443"
153+
source_address_prefix = "*"
154+
},
155+
]
156+
157+
# Adding TAG's to your Azure resources (Required)
158+
# ProjectName and Env are already declared above, to use them here, create a varible.
159+
tags = {
160+
ProjectName = "demo-internal"
161+
Env = "dev"
162+
163+
BusinessUnit = "CORP"
164+
ServiceClass = "Gold"
165+
}
166+
}
167+
```
168+
169+
## Terraform Usage
170+
171+
To run this example you need to execute following Terraform commands
172+
173+
```hcl
174+
terraform init
175+
terraform plan
176+
terraform apply
177+
```
178+
179+
Run `terraform destroy` when you don't need these resources.
180+
181+
## Outputs
182+
183+
|Name | Description|
184+
|---- | -----------|
185+
`admin_ssh_key_public`|The generated public key data in PEM format
186+
`admin_ssh_key_private`|The generated private key data in PEM format
187+
`windows_vm_password`|Password for the windows Virtual Machine
188+
`load_balancer_public_ip`|The Public IP address allocated for load balancer
189+
`load_balancer_private_ip`|The Private IP address allocated for load balancer
190+
`load_balancer_nat_pool_id`|The resource ID of the Load Balancer NAT pool
191+
`load_balancer_health_probe_id`|The resource ID of the Load Balancer health Probe
192+
`load_balancer_rules_id`|The resource ID of the Load Balancer Rule
193+
`network_security_group_id`|The resource id of Network security group
194+
`linux_virtual_machine_scale_set_name`|The name of the Linux Virtual Machine Scale Set
195+
`linux_virtual_machine_scale_set_id`|The resource ID of the Linux Virtual Machine Scale Set
196+
`linux_virtual_machine_scale_set_unique_id`|The unique ID of the Linux Virtual Machine Scale Set
197+
`windows_virtual_machine_scale_set_name`|The name of the windows Virtual Machine Scale Set
198+
`windows_virtual_machine_scale_set_id`|The resource ID of the windows Virtual Machine Scale Set
199+
`windows_virtual_machine_scale_set_unique_id`|The unique ID of the windows Virtual Machine Scale Set

0 commit comments

Comments
 (0)