Skip to content

Instantly share code, notes, and snippets.

@adilsonbna
Last active December 30, 2018 18:11
Show Gist options
  • Save adilsonbna/3cc3d7b51677c4e85b941cf1df3bb3fc to your computer and use it in GitHub Desktop.
Save adilsonbna/3cc3d7b51677c4e85b941cf1df3bb3fc to your computer and use it in GitHub Desktop.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"spClientId": {
"type": "string",
"defaultValue": "YOUR Client appId",
"metadata": {
"description": "Service Principal Client ID used by Jenkins and Azure Container Service (AKS)."
}
},
"spClientSecret": {
"type": "securestring",
"defaultValue": "YOUR SECRET PASSWORD",
"metadata": {
"description": "Service Principal Client Secret used by Jenkins and Azure Container Service(AKS)."
}
},
"linuxAdminUsername": {
"type": "string",
"defaultValue": "YOUR USER",
"metadata": {
"description": "User name for the Linux Virtual Machines (Jenkins and Kubernetes)."
}
},
"linuxAdminPassword": {
"type": "securestring",
"defaultValue": "YOUR PASSWORD",
"metadata": {
"description": "Password for the Jenkins and Grafana Virtual Machines."
}
},
"linuxSSHPublicKey": {
"type": "string",
"defaultValue": "YOUR SSH KEY",
"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'"
}
},
"cosmosDbName": {
"type": "string",
"defaultValue": "acscosmosdb",
"metadata": {
"description": "Name of the CosmosDB."
}
},
"acrName": {
"type": "string",
"defaultValue": "acsimages",
"metadata": {
"description": "Name of the Azure Container Registery. The name may contain alpha numeric characters only and must be between 5 and 50 characters."
}
},
"jenkinsDnsPrefix": {
"type": "string",
"defaultValue": "acsjenkins",
"metadata": {
"description": "Unique DNS Name for the Public IP used to access the Jenkins Virtual Machine."
}
},
"grafanaDnsPrefix": {
"type": "string",
"defaultValue": "acsgrafana",
"metadata": {
"description": "Unique DNS Name for the Public IP used to access the Grafana Virtual Machine."
}
},
"kubernetesDnsPrefix": {
"type": "string",
"defaultValue": "acskube",
"metadata": {
"description": "Optional DNS prefix to use with hosted Kubernetes API server FQDN."
}
},
"kubernetesClusterName": {
"type": "string",
"defaultValue": "acskubecluster",
"metadata": {
"description": "The name of the Managed Cluster resource."
}
},
"kubernetesAgentCount": {
"type": "int",
"defaultValue": 1,
"metadata": {
"description": "The number of nodes for the cluster."
},
"minValue": 1,
"maxValue": 50
},
"kubernetesAgentVMSize": {
"type": "string",
"defaultValue": "Standard_D2_v2",
"allowedValues": [
"Standard_A10",
"Standard_A11",
"Standard_A2",
"Standard_A2_v2",
"Standard_A2m_v2",
"Standard_A3",
"Standard_A4",
"Standard_A4_v2",
"Standard_A4m_v2",
"Standard_A5",
"Standard_A6",
"Standard_A7",
"Standard_A8",
"Standard_A8_v2",
"Standard_A8m_v2",
"Standard_A9",
"Standard_D1_v2",
"Standard_D11",
"Standard_D11_v2",
"Standard_D12",
"Standard_D12_v2",
"Standard_D13",
"Standard_D13_v2",
"Standard_D14",
"Standard_D14_v2",
"Standard_D15_v2",
"Standard_D2",
"Standard_D2_v2",
"Standard_D3",
"Standard_D3_v2",
"Standard_D4",
"Standard_D4_v2",
"Standard_D5_v2",
"Standard_DS11",
"Standard_DS11_v2",
"Standard_DS12",
"Standard_DS12_v2",
"Standard_DS13",
"Standard_DS13_v2",
"Standard_DS14",
"Standard_DS14_v2",
"Standard_DS15_v2",
"Standard_DS2",
"Standard_DS2_v2",
"Standard_DS3",
"Standard_DS3_v2",
"Standard_DS4",
"Standard_DS4_v2",
"Standard_DS5_v2",
"Standard_F16",
"Standard_F16s",
"Standard_F2",
"Standard_F2s",
"Standard_F4",
"Standard_F4s",
"Standard_F8",
"Standard_F8s",
"Standard_G1",
"Standard_G2"
],
"metadata": {
"description": "The size of the Virtual Machine."
}
},
"kubernetesVersion": {
"type": "string",
"defaultValue": "1.11.5",
"allowedValues": [
"1.11.5",
"1.11.4"
],
"metadata": {
"description": "The version of Kubernetes."
}
},
"gitRepository": {
"type": "string",
"metadata": {
"description": "URL to a public git repository that includes a Dockerfile."
},
"defaultValue": "https://github.com/Azure/azure-quickstart-templates"
},
"_artifactsLocation": {
"type": "string",
"defaultValue": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/jenkins-cicd-container/",
"metadata": {
"description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated."
}
},
"_artifactsLocationSasToken": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"jenkinsVMName": "jenkins",
"grafanaVMName": "grafana",
"cosmosDbName": "[parameters('cosmosDbName')]",
"acrName": "[parameters('acrName')]",
"virtualNetworkName": "virtual-network",
"subnetName": "default-subnet"
},
"resources": [
{
"name": "[variables('acrName')]",
"type": "Microsoft.ContainerRegistry/registries",
"location": "[parameters('location')]",
"apiVersion": "2017-10-01",
"sku": {
"name": "Basic"
},
"properties": {
"adminUserEnabled": true
}
},
{
"apiVersion": "2015-04-08",
"kind": "MongoDB",
"type": "Microsoft.DocumentDb/databaseAccounts",
"name": "[variables('cosmosDbName')]",
"location": "[parameters('location')]",
"properties": {
"databaseAccountOfferType": "Standard"
}
},
{
"apiVersion": "2016-09-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
]
}
},
{
"apiVersion": "2017-05-10",
"name": "jenkinsDeployment",
"type": "Microsoft.Resources/deployments",
"dependsOn": [
"[resourceId('Microsoft.ContainerRegistry/registries', variables('acrName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"[resourceId('Microsoft.DocumentDb/databaseAccounts', variables('cosmosDbName'))]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(parameters('_artifactsLocation'), 'nested/jenkins.json', parameters('_artifactsLocationSasToken'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"jenkinsVMName": {
"value": "[variables('jenkinsVMName')]"
},
"spClientId": {
"value": "[parameters('spClientId')]"
},
"spClientSecret": {
"value": "[parameters('spClientSecret')]"
},
"linuxAdminUsername": {
"value": "[parameters('linuxAdminUsername')]"
},
"linuxAdminPassword": {
"value": "[parameters('linuxAdminPassword')]"
},
"dnsPrefix": {
"value": "[parameters('jenkinsDnsPrefix')]"
},
"subnetId": {
"value": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
},
"gitRepository": {
"value": "[parameters('gitRepository')]"
},
"acrServer": {
"value": "[reference(resourceId('Microsoft.ContainerRegistry/registries', variables('acrName'))).loginServer]"
},
"acrUsername": {
"value": "[listCredentials(resourceId('Microsoft.ContainerRegistry/registries', variables('acrName')), '2017-10-01').username]"
},
"acrPassword": {
"value": "[listCredentials(resourceId('Microsoft.ContainerRegistry/registries', variables('acrName')), '2017-10-01').passwords[0].value]"
},
"mongoDbURI": {
"value": "[concat('mongodb://', variables('cosmosDbName'), ':', uriComponent(listKeys(resourceId('Microsoft.DocumentDb/databaseAccounts', variables('cosmosDbName')), '2015-04-08').primaryMasterKey), '@', variables('cosmosDbName'), '.documents.azure.com:10255/?ssl=true&replicaSet=globaldb')]"
},
"kubernetesResourceGroupName": {
"value": "[resourceGroup().name]"
},
"kubernetesClusterName": {
"value": "[parameters('kubernetesClusterName')]"
},
"_artifactsLocation": {
"value": "[parameters('_artifactsLocation')]"
},
"_artifactsLocationSasToken": {
"value": "[parameters('_artifactsLocationSasToken')]"
}
}
}
},
{
"apiVersion": "2017-08-31",
"type": "Microsoft.ContainerService/managedClusters",
"location": "eastus",
"name": "[parameters('kubernetesClusterName')]",
"properties": {
"kubernetesVersion": "[parameters('kubernetesVersion')]",
"dnsPrefix": "[parameters('kubernetesDnsPrefix')]",
"agentPoolProfiles": [
{
"name": "agentpool",
"osDiskSizeGB": 0,
"count": "[parameters('kubernetesAgentCount')]",
"vmSize": "[parameters('kubernetesAgentVMSize')]",
"osType": "Linux",
"storageProfile": "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "[parameters('linuxAdminUsername')]",
"ssh": {
"publicKeys": [
{
"keyData": "[parameters('linuxSSHPublicKey')]"
}
]
}
},
"servicePrincipalProfile": {
"ClientId": "[parameters('spClientId')]",
"Secret": "[parameters('spClientSecret')]"
}
}
},
{
"apiVersion": "2017-05-10",
"name": "grafanaDeployment",
"type": "Microsoft.Resources/deployments",
"dependsOn": [
"[resourceId('Microsoft.DocumentDb/databaseAccounts', variables('cosmosDbName'))]",
"[resourceId('Microsoft.ContainerService/managedClusters', parameters('kubernetesClusterName'))]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(parameters('_artifactsLocation'), 'nested/grafana.json', parameters('_artifactsLocationSasToken'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"grafanaVMName": {
"value": "[variables('grafanaVMName')]"
},
"spClientId": {
"value": "[parameters('spClientId')]"
},
"spClientSecret": {
"value": "[parameters('spClientSecret')]"
},
"linuxAdminUsername": {
"value": "[parameters('linuxAdminUsername')]"
},
"linuxAdminPassword": {
"value": "[parameters('linuxAdminPassword')]"
},
"dnsPrefix": {
"value": "[parameters('grafanaDnsPrefix')]"
},
"subnetId": {
"value": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
},
"cosmosDbName": {
"value": "[parameters('cosmosDbName')]"
},
"kubernetesClusterName": {
"value": "[parameters('kubernetesClusterName')]"
},
"_artifactsLocation": {
"value": "[parameters('_artifactsLocation')]"
},
"_artifactsLocationSasToken": {
"value": "[parameters('_artifactsLocationSasToken')]"
}
}
}
}
],
"outputs": {
"jenkinsURL": {
"type": "string",
"value": "[reference('jenkinsDeployment').outputs.jenkinsURL.value]"
},
"jenkinsSSH": {
"type": "string",
"value": "[reference('jenkinsDeployment').outputs.jenkinsSSH.value]"
},
"azureContainerRegistryUrl": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ContainerRegistry/registries', variables('acrName'))).loginServer]"
},
"kubernetesControlPlaneFQDN": {
"type": "string",
"value": "[reference(concat('Microsoft.ContainerService/managedClusters/', parameters('kubernetesClusterName'))).fqdn]"
},
"grafanaUrl": {
"type": "string",
"value": "[reference('grafanaDeployment').outputs.grafanaURL.value]"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment