Skip to content

Commit 72253dd

Browse files
Azure Deployment Setup (#124)
Co-authored-by: Akshay Shekhawat <[email protected]>
1 parent c894125 commit 72253dd

File tree

6 files changed

+539
-4
lines changed

6 files changed

+539
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ ingestors/python/.idea
2222
ingestors/java/spring/.gradle/
2323
ingestors/java/spring/.idea/
2424
ingestors/java/spring/gradle.properties
25-
ingestors/java/spring/target/
25+
ingestors/java/spring/target/
26+
27+
.meta/*

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@
9191
<hr>
9292
</details>
9393

94+
<details>
95+
<summary><strong>Deploy to Azure →</strong></summary>
96+
<hr>
97+
<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">
98+
<img src="https://aka.ms/deploytoazurebutton" scale="0" height="40"/>
99+
</a>
100+
<hr>
101+
</details>
102+
94103
**Deploy with Docker**
95104

96105
Run the following in your cloud environment:

deploy/azure/deployment.bicep

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
@description('Name for the Metlo Instance')
2+
param vmName string = 'Metlo-Manager'
3+
4+
var adminUsername = 'azureuser'
5+
6+
var authenticationType = 'sshPublicKey'
7+
8+
@description('SSH Key or password for the Virtual Machine. SSH key is recommended.')
9+
@secure()
10+
param adminPasswordOrKey string
11+
12+
var dnsLabelPrefix = toLower('${vmName}-${uniqueString(resourceGroup().id)}')
13+
14+
@description('Location for all resources. Leave as default to take value from resource group')
15+
param location string = resourceGroup().location
16+
17+
var vmSize = 'Standard_B2s'
18+
19+
var virtualNetworkName = 'metloVNet'
20+
21+
var subnetName = 'metloSubnet'
22+
23+
var networkSecurityGroupName = 'metloSecGroupNet'
24+
25+
var customDataName = 'metloPostDeploymentScript'
26+
// var customData = '[base64("sudo metlo init-env && sudo metlo update && sudo metlo start")]'
27+
28+
var publicIPAddressName = '${vmName}PublicIP'
29+
var networkInterfaceName = '${vmName}NetInt'
30+
var osDiskType = 'Standard_LRS'
31+
var subnetAddressPrefix = '10.1.0.0/24'
32+
var addressPrefix = '10.1.0.0/16'
33+
var linuxConfiguration = {
34+
disablePasswordAuthentication: true
35+
ssh: {
36+
publicKeys: [
37+
{
38+
path: '/home/${adminUsername}/.ssh/authorized_keys'
39+
keyData: adminPasswordOrKey
40+
}
41+
]
42+
}
43+
}
44+
45+
resource nic 'Microsoft.Network/networkInterfaces@2021-05-01' = {
46+
name: networkInterfaceName
47+
location: location
48+
properties: {
49+
ipConfigurations: [
50+
{
51+
name: 'ipconfig1'
52+
properties: {
53+
subnet: {
54+
id: subnet.id
55+
}
56+
privateIPAllocationMethod: 'Dynamic'
57+
publicIPAddress: {
58+
id: publicIP.id
59+
}
60+
}
61+
}
62+
]
63+
networkSecurityGroup: {
64+
id: nsg.id
65+
}
66+
}
67+
}
68+
69+
resource nsg 'Microsoft.Network/networkSecurityGroups@2021-05-01' = {
70+
name: networkSecurityGroupName
71+
location: location
72+
properties: {
73+
securityRules: [
74+
{
75+
name: 'MetloSSH'
76+
properties: {
77+
priority: 1000
78+
protocol: 'Tcp'
79+
access: 'Allow'
80+
direction: 'Inbound'
81+
sourceAddressPrefix: '*'
82+
sourcePortRange: '*'
83+
destinationAddressPrefix: '*'
84+
destinationPortRange: '22'
85+
}
86+
}
87+
{
88+
name: 'Metlo-Collector'
89+
properties: {
90+
priority: 1001
91+
protocol: 'Tcp'
92+
access: 'Allow'
93+
direction: 'Inbound'
94+
sourceAddressPrefix: '*'
95+
sourcePortRange: '*'
96+
destinationAddressPrefix: '*'
97+
destinationPortRange: '8081'
98+
}
99+
}
100+
{
101+
name: 'Metlo-Frontend-10-8'
102+
properties: {
103+
priority: 1002
104+
protocol: 'Tcp'
105+
access: 'Allow'
106+
direction: 'Inbound'
107+
sourceAddressPrefix: '10.0.0.0/8'
108+
sourcePortRange: '*'
109+
destinationAddressPrefix: '*'
110+
destinationPortRange: '8000'
111+
}
112+
}
113+
{
114+
name: 'Metlo-Frontend-172.16-12'
115+
properties: {
116+
priority: 1003
117+
protocol: 'Tcp'
118+
access: 'Allow'
119+
direction: 'Inbound'
120+
sourceAddressPrefix: '172.16.0.0/12'
121+
sourcePortRange: '*'
122+
destinationAddressPrefix: '*'
123+
destinationPortRange: '8000'
124+
}
125+
}
126+
{
127+
name: 'Metlo-Frontend-192.168-16'
128+
properties: {
129+
priority: 1004
130+
protocol: 'Tcp'
131+
access: 'Allow'
132+
direction: 'Inbound'
133+
sourceAddressPrefix: '192.168.0.0/16'
134+
sourcePortRange: '*'
135+
destinationAddressPrefix: '*'
136+
destinationPortRange: '8000'
137+
}
138+
}
139+
]
140+
}
141+
}
142+
143+
resource vnet 'Microsoft.Network/virtualNetworks@2021-05-01' = {
144+
name: virtualNetworkName
145+
location: location
146+
properties: {
147+
addressSpace: {
148+
addressPrefixes: [
149+
addressPrefix
150+
]
151+
}
152+
}
153+
}
154+
155+
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-05-01' = {
156+
parent: vnet
157+
name: subnetName
158+
properties: {
159+
addressPrefix: subnetAddressPrefix
160+
privateEndpointNetworkPolicies: 'Enabled'
161+
privateLinkServiceNetworkPolicies: 'Enabled'
162+
}
163+
}
164+
165+
resource publicIP 'Microsoft.Network/publicIPAddresses@2021-05-01' = {
166+
name: publicIPAddressName
167+
location: location
168+
sku: {
169+
name: 'Basic'
170+
}
171+
properties: {
172+
publicIPAllocationMethod: 'Dynamic'
173+
publicIPAddressVersion: 'IPv4'
174+
dnsSettings: {
175+
domainNameLabel: dnsLabelPrefix
176+
}
177+
idleTimeoutInMinutes: 4
178+
}
179+
}
180+
181+
resource vm 'Microsoft.Compute/virtualMachines@2021-11-01' = {
182+
name: vmName
183+
location: location
184+
properties: {
185+
userData: ''
186+
hardwareProfile: {
187+
vmSize: vmSize
188+
}
189+
storageProfile: {
190+
osDisk: {
191+
createOption: 'FromImage'
192+
managedDisk: {
193+
storageAccountType: osDiskType
194+
}
195+
}
196+
imageReference: {
197+
publisher: 'Canonical'
198+
offer: 'UbuntuServer'
199+
sku: '18.04-LTS'
200+
version: 'latest'
201+
}
202+
}
203+
networkProfile: {
204+
networkInterfaces: [
205+
{
206+
id: nic.id
207+
}
208+
]
209+
}
210+
osProfile: {
211+
computerName: vmName
212+
adminUsername: adminUsername
213+
adminPassword: adminPasswordOrKey
214+
linuxConfiguration: ((authenticationType == 'password') ? null : linuxConfiguration)
215+
}
216+
}
217+
}
218+
219+
resource script 'Microsoft.Compute/virtualMachines/extensions@2022-08-01' = {
220+
name: format('{0}/{1}', vmName, customDataName)
221+
location: location
222+
dependsOn: [ vm ]
223+
properties: {
224+
publisher: 'Microsoft.OSTCExtensions'
225+
type: 'CustomScriptForLinux'
226+
typeHandlerVersion: '1.2'
227+
settings: {
228+
fileUris: [
229+
'https://raw.githubusercontent.com/metlo-labs/metlo/master/deploy/deploy_script.sh'
230+
]
231+
commandToExecute: 'sudo /bin/bash deploy_script.sh'
232+
}
233+
}
234+
}
235+
236+
output adminUsername string = adminUsername
237+
output hostname string = publicIP.properties.dnsSettings.fqdn
238+
output sshCommand string = 'ssh ${adminUsername}@${publicIP.properties.dnsSettings.fqdn}'

0 commit comments

Comments
 (0)