Introduction
In Azure there are two “generations” (so to speak) ;
- “Service Management” : the backend of the “old” portal
- “Resource Manager” : the backend of the “new” portal
The technology underneath differs quite a bit…Though the “Azure Resource Manager” (or “ARM”) has the possibility to work with templates for deployments.
In the last blog post, I showed you how you can deploy nodes in Azure from your Rancher host. Today we’ll do it the other way around… We’ll deploy hosts using an “ARM”-template and will connect back to our Rancher host in one quick move!
Prep
First thing to do is go to your Rancher host and select “Add host”. Browse to “Custom” and note the api URL shown in step #4.
For Example
Note this one down, as we’ll be needing it in a bit…
Depoying via an ARM-template
Getting the API link was the “hard” part, and now comes the easy stuff! Browse to the following BitBucket repository ; https://bitbucket.org/kvaes/azure-rancher
This contains the deployment template(s). To make it real easy, I created a link in the readme markdown so that you just have to click it.
After clicking on the “Deploy to Azure”, you’ll be redirected to the “new portal” and asked to provide the parameters you want to use for this deployment…
The following parameters are available (source for the paranoia ones) ;
- newstorageaccountname ; the name of the newly created storage account that will host all the new hosts
- admin username & password ; the credentials to login to your host
- dnsnameforpublicip ; the name of the public ip
- rancherapi ; here you enter the URL we just copied from the Rancher host!
- ranchernodename ; the prefix hostname for all the hosts you’ll be deploying
- ranchercount ; the amount of hosts your want to deploy
Enter all the information… Select a region & subscription. Create / select a resource group. Accept the legal mumbo jumbo and press Create. Now wait a while…Feel free to follow up on the deployment.
And the nodes will pop up in Rancher!
The Cool Stuff
For the deployment of the Rancher agent, I’m relying on the native DockerExtension of Azure!
{ "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(parameters('rancherNodeName'), copyIndex(),'/', variables('extensionName'))]", "apiVersion": "2015-06-15", "location": "[resourceGroup().location]", "copy": { "name": "extLoopNode", "count": "[parameters('rancherCount')]" }, "dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', parameters('rancherNodeName'), copyIndex())]" ], "properties": { "publisher": "Microsoft.Azure.Extensions", "type": "DockerExtension", "typeHandlerVersion": "1.0", "autoUpgradeMinorVersion": true, "settings": { "docker": { "port": "2375" }, "compose": { "rancheragent": { "image": "rancher/agent:v0.8.2", "restart": "always", "privileged": true, "volumes": [ "/var/run/docker.sock:/var/run/docker.sock" ], "command": "[parameters('rancherApi')]" } } } }
Hostname Fix!
I forgot to add the index number to the computername. So the Rancher screenshot shows four hosts with the same name, where the update of the script has fixed that.
TL;DR
- We used ARM to deploy Docker hosts
- We used the Azure DockerExtension to deploy our Rancher agent
- We learned that ARM templates can be used in an easy manner too!
That’s amazing ! Thanks for making the scripts.