Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
13.96k stars 16.09k forks source link

101-acs-mesos - Deploy to an existing vnet #1314

Open Jaykah opened 8 years ago

Jaykah commented 8 years ago

Hi,

I am trying to deploy an ACS cluster to an existing Vnet.

So far I have something that looks like this:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "dnsNamePrefix": {
            "type": "string",
            "metadata": {
                "description": "Sets the Domain name prefix for the jumpbox.  The concatenation of the domain name, component, and the regionalized DNS zone make up the fully qualified domain name associated with the public IP address."
            }
        },
        "agentCount": {
            "type": "int",
            "defaultValue": 1,
            "metadata": {
                "description": "The number of Mesos agents for the cluster.  This value can be from 1 to 40"
            },
            "minValue": 1,
            "maxValue": 100
        },
        "agentVMSize": {
            "type": "string",
            "defaultValue": "Standard_D2",
            "allowedValues": [
                "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5",
                "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11",
                "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4",
                "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14",
                "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2",
                "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2",
                "Standard_G1", "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5",
                "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4",
                "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14",
                "Standard_GS1", "Standard_GS2", "Standard_GS3", "Standard_GS4", "Standard_GS5"
            ],
            "metadata": {
                "description": "The size of the Virtual Machine."
            }
        },
        "linuxAdminUsername": {
            "type": "string",
            "defaultValue": "azureuser",
            "metadata": {
                "description": "User name for the Linux Virtual Machines."
            }
        },
        "orchestratorType": {
            "type": "string",
            "defaultValue": "Mesos",
            "allowedValues": [
                "Mesos",
                "SwarmPreview"
            ],
            "metadata": {
                "description": "The type of orchestrator used to manage the applications on the cluster."
            }
        },
        "masterCount": {
            "type": "int",
            "defaultValue": 1,
            "allowedValues": [
                1,
                3,
                5
            ],
            "metadata": {
                "description": "The number of Mesos masters for the cluster."
            }
        },
        "sshRSAPublicKey": {
            "type": "string",
            "metadata": {
                "description": "Configure all linux machines with the SSH RSA public key string.  Your key should include three parts, for example 'ssh-rsa AAAAB...snip...UcyupgH azureuser@linuxvm'"
            }
        },
        "existingVirtualNetworkName": {
            "type": "string",
            "metadata": {
                "description": "Name of the existing VNET"
            }
        },
        "existingVirtualNetworkResourceGroup": {
            "type": "string",
            "metadata": {
                "description": "Name of the existing VNET resource group"
            }
        },
        "subnetName": {
            "type": "string",
            "metadata": {
                "description": "Name of the subnet in the virtual network you want to use"
            }
        }
    },
    "variables": {
        "api-version": "2015-11-01-preview",
        "publicIPAddressType": "Dynamic",
        "vnetID": "[resourceId(parameters('existingVirtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('existingVirtualNetworkName'))]",
        "subnetRef": "[concat(variables('vnetID'),'/subnets/', parameters('subnetName'))]",
        "adminUsername": "[parameters('linuxAdminUsername')]",
        "agentCount": "[parameters('agentCount')]",
        "agentsEndpointDNSNamePrefix": "[concat(parameters('dnsNamePrefix'),'agents')]",
        "agentVMSize": "[parameters('agentVMSize')]",
        "masterCount": "[parameters('masterCount')]",
        "mastersEndpointDNSNamePrefix": "[concat(parameters('dnsNamePrefix'),'mgmt')]",
        "orchestratorType": "[parameters('orchestratorType')]",
        "sshRSAPublicKey": "[parameters('sshRSAPublicKey')]"
    },
    "resources": [{
        "apiVersion": "[variables('api-version')]",
        "type": "Microsoft.ContainerService/containerServices",
        "location": "[resourceGroup().location]",
        "name": "[concat('containerservice-',resourceGroup().name)]",
        "dependsOn": [
            "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
        ],
        "properties": {
            "orchestratorProfile": {
                "orchestratorType": "[variables('orchestratorType')]"
            },
            "masterProfile": {
                "count": "[variables('masterCount')]",
                "dnsPrefix": "[variables('mastersEndpointDNSNamePrefix')]"
            },
            "agentPoolProfiles": [{
                "name": "agentpools",
                "count": "[variables('agentCount')]",
                "vmSize": "[variables('agentVMSize')]",
                "dnsPrefix": "[variables('agentsEndpointDNSNamePrefix')]"
            }],
            "linuxProfile": {
                "adminUsername": "[variables('adminUsername')]",
                "ssh": {
                    "publicKeys": [{
                        "keyData": "[variables('sshRSAPublicKey')]"
                    }]
                }
            }
        }
    },  {
        "apiVersion": "[variables('api-version')]",
        "type": "Microsoft.Network/networkInterfaces",
        "name": "[variables('nicName')]",
        "location": "[parameters('location')]",
        "dependsOn": [
            "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
        ],
        "tags": {
            "displayName": "NetworkInterface"
        },
        "properties": {
            "ipConfigurations": [{
                "name": "ipconfig1",
                "properties": {
                    "privateIPAllocationMethod": "Dynamic",
                    "publicIPAddress": {
                        "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
                    },
                    "subnet": {
                        "id": "[variables('subnetRef')]"
                    }
                }
            }]
        }
    }],
    "outputs": {
        "masterFQDN": {
            "type": "string",
            "value": "[reference(concat('Microsoft.ContainerService/containerServices/', 'containerservice-', resourceGroup().name)).masterProfile.fqdn]"
        },
        "sshMaster0": {
            "type": "string",
            "value": "[concat('ssh ', variables('adminUsername'), '@', reference(concat('Microsoft.ContainerService/containerServices/', 'containerservice-', resourceGroup().name)).masterProfile.fqdn, ' -A -p 2200')]"
        },
        "agentFQDN": {
            "type": "string",
            "value": "[reference(concat('Microsoft.ContainerService/containerServices/', 'containerservice-', resourceGroup().name)).agentPoolProfiles[0].fqdn]"
        }
    }
}

However I get:

Deployment template validation failed: 'The template variable 'nicName' is not found. Please see http://aka.ms/arm-template/#variables for usage details.'.

I assume I mixed up the templates somehow, an I am curious if there is an easier way to accomplish what I am trying to do.

singhkays commented 8 years ago

@Jaykah You don't have a variable called 'nicName' in the variables section.

Jaykah commented 8 years ago

After fixing that I have tried a variety of other options but nothing seemed to work.

I currently have the following template (with a custom VHD and network settings):

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "vmSSName": {
            "type": "string"
        },
        "userImageStorageAccountName": {
            "type": "string",
            "metadata": {
                "description": "This is the name of the your storage account"
            }
        },
        "osDiskVhdUri": {
              "type": "string",
              "metadata": {
                "description": "Uri of the your user image"
            }
        },
        "dnsNamePrefix": {
            "type": "string",
            "metadata": {
                "description": "Sets the Domain name prefix for the cluster.  The concatenation of the domain name and the regionalized DNS zone make up the fully qualified domain name associated with the public IP address."
            }
        },
        "agentCount": {
            "type": "int",
            "defaultValue": 1,
            "metadata": {
                "description": "The number of Mesos agents for the cluster.  This value can be from 1 to 40"
            },
            "minValue": 1,
            "maxValue": 100
        },
        "agentVMSize": {
            "type": "string",
            "defaultValue": "Standard_D2",
            "allowedValues": [
                "Standard_A0",
                "Standard_A1",
                "Standard_A2",
                "Standard_A3",
                "Standard_A4",
                "Standard_A5",
                "Standard_A6",
                "Standard_A7",
                "Standard_A8",
                "Standard_A9",
                "Standard_A10",
                "Standard_A11",
                "Standard_D1",
                "Standard_D2",
                "Standard_D3",
                "Standard_D4",
                "Standard_D11",
                "Standard_D12",
                "Standard_D13",
                "Standard_D14",
                "Standard_D1_v2",
                "Standard_D2_v2",
                "Standard_D3_v2",
                "Standard_D4_v2",
                "Standard_D5_v2",
                "Standard_D11_v2",
                "Standard_D12_v2",
                "Standard_D13_v2",
                "Standard_D14_v2",
                "Standard_G1",
                "Standard_G2",
                "Standard_G3",
                "Standard_G4",
                "Standard_G5",
                "Standard_DS1",
                "Standard_DS2",
                "Standard_DS3",
                "Standard_DS4",
                "Standard_DS11",
                "Standard_DS12",
                "Standard_DS13",
                "Standard_DS14",
                "Standard_GS1",
                "Standard_GS2",
                "Standard_GS3",
                "Standard_GS4",
                "Standard_GS5"
            ],
            "metadata": {
                "description": "The size of the Virtual Machine."
            }
        },
        "linuxAdminUsername": {
            "type": "string",
            "defaultValue": "azureuser",
            "metadata": {
                "description": "User name for the Linux Virtual Machines."
            }
        },
        "orchestratorType": {
            "type": "string",
            "defaultValue": "Mesos",
            "allowedValues": [
                "Mesos",
                "SwarmPreview"
            ],
            "metadata": {
                "description": "The type of orchestrator used to manage the applications on the cluster."
            }
        },
        "masterCount": {
            "type": "int",
            "defaultValue": 1,
            "allowedValues": [
                1,
                3,
                5
            ],
            "metadata": {
                "description": "The number of Mesos masters for the cluster."
            }
        },
        "sshRSAPublicKey": {
            "type": "string",
            "metadata": {
                "description": "Configure all linux machines with the SSH RSA public key string.  Your key should include three parts, for example 'ssh-rsa AAAAB...snip...UcyupgH azureuser@linuxvm'"
            }
        }
    },
    "variables": {
        "addressPrefix": "10.42.0.0/16",
        "subnetName": "subnet",
        "subnetPrefix": "10.42.0.0/24",
        "virtualNetworkName": "my-vnet",
        "location": "[resourceGroup().location]",
        "adminUsername": "[parameters('linuxAdminUsername')]",
        "agentCount": "[parameters('agentCount')]",
        "agentsEndpointDNSNamePrefix": "[concat(parameters('dnsNamePrefix'),'agents')]",
        "agentVMSize": "[parameters('agentVMSize')]",
        "masterCount": "[parameters('masterCount')]",
        "mastersEndpointDNSNamePrefix": "[concat(parameters('dnsNamePrefix'),'mgmt')]",
        "orchestratorType": "[parameters('orchestratorType')]",
        "sshRSAPublicKey": "[parameters('sshRSAPublicKey')]",
        "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[variables('addressPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[variables('subnetName')]",
                        "properties": {
                            "addressPrefix": "[variables('subnetPrefix')]"
                        }
                    }
                ]
            }
    },
    "resources": [
    {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[variables('virtualNetworkName')]",
            "location": "[variables('location')]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[variables('addressPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[variables('subnetName')]",
                        "properties": {
                            "addressPrefix": "[variables('subnetPrefix')]"
                        }
                    }
                ]
            }
        },
        {
            "apiVersion": "2015-11-01-preview",
            "type": "Microsoft.ContainerService/containerServices",
            "location": "[resourceGroup().location]",
            "name": "[concat('containerservice-',resourceGroup().name)]",
            "dependsOn": [
                "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
            ],
            "properties": {
                "orchestratorProfile": {
                    "orchestratorType": "[variables('orchestratorType')]"
                },
                "masterProfile": {
                    "count": "[variables('masterCount')]",
                    "dnsPrefix": "[variables('mastersEndpointDNSNamePrefix')]"
                },
                "agentPoolProfiles": [
                    {
                        "name": "agentpools",
                        "count": "[variables('agentCount')]",
                        "vmSize": "[variables('agentVMSize')]",
                        "dnsPrefix": "[variables('agentsEndpointDNSNamePrefix')]"
                    }
                ],
                "linuxProfile": {
                    "adminUsername": "[variables('adminUsername')]",
                    "ssh": {
                        "publicKeys": [
                            {
                                "keyData": "[variables('sshRSAPublicKey')]"
                            }
                        ]
                    }
                },
                "networkProfile": {
                    "networkInterfaceConfigurations": [
                        {
                            "name": "nic1",
                            "properties": {
                                "primary": "true",
                                "ipConfigurations": [
                                    {
                                        "name": "ip1",
                                        "properties": {
                                            "subnet": {
                                                "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'), '/subnets/', variables('subnetName'))]"
                                            }
                                        }
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        }
    ],
    "outputs": {
        "masterFQDN": {
            "type": "string",
            "value": "[reference(concat('Microsoft.ContainerService/containerServices/', 'containerservice-', resourceGroup().name)).masterProfile.fqdn]"
        },
        "sshMaster0": {
            "type": "string",
            "value": "[concat('ssh ', variables('adminUsername'), '@', reference(concat('Microsoft.ContainerService/containerServices/', 'containerservice-', resourceGroup().name)).masterProfile.fqdn, ' -A -p 2200')]"
        },
        "agentFQDN": {
            "type": "string",
            "value": "[reference(concat('Microsoft.ContainerService/containerServices/', 'containerservice-', resourceGroup().name)).agentPoolProfiles[0].fqdn]"
        }
    }
}

And now I get the following error:

statusCode:BadRequest statusMessage:{"error":{"code":"BadRequest","target":"containerService.properties.networkProfile","message":"Could not find member 'networkProfile' on object of type 'Properties'. Path 'properties.networkProfile', line 1, position 744."}}

Are custom network profiles unsupported for ACS?

Jaykah commented 8 years ago

Hate to ping it, but would really appreciate some feedback on that one.

Thanks!

singhkays commented 8 years ago

I don't see network profile in the ACS API/templates so that could be the reason. https://github.com/Azure/azure-quickstart-templates/blob/master/101-acs-mesos/azuredeploy.json

Jaykah commented 8 years ago

I was under the impression that templates define resources and thus can be customized as long as those resources exist, or am I mistaken?