Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

VirtualMachineScaleSets support for Kubernetes #2620

Merged
merged 24 commits into from
Apr 24, 2018
Merged
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
2 changes: 1 addition & 1 deletion docs/clusterdefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ A cluster can have 0 to 12 agent pool profiles. Agent Pool Profiles are used for

|Name|Required|Description|
|---|---|---|
|availabilityProfile|no|Supported values are `VirtualMachineScaleSets` (default) and `AvailabilitySet`. For Kubernetes clusters before k8s version 1.10, use `AvailabilitySet`. Otherwise, you should use `VirtualMachineScaleSets`, unless you need features such as dynamic attached disks|
|availabilityProfile|no|Supported values are `VirtualMachineScaleSets` (default) and `AvailabilitySet`. For Kubernetes clusters before version 1.10, use `AvailabilitySet`. Otherwise, you should use `VirtualMachineScaleSets`|
|count|yes|Describes the node count|
|diskSizesGB|no|Describes an array of up to 4 attached disk sizes. Valid disk size values are between 1 and 1024|
|dnsPrefix|Required if agents are to be exposed publically with a load balancer|The dns prefix that forms the FQDN to access the loadbalancer for this agent pool. This must be a unique name among all agent pools. Not supported for Kubernetes clusters|
Expand Down
35 changes: 35 additions & 0 deletions examples/kubernetes-vmss/kubernetes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"apiVersion": "vlabs",
"properties": {
"orchestratorProfile": {
"orchestratorType": "Kubernetes",
"orchestratorRelease": "1.10",
"kubernetesConfig": {
"useManagedIdentity": true
}
},
"masterProfile": {
"count": 1,
"dnsPrefix": "",
"vmSize": "Standard_D2_v2"
},
"agentPoolProfiles": [
{
"name": "agentpool1",
"count": 3,
"vmSize": "Standard_D2_v2",
"availabilityProfile": "VirtualMachineScaleSets"
}
],
"linuxProfile": {
"adminUsername": "azureuser",
"ssh": {
"publicKeys": [
{
"keyData": ""
}
]
}
}
}
}
213 changes: 213 additions & 0 deletions parts/k8s/kubernetesagentresourcesvmss.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
{{if .IsStorageAccount}}
{
"apiVersion": "[variables('apiVersionStorage')]",
"copy": {
"count": "[variables('{{.Name}}StorageAccountsCount')]",
"name": "loop"
},
{{if not IsHostedMaster}}
{{if not IsPrivateCluster}}
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))]"
],
{{end}}
{{end}}
"location": "[variables('location')]",
"name": "[concat(variables('storageAccountPrefixes')[mod(add(copyIndex(),variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('storageAccountPrefixes')[div(add(copyIndex(),variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('{{.Name}}AccountName'))]",
"properties": {
"accountType": "[variables('vmSizesMap')[variables('{{.Name}}VMSize')].storageAccountType]"
},
"type": "Microsoft.Storage/storageAccounts"
},
{{if .HasDisks}}
{
"apiVersion": "[variables('apiVersionStorage')]",
"copy": {
"count": "[variables('{{.Name}}StorageAccountsCount')]",
"name": "datadiskLoop"
},
{{if not IsHostedMaster}}
{{if not IsPrivateCluster}}
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))]"
],
{{end}}
{{end}}
"location": "[variables('location')]",
"name": "[concat(variables('storageAccountPrefixes')[mod(add(copyIndex(variables('dataStorageAccountPrefixSeed')),variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('storageAccountPrefixes')[div(add(copyIndex(variables('dataStorageAccountPrefixSeed')),variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('{{.Name}}DataAccountName'))]",
"properties": {
"accountType": "[variables('vmSizesMap')[variables('{{.Name}}VMSize')].storageAccountType]"
},
"type": "Microsoft.Storage/storageAccounts"
},
{{end}}
{{end}}
{{if UseManagedIdentity}}
{
"apiVersion": "2014-10-01-preview",
"name": "[guid(concat('Microsoft.Compute/virtualMachineScaleSets/', variables('{{.Name}}VMNamePrefix'), 'vmidentity'))]",
"type": "Microsoft.Authorization/roleAssignments",
"properties": {
"roleDefinitionId": "[variables('readerRoleDefinitionId')]",
"principalId": "[reference(concat('Microsoft.Compute/virtualMachineScaleSets/', variables('{{.Name}}VMNamePrefix')), '2017-03-30', 'Full').identity.principalId]"
}
},
{{end}}
{
"apiVersion": "[variables('apiVersionVirtualMachineScaleSets')]",
"dependsOn": [
{{if .IsCustomVNET}}
"[variables('nsgID')]"
{{else}}
"[variables('vnetID')]"
{{end}}
{{if .IsStorageAccount}}
,"[concat('Microsoft.Storage/storageAccounts/',variables('storageAccountPrefixes')[mod(add(div(0,variables('maxVMsPerStorageAccount')),variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('storageAccountPrefixes')[div(add(div(0,variables('maxVMsPerStorageAccount')),variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('{{.Name}}AccountName'))]"
{{if .HasDisks}}
,"[concat('Microsoft.Storage/storageAccounts/',variables('storageAccountPrefixes')[mod(add(add(div(0,variables('maxVMsPerStorageAccount')),variables('{{.Name}}StorageAccountOffset')),variables('dataStorageAccountPrefixSeed')),variables('storageAccountPrefixesCount'))],variables('storageAccountPrefixes')[div(add(add(div(0,variables('maxVMsPerStorageAccount')),variables('{{.Name}}StorageAccountOffset')),variables('dataStorageAccountPrefixSeed')),variables('storageAccountPrefixesCount'))],variables('{{.Name}}DataAccountName'))]"
{{end}}
{{end}}
],
"tags":
{
"creationSource" : "[concat(variables('generatorCode'), '-', variables('{{.Name}}VMNamePrefix'))]",
"resourceNameSuffix" : "[variables('nameSuffix')]",
"orchestrator" : "[variables('orchestratorNameVersionTag')]",
"poolName" : "{{.Name}}"
},
"location": "[variables('location')]",
"name": "[variables('{{.Name}}VMNamePrefix')]",
{{if UseManagedIdentity}}
"identity": {
"type": "systemAssigned"
},
{{end}}
"sku": {
"tier": "Standard",
"capacity": "[variables('{{.Name}}Count')]",
"name": "[variables('{{.Name}}VMSize')]"
},
"properties": {
"overprovision": false,
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "[variables('{{.Name}}VMNamePrefix')]",
"properties": {
"primary": true,
{{if .IsCustomVNET}}
"networkSecurityGroup": {
"id": "[variables('nsgID')]"
},
{{end}}
"ipConfigurations": [
{{range $seq := loop 1 .IPAddressCount}}
{
"name": "ipconfig{{$seq}}",
"properties": {
{{if eq $seq 1}}
"primary": true,
{{end}}
"subnet": {
"id": "[variables('{{$.Name}}VnetSubnetID')]"
}
}
}
{{if lt $seq $.IPAddressCount}},{{end}}
{{end}}
]
{{if not IsAzureCNI}}
,"enableIPForwarding": true
{{end}}
}
}
]
},
"osProfile": {
"adminUsername": "[variables('username')]",
"computerNamePrefix": "[variables('{{.Name}}VMNamePrefix')]",
{{GetKubernetesAgentCustomData .}}
"linuxConfiguration": {
"disablePasswordAuthentication": "true",
"ssh": {
"publicKeys": [
{
"keyData": "[parameters('sshRSAPublicKey')]",
"path": "[variables('sshKeyPath')]"
}
]
}
}
{{if HasLinuxSecrets}}
,
"secrets": "[variables('linuxProfileSecrets')]"
{{end}}
},
"storageProfile": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a PR recently enabling users to provision using their own images. is this included? Used currently by openshift on acs-engine @jim-minter FYI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, seems to be included, thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom images should be included now

{{if not (UseAgentCustomImage .)}}
{{GetDataDisks .}}
{{end}}
"imageReference": {
{{if UseAgentCustomImage .}}
"id": "[resourceId(variables('{{.Name}}osImageResourceGroup'), 'Microsoft.Compute/images', variables('{{.Name}}osImageName'))]"
{{else}}
"offer": "[variables('{{.Name}}osImageOffer')]",
"publisher": "[variables('{{.Name}}osImagePublisher')]",
"sku": "[variables('{{.Name}}osImageSKU')]",
"version": "[variables('{{.Name}}osImageVersion')]"
{{end}}
},
"osDisk": {
"createOption": "FromImage",
"caching": "ReadWrite"
{{if .IsStorageAccount}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackfrancis I think we should validate against storage accounts for new clusters while allowing them for scale ops. Is this possible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khenidak I'm not sure what you mean.

@JackQuincy can you confirm that there's no special validation/template processing context for deployment vs scale?

,"name": "[concat(variables('{{.Name}}VMNamePrefix'),'-osdisk')]"
,"vhdContainers": [
"[concat(reference(concat('Microsoft.Storage/storageAccounts/',variables('storageAccountPrefixes')[mod(add(0,variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('storageAccountPrefixes')[div(add(0,variables('{{.Name}}StorageAccountOffset')),variables('storageAccountPrefixesCount'))],variables('{{.Name}}AccountName')),variables('apiVersionStorage')).primaryEndpoints.blob,'osdisk')]"
]
{{end}}
{{if ne .OSDiskSizeGB 0}}
,"diskSizeGB": {{.OSDiskSizeGB}}
{{end}}
}
},
"extensionProfile": {
"extensions": [
{
"name": "vmssCSE",
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {},
"protectedSettings": {
"commandToExecute": "[concat(variables('provisionScriptParametersCommon'),' /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1\"')]"
}
}
}
{{if UseManagedIdentity}}
,{
"name": "managedIdentityExtension",
"properties": {
"publisher": "Microsoft.ManagedIdentity",
"type": "ManagedIdentityExtensionForLinux",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": {
"port": 50343
},
"protectedSettings": {}
}
}
{{end}}
]
}
}
},
"type": "Microsoft.Compute/virtualMachineScaleSets"
}
6 changes: 6 additions & 0 deletions parts/k8s/kubernetesagentvars.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
"{{.Name}}StorageAccountsCount": "[add(div(variables('{{.Name}}Count'), variables('maxVMsPerStorageAccount')), mod(add(mod(variables('{{.Name}}Count'), variables('maxVMsPerStorageAccount')),2), add(mod(variables('{{.Name}}Count'), variables('maxVMsPerStorageAccount')),1)))]",
{{end}}
"{{.Name}}Count": "[parameters('{{.Name}}Count')]",
{{if .IsAvailabilitySets}}
"{{.Name}}Offset": "[parameters('{{.Name}}Offset')]",
"{{.Name}}AvailabilitySet": "[concat('{{.Name}}-availabilitySet-', variables('nameSuffix'))]",
{{end}}
{{if .IsWindows}}
"winResourceNamePrefix" : "[substring(variables('nameSuffix'), 0, 5)]",
"{{.Name}}VMNamePrefix": "[concat(variables('winResourceNamePrefix'), variables('orchestratorName'), add(900,variables('{{.Name}}Index')))]",
{{else}}
{{if .IsAvailabilitySets}}
"{{.Name}}VMNamePrefix": "[concat(variables('orchestratorName'), '-{{.Name}}-', variables('nameSuffix'), '-')]",
{{else}}
"{{.Name}}VMNamePrefix": "[concat(variables('orchestratorName'), '-{{.Name}}-', variables('nameSuffix'), '-vmss')]",
{{end}}
{{end}}
"{{.Name}}VMSize": "[parameters('{{.Name}}VMSize')]",
{{if .IsCustomVNET}}
Expand Down
12 changes: 10 additions & 2 deletions parts/k8s/kubernetesbase.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@
{{ range $index, $element := .AgentPoolProfiles}}
{{if $index}}, {{end}}
{{if .IsWindows}}
{{template "k8s/kuberneteswinagentresourcesvmas.t" .}}
{{if .IsVirtualMachineScaleSets}}
{{template "k8s/kuberneteswinagentresourcesvmss.t" .}}
{{else}}
{{template "k8s/kuberneteswinagentresourcesvmas.t" .}}
{{end}}
{{else}}
{{template "k8s/kubernetesagentresourcesvmas.t" .}}
{{if .IsVirtualMachineScaleSets}}
{{template "k8s/kubernetesagentresourcesvmss.t" .}}
{{else}}
{{template "k8s/kubernetesagentresourcesvmas.t" .}}
{{end}}
{{end}}
{{end}}
{{if not IsHostedMaster}}
Expand Down
2 changes: 2 additions & 0 deletions parts/k8s/kubernetescustomscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,14 @@ cat << EOF > "${AZURE_JSON_PATH}"
"aadClientSecret": "${SERVICE_PRINCIPAL_CLIENT_SECRET}",
"resourceGroup": "${RESOURCE_GROUP}",
"location": "${LOCATION}",
"vmType": "${VM_TYPE}",
"subnetName": "${SUBNET}",
"securityGroupName": "${NETWORK_SECURITY_GROUP}",
"vnetName": "${VIRTUAL_NETWORK}",
"vnetResourceGroup": "${VIRTUAL_NETWORK_RESOURCE_GROUP}",
"routeTableName": "${ROUTE_TABLE}",
"primaryAvailabilitySetName": "${PRIMARY_AVAILABILITY_SET}",
"primaryScaleSetName": "${PRIMARY_SCALE_SET}",
"cloudProviderBackoff": ${CLOUDPROVIDER_BACKOFF},
"cloudProviderBackoffRetries": ${CLOUDPROVIDER_BACKOFF_RETRIES},
"cloudProviderBackoffExponent": ${CLOUDPROVIDER_BACKOFF_EXPONENT},
Expand Down
2 changes: 1 addition & 1 deletion parts/k8s/kubernetesmasterresources.t
Original file line number Diff line number Diff line change
Expand Up @@ -1006,4 +1006,4 @@
{{end}}
}
}
}{{WriteLinkedTemplatesForExtensions}}
}{{WriteLinkedTemplatesForExtensions}}
Loading