Skip to content

Commit

Permalink
Azure Deployment Setup (#124)
Browse files Browse the repository at this point in the history
Co-authored-by: Akshay Shekhawat <[email protected]>
  • Loading branch information
AHarmlessPyro and akshay288 authored Nov 17, 2022
1 parent c894125 commit 72253dd
Show file tree
Hide file tree
Showing 6 changed files with 539 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ ingestors/python/.idea
ingestors/java/spring/.gradle/
ingestors/java/spring/.idea/
ingestors/java/spring/gradle.properties
ingestors/java/spring/target/
ingestors/java/spring/target/

.meta/*
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@
<hr>
</details>

<details>
<summary><strong>Deploy to Azure →</strong></summary>
<hr>
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmetlo-labs%2Fmetlo%2Fmaster%2Fdeploy%2Fazure%2Fdeployment.json" target="_blank">
<img src="https://aka.ms/deploytoazurebutton" scale="0" height="40"/>
</a>
<hr>
</details>

**Deploy with Docker**

Run the following in your cloud environment:
Expand Down
238 changes: 238 additions & 0 deletions deploy/azure/deployment.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
@description('Name for the Metlo Instance')
param vmName string = 'Metlo-Manager'

var adminUsername = 'azureuser'

var authenticationType = 'sshPublicKey'

@description('SSH Key or password for the Virtual Machine. SSH key is recommended.')
@secure()
param adminPasswordOrKey string

var dnsLabelPrefix = toLower('${vmName}-${uniqueString(resourceGroup().id)}')

@description('Location for all resources. Leave as default to take value from resource group')
param location string = resourceGroup().location

var vmSize = 'Standard_B2s'

var virtualNetworkName = 'metloVNet'

var subnetName = 'metloSubnet'

var networkSecurityGroupName = 'metloSecGroupNet'

var customDataName = 'metloPostDeploymentScript'
// var customData = '[base64("sudo metlo init-env && sudo metlo update && sudo metlo start")]'

var publicIPAddressName = '${vmName}PublicIP'
var networkInterfaceName = '${vmName}NetInt'
var osDiskType = 'Standard_LRS'
var subnetAddressPrefix = '10.1.0.0/24'
var addressPrefix = '10.1.0.0/16'
var linuxConfiguration = {
disablePasswordAuthentication: true
ssh: {
publicKeys: [
{
path: '/home/${adminUsername}/.ssh/authorized_keys'
keyData: adminPasswordOrKey
}
]
}
}

resource nic 'Microsoft.Network/networkInterfaces@2021-05-01' = {
name: networkInterfaceName
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
subnet: {
id: subnet.id
}
privateIPAllocationMethod: 'Dynamic'
publicIPAddress: {
id: publicIP.id
}
}
}
]
networkSecurityGroup: {
id: nsg.id
}
}
}

resource nsg 'Microsoft.Network/networkSecurityGroups@2021-05-01' = {
name: networkSecurityGroupName
location: location
properties: {
securityRules: [
{
name: 'MetloSSH'
properties: {
priority: 1000
protocol: 'Tcp'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '*'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '22'
}
}
{
name: 'Metlo-Collector'
properties: {
priority: 1001
protocol: 'Tcp'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '*'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '8081'
}
}
{
name: 'Metlo-Frontend-10-8'
properties: {
priority: 1002
protocol: 'Tcp'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '10.0.0.0/8'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '8000'
}
}
{
name: 'Metlo-Frontend-172.16-12'
properties: {
priority: 1003
protocol: 'Tcp'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '172.16.0.0/12'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '8000'
}
}
{
name: 'Metlo-Frontend-192.168-16'
properties: {
priority: 1004
protocol: 'Tcp'
access: 'Allow'
direction: 'Inbound'
sourceAddressPrefix: '192.168.0.0/16'
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '8000'
}
}
]
}
}

resource vnet 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
}
}

resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-05-01' = {
parent: vnet
name: subnetName
properties: {
addressPrefix: subnetAddressPrefix
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}

resource publicIP 'Microsoft.Network/publicIPAddresses@2021-05-01' = {
name: publicIPAddressName
location: location
sku: {
name: 'Basic'
}
properties: {
publicIPAllocationMethod: 'Dynamic'
publicIPAddressVersion: 'IPv4'
dnsSettings: {
domainNameLabel: dnsLabelPrefix
}
idleTimeoutInMinutes: 4
}
}

resource vm 'Microsoft.Compute/virtualMachines@2021-11-01' = {
name: vmName
location: location
properties: {
userData: ''
hardwareProfile: {
vmSize: vmSize
}
storageProfile: {
osDisk: {
createOption: 'FromImage'
managedDisk: {
storageAccountType: osDiskType
}
}
imageReference: {
publisher: 'Canonical'
offer: 'UbuntuServer'
sku: '18.04-LTS'
version: 'latest'
}
}
networkProfile: {
networkInterfaces: [
{
id: nic.id
}
]
}
osProfile: {
computerName: vmName
adminUsername: adminUsername
adminPassword: adminPasswordOrKey
linuxConfiguration: ((authenticationType == 'password') ? null : linuxConfiguration)
}
}
}

resource script 'Microsoft.Compute/virtualMachines/extensions@2022-08-01' = {
name: format('{0}/{1}', vmName, customDataName)
location: location
dependsOn: [ vm ]
properties: {
publisher: 'Microsoft.OSTCExtensions'
type: 'CustomScriptForLinux'
typeHandlerVersion: '1.2'
settings: {
fileUris: [
'https://raw.githubusercontent.com/metlo-labs/metlo/master/deploy/deploy_script.sh'
]
commandToExecute: 'sudo /bin/bash deploy_script.sh'
}
}
}

output adminUsername string = adminUsername
output hostname string = publicIP.properties.dnsSettings.fqdn
output sshCommand string = 'ssh ${adminUsername}@${publicIP.properties.dnsSettings.fqdn}'
Loading

0 comments on commit 72253dd

Please sign in to comment.