Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions vms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Container OpenHack temporary VM

## Included Utilities

* [Git](https://git-scm.com/)
* [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest)
* [Kubectl](https://kubernetes.io/docs/reference/kubectl/overview/)
* [Helm](https://helm.sh/)

## Linux VM deployment

```bash
az group create -n <rgname> -l <region>
az deployment group create -g <rgname> -n <deploymentName> --template-file linux/azuredeploy.json --parameters linux/azuredeploy.parameters.json
```
259 changes: 259 additions & 0 deletions vms/linux/azuredeploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourcePrefix": {
"type": "string",
"defaultValue": "openhack",
"metadata": {
"description": "Globally Unique Prefix"
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "User name for the Virtual Machine."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"ubuntuOSVersion": {
"type": "string",
"defaultValue": "18.04-LTS",
"allowedValues": [
"12.04.5-LTS",
"14.04.2-LTS",
"15.10",
"16.04-LTS",
"18.04-LTS"
],
"metadata": {
"description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version. Allowed values: 12.04.5-LTS, 14.04.2-LTS, 15.10."
}
},
"vnetPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "Address Prefix"
}
},
"subnetName": {
"type": "string",
"defaultValue": "Default",
"metadata": {
"description": "Subnet Name"
}
},
"subnetPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/24",
"metadata": {
"description": "Subnet Prefix"
}
},
"scriptUri" : {
"type" : "string",
"metadata": {
"description" : "URI for the script file to be used to set up the Linux VM"
}
},
"scriptName" : {
"type" : "string",
"metadata": {
"description" : "The name of the script file to be used to set up the Linux VM"
}
}
},
"variables": {
"vnetName": "[concat(parameters('resourcePrefix'), '-VNET')]",
"nsgName": "[concat(parameters('resourcePrefix'), '-NSG')]",
"nicName": "[concat(parameters('resourcePrefix'), '-VM-NIC')]",
"vmName": "[concat(parameters('resourcePrefix'), '-VM')]",
"publicIPAddressName": "[concat(parameters('resourcePrefix'), '-PIP')]",
"publicIPAddressType": "Dynamic",
"dnsNameForPublicIP": "[concat(parameters('resourcePrefix'), uniquestring(resourceGroup().id), '-pip')]",
"subnetRef": "[concat(resourceId('Microsoft.Network/virtualNetworks',variables('vnetName')),'/subnets/',parameters('subnetName'))]",
"vmSize": "Standard_DS2_v2",
"imagePublisher": "Canonical",
"imageOffer": "UbuntuServer",
"extensionName": "vmSetupScript"
},
"resources": [
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[variables('nsgName')]",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "ssh_rule",
"properties": {
"description": "Allow SSH",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "Internet",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 100,
"direction": "Inbound"
}
},
{
"name": "allow-app-endpoints",
"properties": {
"description": "allow-app-endpoints",
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "3000-3010",
"sourceAddressPrefix": "Internet",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 101,
"direction": "Inbound"
}
}
]
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('vnetName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('vnetPrefix')]"
]
},
"subnets": [
{
"name": "[parameters('subnetName')]",
"properties": {
"addressPrefix": "[parameters('subnetPrefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
}
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[variables('dnsNameForPublicIP')]"
}
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[parameters('ubuntuOSVersion')]",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
}
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'), '/', variables('extensionName'))]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[parameters('scriptUri')]"
]
},
"protectedSettings": {
"commandToExecute": "[concat('sh', ' ', parameters('scriptName'), ' ', parameters('adminUsername'))]"
}
}
}
],
"outputs": {
"instanceView": {
"type": "object",
"value": "[reference(resourceId('Microsoft.Compute/virtualMachines/extensions', variables('vmName'), variables('extensionName'))).instanceView]"
}
}
}
30 changes: 30 additions & 0 deletions vms/linux/azuredeploy.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"ubuntuOSVersion": {
"value": "18.04-LTS"
},
"resourcePrefix": {
"value": "openhack"
},
"adminUsername": {
"value": "openhack"
},
"vnetPrefix": {
"value": "10.0.0.0/16"
},
"subnetName": {
"value": "Default"
},
"subnetPrefix": {
"value": "10.0.0.0/24"
},
"scriptUri" : {
"value": "https://raw.githubusercontent.com/Azure-Samples/openhack-containers/master/vms/linux/config.sh"
},
"scriptName" : {
"value": "config.sh"
}
}
}
38 changes: 38 additions & 0 deletions vms/linux/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# install az cli
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

# install kubectl
az aks install-cli

# install docker (https://docs.docker.com/engine/install/ubuntu/)
sudo apt-get upgrade

sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

sudo apt-get install docker-ce docker-ce-cli containerd.io -y

# install helm (https://helm.sh/docs/intro/install/)
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3

chmod +x get_helm.sh

./get_helm.sh

rm get_helm.sh

# clone git repo
git clone https://github.com/Azure-Samples/openhack-containers.git