Skip to content

Commit

Permalink
Merge branch 'main' into Optimize-GH-CI-Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sumanthreddy29 authored Mar 11, 2024
2 parents e056589 + b6674ec commit b565c8f
Show file tree
Hide file tree
Showing 10 changed files with 452 additions and 291 deletions.
522 changes: 238 additions & 284 deletions modules/bash/storage/fio.sh

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions modules/terraform/azure/network/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
locals {
nsr_rules_map = { for rule in var.network_config.nsr_rules : rule.name => rule }
vnet_name = var.network_config.vnet_name
input_subnet_map = { for subnet in var.network_config.subnet : subnet.name => subnet }
subnets_map = { for subnet in azurerm_subnet.subnets : subnet.name => subnet }
network_security_group_name = var.network_config.network_security_group_name
nic_association_map = { for nic in var.network_config.nic_public_ip_associations : nic.nic_name => nic }
tags = merge(var.tags, { "role" = var.network_config.role })
nsr_rules_map = { for rule in var.network_config.nsr_rules : rule.name => rule }
nat_gateway_associations_map = var.network_config.nat_gateway_associations == null ? {} : { for nat in var.network_config.nat_gateway_associations : nat.nat_gateway_name => nat }
vnet_name = var.network_config.vnet_name
input_subnet_map = { for subnet in var.network_config.subnet : subnet.name => subnet }
subnets_map = { for subnet in azurerm_subnet.subnets : subnet.name => subnet }
network_security_group_name = var.network_config.network_security_group_name
nic_association_map = { for nic in var.network_config.nic_public_ip_associations : nic.nic_name => nic }
tags = merge(var.tags, { "role" = var.network_config.role })
}

resource "azurerm_virtual_network" "vnet" {
Expand Down Expand Up @@ -77,3 +78,15 @@ module "nsr" {
resource_group_name = var.resource_group_name
network_security_group_name = azurerm_network_security_group.nsg[0].name
}

module "nat_gateway" {
source = "./nat-gateway"
for_each = local.nat_gateway_associations_map

nat_gateway_name = each.value.nat_gateway_name
location = var.location
public_ip_address_id = var.public_ips[each.value.public_ip_name]
resource_group_name = var.resource_group_name
subnet_id = local.subnets_map[each.value.subnet_name].id
tags = local.tags
}
18 changes: 18 additions & 0 deletions modules/terraform/azure/network/nat-gateway/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "azurerm_nat_gateway" "nat_gateway" {
name = var.nat_gateway_name
location = var.location
resource_group_name = var.resource_group_name
sku_name = "Standard"

tags = var.tags
}

resource "azurerm_nat_gateway_public_ip_association" "ipng" {
nat_gateway_id = azurerm_nat_gateway.nat_gateway.id
public_ip_address_id = var.public_ip_address_id
}

resource "azurerm_subnet_nat_gateway_association" "subnetng" {
subnet_id = var.subnet_id
nat_gateway_id = azurerm_nat_gateway.nat_gateway.id
}
32 changes: 32 additions & 0 deletions modules/terraform/azure/network/nat-gateway/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
variable "resource_group_name" {
description = "Value of the resource group name"
type = string
default = "rg"
}

variable "location" {
description = "Value of the location"
type = string
default = "East US"
}

variable "nat_gateway_name" {
description = "Value of the nat gateway name"
type = string
}

variable "subnet_id" {
description = "Value of the subnet id"
type = string
}

variable "public_ip_address_id" {
description = "Value of the public ip address id"
type = string
}

variable "tags" {
type = map(string)
default = {
}
}
5 changes: 5 additions & 0 deletions modules/terraform/azure/network/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ variable "network_config" {
source_address_prefix = string
destination_address_prefix = string
}))
nat_gateway_associations = optional(list(object({
nat_gateway_name = string
public_ip_name = string
subnet_name = string
})))
})
}

Expand Down
5 changes: 5 additions & 0 deletions modules/terraform/azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ variable "network_config_list" {
source_address_prefix = string
destination_address_prefix = string
}))
nat_gateway_associations = optional(list(object({
nat_gateway_name = string
public_ip_name = string
subnet_name = string
})))
}))
default = []
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sudo perl -pi -e 's/^#?Port 22$/Port 2222/' /etc/ssh/sshd_config
sudo service ssh restart

sudo apt-get update && sudo apt-get install iperf -y
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

sudo perl -pi -e 's/^#?Port 22$/Port 2222/' /etc/ssh/sshd_config
sudo service ssh restart

sudo apt-get update && sudo apt-get install iperf -y

nohup iperf --server --port 20001 &> /dev/null &
nohup iperf --server --udp --port 20002 &> /dev/null &
111 changes: 111 additions & 0 deletions scenarios/perf-eval/nat-gateway-iperf/terraform-inputs/azure.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
scenario_type = "perf-eval"
scenario_name = "nat-gateway-iperf"
deletion_delay = "2h"
public_ip_config_list = [
{
name = "server-vm-pip"
},
{
name = "client-vm-pip"
},
{
name = "nat-gateway-pip"
}
]
network_config_list = [
{
role = "network"
vnet_name = "same-vnet"
vnet_address_space = "10.2.0.0/16"
subnet = [{
name = "same-subnet"
address_prefix = "10.2.1.0/24"
}]
network_security_group_name = "same-nsg"
nic_public_ip_associations = [
{
nic_name = "server-nic"
subnet_name = "same-subnet"
ip_configuration_name = "server-ipconfig"
public_ip_name = "server-vm-pip"
},
{
nic_name = "client-nic"
subnet_name = "same-subnet"
ip_configuration_name = "client-ipconfig"
public_ip_name = "client-vm-pip"
}
]
nsr_rules = [{
name = "nsr-ssh"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "2222"
source_address_prefix = "*"
destination_address_prefix = "*"
},
{
name = "nsr-tcp"
priority = 101
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "20001-20001"
source_address_prefix = "*"
destination_address_prefix = "*"
},
{
name = "nsr-udp"
priority = 102
direction = "Inbound"
access = "Allow"
protocol = "Udp"
source_port_range = "*"
destination_port_range = "20002-20002"
source_address_prefix = "*"
destination_address_prefix = "*"
}
],
nat_gateway_associations = [{
nat_gateway_name = "nat-gateway"
subnet_name = "same-subnet"
public_ip_name = "nat-gateway-pip"
}]
}
]
loadbalancer_config_list = []
vm_config_list = [{
role = "client"
vm_name = "client-vm"
nic_name = "client-nic"
admin_username = "ubuntu"
zone = "1"
source_image_reference = {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-focal"
sku = "20_04-lts"
version = "latest"
}
create_vm_extension = true
},
{
role = "server"
vm_name = "server-vm"
nic_name = "server-nic"
admin_username = "ubuntu"
zone = "2"
source_image_reference = {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-focal"
sku = "20_04-lts"
version = "latest"
}
create_vm_extension = true
}
]
vmss_config_list = []
nic_backend_pool_association_list = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner" : "terraform_unit_tests",
"run_id" : "123456789",
"region" : "eastus",
"machine_type" : "Standard_D16_v5",
"zone" : "1",
"accelerated_networking" : true
}

0 comments on commit b565c8f

Please sign in to comment.