Created
October 1, 2018 18:36
-
-
Save jmaitrehenry/0e242765d9dfa8e0447cc30e509187c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"vnetName": { | |
"type": "string", | |
"defaultValue": "vnet_monitoring", | |
"metadata": { | |
"description": "VNet name" | |
} | |
}, | |
"vnetAddressPrefix": { | |
"type": "string", | |
"metadata": { | |
"description": "Address prefix" | |
} | |
}, | |
"SubnetName": { | |
"type": "string", | |
"defaultValue": "sb_mon_docker", | |
"metadata": { | |
"description": "Docker mon Subnet name" | |
} | |
}, | |
"adminUserName": { | |
"type": "string", | |
"defaultValue": "ansible", | |
"metadata": { | |
"description": "Admin User name for the Virtual Machine." | |
} | |
}, | |
"sshKeyData": { | |
"type": "string", | |
"metadata": { | |
"description": "SSH rsa public key file as a string." | |
} | |
}, | |
"numberOfNodes": { | |
"type": "int" | |
}, | |
"lbName": { | |
"type": "string", | |
"defaultValue": "loadbalancer-docker", | |
"metadata": { | |
"description": "Load Balancer name" | |
} | |
} | |
}, | |
"variables": { | |
"api-version": "2015-06-15", | |
"publicIPAddress": "dockerswarm-externalLoadBalancer-public-ip", | |
"vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', parameters('vnetName'))]", | |
"mgmtSubnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('SubnetName'))]", | |
"diagnosticsStorageAccountName": "[concat('diaglogs', uniqueString(subscription().subscriptionId))]", | |
"vmPrefix": "vm-docker-", | |
"pipPrefix": "pip-docker-", | |
"nicPrefix": "nic-docker-", | |
"nicLoopPrefix": "nicLoop", | |
"extLoopPrefix": "extLoop", | |
"osDiskNamePrefix": "osdisk-docker-", | |
"availSetPrefix": "availset-docker-", | |
"subnetParts": "[split(parameters('vnetAddressPrefix'), '.')]", | |
"subnetPrefix": "[concat(variables('subnetParts')[0], '.', variables('subnetParts')[1], '.0.')]", | |
"lbID": "[resourceId('Microsoft.Network/loadBalancers',parameters('lbName'))]", | |
"nicLoop": "nicloop-docker", | |
"dockerVMs": { | |
"docker": { | |
"vmName": "[concat(variables('vmPrefix'), 'docker')]", | |
"vmSize": "Standard_B1ms", | |
"vmPip": "[concat(variables('pipPrefix'), 'docker')]", | |
"vmNic": "[concat(variables('nicPrefix'), 'docker')]", | |
"osDiskName": "[concat(variables('osDiskNamePrefix'), 'docker')]", | |
"availSetName": "[concat(variables('availSetPrefix'), 'docker')]", | |
"staticIPStart": 11 | |
} | |
}, | |
"availSetName": "[concat(variables('availSetPrefix'), 'docker')]", | |
"nicLoop": "[concat(variables('nicLoopPrefix'), 'docker')]", | |
"extLoop": "[concat(variables('extLoopPrefix'), 'docker')]" | |
}, | |
"resources": [ | |
{ | |
"apiVersion": "2015-06-15", | |
"type": "Microsoft.Network/virtualNetworks", | |
"name": "[parameters('vnetName')]", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"[parameters('vnetAddressPrefix')]" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "[parameters('SubnetName')]", | |
"properties": { | |
"addressPrefix": "10.0.0.0/24" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"comments": "Availability Set for Docker", | |
"type": "Microsoft.Compute/availabilitySets", | |
"name": "[variables('availSetName')]", | |
"apiVersion": "2016-04-30-preview", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"platformFaultDomainCount": 2, | |
"platformUpdateDomainCount": 5, | |
"managed": "true" | |
} | |
}, | |
{ | |
"name": "[concat(variables('dockerVMs').docker.vmNic, copyIndex())]", | |
"type": "Microsoft.Network/networkInterfaces", | |
"apiVersion": "2016-09-01", | |
"copy": { | |
"name": "[variables('nicLoop')]", | |
"count": "[parameters('numberOfNodes')]" | |
}, | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')))]" | |
], | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ipconfig1", | |
"properties": { | |
"subnet": { | |
"id": "[variables('mgmtSubnetRef')]" | |
}, | |
"loadBalancerBackendAddressPools": [ | |
{ | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/backendAddressPools/loadBalancerBackEnd')]" | |
} | |
], | |
"privateIPAllocationMethod": "Static", | |
"privateIPAddress": "[concat(variables('subnetPrefix'), add(copyIndex(), variables('dockerVMs').docker.staticIPStart))]" | |
} | |
} | |
], | |
"dnsSettings": { | |
"dnsServers": [], | |
"internalDnsNameLabel": "[concat(variables('dockerVMs').docker.vmName, copyIndex())]" | |
}, | |
"enableIPForwarding": false | |
} | |
}, | |
{ | |
"name": "[concat(variables('dockerVMs').docker.vmName, copyIndex())]", | |
"type": "Microsoft.Compute/virtualMachines", | |
"apiVersion": "2016-04-30-preview", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Compute/availabilitySets/', variables('availSetName'))]", | |
"[resourceId('Microsoft.Network/networkInterfaces/', concat(variables('dockerVMs').docker.vmNic, copyIndex()))]" | |
], | |
"copy": { | |
"name": "[variables('nicLoop')]", | |
"count": "[parameters('numberOfNodes')]" | |
}, | |
"properties": { | |
"availabilitySet": { | |
"id": "[resourceId('Microsoft.Compute/availabilitySets/', variables('availSetName'))]" | |
}, | |
"osProfile": { | |
"computerName": "[concat(variables('dockerVMs').docker.vmName, copyIndex())]", | |
"adminUsername": "[parameters('adminUsername')]", | |
"linuxConfiguration": { | |
"disablePasswordAuthentication": true, | |
"ssh": { | |
"publicKeys": [ | |
{ | |
"path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]", | |
"keyData": "[parameters('sshKeyData')]" | |
} | |
] | |
} | |
} | |
}, | |
"hardwareProfile": { | |
"vmSize": "[variables('dockerVMs').docker.vmSize]" | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "CoreOS", | |
"offer": "CoreOS", | |
"sku": "Alpha", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"createOption": "fromImage", | |
"managedDisk": { | |
"storageAccountType": "Premium_LRS" | |
} | |
} | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('dockerVMs').docker.vmNic, copyIndex()))]" | |
} | |
] | |
}, | |
"diagnosticsProfile": { | |
"bootDiagnostics": { | |
"enabled": false | |
} | |
} | |
} | |
}, | |
{ | |
"apiVersion": "[variables('api-version')]", | |
"type": "Microsoft.Compute/virtualMachines/extensions", | |
"name": "[concat(variables('dockerVMs').docker.vmName, copyindex(), '/enablevmaccess')]", | |
"copy": { | |
"name": "[variables('extLoop')]", | |
"count": "[parameters('numberOfNodes')]" | |
}, | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[concat('Microsoft.Compute/virtualMachines/', concat(variables('dockerVMs').docker.vmName, copyIndex()))]" | |
], | |
"properties": { | |
"publisher": "Microsoft.OSTCExtensions", | |
"type": "VMAccessForLinux", | |
"typeHandlerVersion": "1.4", | |
"autoUpgradeMinorVersion": "true", | |
"settings": {}, | |
"protectedSettings": {} | |
} | |
}, | |
{ | |
"comments": "Load Balancer for Swarm", | |
"type": "Microsoft.Network/loadBalancers", | |
"name": "[parameters('lbName')]", | |
"apiVersion": "2017-03-01", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"frontendIPConfigurations": [ | |
{ | |
"name": "LoadBalancerFrontEnd", | |
"properties": { | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses/',variables('publicIPAddress'))]" | |
} | |
} | |
} | |
], | |
"backendAddressPools": [ | |
{ | |
"name": "loadBalancerBackEnd" | |
} | |
], | |
"loadBalancingRules": [ | |
{ | |
"name": "HTTP", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/frontendIpConfigurations/loadBalancerFrontEnd')]" | |
}, | |
"frontendPort": 80, | |
"backendPort": 80, | |
"enableFloatingIP": false, | |
"idleTimeoutInMinutes": 4, | |
"protocol": "Tcp", | |
"loadDistribution": "Default", | |
"backendAddressPool": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/backendAddressPools/loadBalancerBackEnd')]" | |
}, | |
"probe": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/probes/lbprobe')]" | |
} | |
} | |
}, | |
{ | |
"name": "HTTPs", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/frontendIpConfigurations/loadBalancerFrontEnd')]" | |
}, | |
"frontendPort": 443, | |
"backendPort": 443, | |
"enableFloatingIP": false, | |
"idleTimeoutInMinutes": 4, | |
"protocol": "Tcp", | |
"loadDistribution": "Default", | |
"backendAddressPool": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/backendAddressPools/loadBalancerBackEnd')]" | |
}, | |
"probe": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/probes/lbprobe')]" | |
} | |
} | |
}, | |
{ | |
"name": "Dashboard", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/frontendIpConfigurations/loadBalancerFrontEnd')]" | |
}, | |
"frontendPort": 8080, | |
"backendPort": 8080, | |
"enableFloatingIP": false, | |
"idleTimeoutInMinutes": 4, | |
"protocol": "Tcp", | |
"loadDistribution": "Default", | |
"backendAddressPool": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/backendAddressPools/loadBalancerBackEnd')]" | |
}, | |
"probe": { | |
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('lbName')), '/probes/lbprobe')]" | |
} | |
} | |
} | |
], | |
"probes": [ | |
{ | |
"name": "lbprobe", | |
"properties": { | |
"protocol": "Tcp", | |
"port": 8080, | |
"intervalInSeconds": 5, | |
"numberOfProbes": 2 | |
} | |
} | |
], | |
"inboundNatRules": [], | |
"outboundNatRules": [], | |
"inboundNatPools": [] | |
}, | |
"dependsOn": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment