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

Commit

Permalink
rm zones from master and vmas, add setVMSSDefaults, set default for z…
Browse files Browse the repository at this point in the history
…ones
  • Loading branch information
ritazh committed Aug 16, 2018
1 parent 5f673f1 commit 3804e7e
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 96 deletions.
2 changes: 1 addition & 1 deletion parts/agentparams.t
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"type": "string"
},
{{if HaveAvailabilityZones .}}
{{if HasAvailabilityZones .}}
"{{.Name}}AvailabilityZones": {
"metadata": {
"description": "Agent availability zones"
Expand Down
11 changes: 0 additions & 11 deletions parts/k8s/kubernetesagentresourcesvmas.t
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"type": "Microsoft.Network/networkInterfaces"
},
{{if .IsManagedDisks}}
{{if not (HaveAvailabilityZones .)}}
{
"location": "[variables('location')]",
"name": "[variables('{{.Name}}AvailabilitySet')]",
Expand All @@ -95,7 +94,6 @@

"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{{else if .IsStorageAccount}}
{
"apiVersion": "[variables('apiVersionStorage')]",
Expand Down Expand Up @@ -139,15 +137,13 @@
"type": "Microsoft.Storage/storageAccounts"
},
{{end}}
{{if not (HaveAvailabilityZones .)}}
{
"location": "[variables('location')]",
"name": "[variables('{{.Name}}AvailabilitySet')]",
"apiVersion": "[variables('apiVersionDefault')]",
"properties": {},
"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{{end}}
{
{{if .IsManagedDisks}}
Expand All @@ -168,9 +164,7 @@
{{end}}
{{end}}
"[concat('Microsoft.Network/networkInterfaces/', variables('{{.Name}}VMNamePrefix'), 'nic-', copyIndex(variables('{{.Name}}Offset')))]",
{{if not (HaveAvailabilityZones .)}}
"[concat('Microsoft.Compute/availabilitySets/', variables('{{.Name}}AvailabilitySet'))]"
{{end}}
],
"tags":
{
Expand All @@ -181,9 +175,6 @@
"poolName" : "{{.Name}}"
},
"location": "[variables('location')]",
{{if HaveAvailabilityZones .}}
"zones": "[split(string(add(mod(copyIndex(),{{GetAvailabilityZoneLength .}}),{{GetMinAvailabilityZone .}})), ',')]",
{{ end }}
"name": "[concat(variables('{{.Name}}VMNamePrefix'), copyIndex(variables('{{.Name}}Offset')))]",
{{if UseManagedIdentity}}
"identity": {
Expand All @@ -198,11 +189,9 @@
},
{{end}}
"properties": {
{{if not (HaveAvailabilityZones .)}}
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('{{.Name}}AvailabilitySet'))]"
},
{{end}}
"hardwareProfile": {
"vmSize": "[variables('{{.Name}}VMSize')]"
},
Expand Down
8 changes: 5 additions & 3 deletions parts/k8s/kubernetesagentresourcesvmss.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"poolName" : "{{.Name}}"
},
"location": "[variables('location')]",
{{ if HaveAvailabilityZones .}}
"zones": "[variables('{{.Name}}AvailabilityZones')]",
{{ if HasAvailabilityZones .}}
"zones": "[parameters('{{.Name}}AvailabilityZones')]",
{{ end }}
"name": "[variables('{{.Name}}VMNamePrefix')]",
{{if UseManagedIdentity}}
Expand All @@ -41,7 +41,9 @@
"name": "[variables('{{.Name}}VMSize')]"
},
"properties": {
{{if not (UseSinglePlacementGroup .)}}
{{if UseSinglePlacementGroup .}}
"singlePlacementGroup": true,
{{else}}
"singlePlacementGroup": false,
{{end}}
"overprovision": false,
Expand Down
3 changes: 0 additions & 3 deletions parts/k8s/kubernetesagentvars.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
"{{.Name}}ScaleSetEvictionPolicy": "[parameters('{{.Name}}ScaleSetEvictionPolicy')]",
{{end}}
{{end}}
{{ if HaveAvailabilityZones .}}
"{{.Name}}AvailabilityZones": "[parameters('{{.Name}}AvailabilityZones')]",
{{end}}
{{end}}
"{{.Name}}VMSize": "[parameters('{{.Name}}VMSize')]",
{{if .IsCustomVNET}}
Expand Down
1 change: 1 addition & 0 deletions parts/k8s/kubernetescustomscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ if [[ ! -z "${MASTER_NODE}" ]]; then
writeKubeConfig
ensureEtcd
ensureK8sControlPlane
ensureKubelet
fi

if [[ $OS == $UBUNTU_OS_NAME ]]; then
Expand Down
50 changes: 10 additions & 40 deletions parts/k8s/kubernetesmasterresources.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{if not HaveMasterAvailabilityZones}}
{{if .MasterProfile.IsManagedDisks}}
{
"apiVersion": "[variables('apiVersionStorageManagedDisks')]",
Expand All @@ -12,17 +11,14 @@
},
"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{{else if .MasterProfile.IsStorageAccount}}
{{if not HaveMasterAvailabilityZones}}
{
"apiVersion": "[variables('apiVersionDefault')]",
"location": "[variables('location')]",
"name": "[variables('masterAvailabilitySet')]",
"properties": {},
"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{
"apiVersion": "[variables('apiVersionStorage')]",
{{if not IsPrivateCluster}}
Expand Down Expand Up @@ -145,36 +141,24 @@
{{end}}
{{if not IsPrivateCluster}}
{
"apiVersion": "[variables('apiVersionNetwork')]",
"apiVersion": "[variables('apiVersionDefault')]",
"location": "[variables('location')]",
"name": "[variables('masterPublicIPAddressName')]",
{{if HaveMasterAvailabilityZones}}
"sku": {
"name": "Standard"
},
{{end}}
"properties": {
"dnsSettings": {
"domainNameLabel": "[variables('masterFqdnPrefix')]"
}
{{if HaveMasterAvailabilityZones}}
,"publicIPAllocationMethod": "Static"
{{end}}
},
"publicIPAllocationMethod": "Dynamic"
},
"type": "Microsoft.Network/publicIPAddresses"
},
{
"apiVersion": "[variables('apiVersionNetwork')]",
"apiVersion": "[variables('apiVersionDefault')]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))]"
],
"location": "[variables('location')]",
"name": "[variables('masterLbName')]",
{{if HaveMasterAvailabilityZones}}
"sku": {
"name": "Standard"
},
{{end}}
"properties": {
"backendAddressPools": [
{
Expand Down Expand Up @@ -526,13 +510,11 @@
},
{
"type": "Microsoft.Network/publicIpAddresses",
{{if HaveMasterAvailabilityZones}}
"sku": {
"name": "Standard"
"name": "Basic"
},
{{end}}
"name": "[variables('jumpboxPublicIpAddressName')]",
"apiVersion": "[variables('apiVersionPublicIP')]",
"apiVersion": "[variables('apiVersionDefault')]",
"location": "[variables('location')]",
"properties": {
"dnsSettings": {
Expand Down Expand Up @@ -578,7 +560,7 @@
{{end}}
{{if gt .MasterProfile.Count 1}}
{
"apiVersion": "[variables('apiVersionNetwork')]",
"apiVersion": "[variables('apiVersionDefault')]",
"dependsOn": [
{{if .MasterProfile.IsCustomVNET}}
"[variables('nsgID')]"
Expand All @@ -588,11 +570,6 @@
],
"location": "[variables('location')]",
"name": "[variables('masterInternalLbName')]",
{{if HaveMasterAvailabilityZones}}
"sku": {
"name": "Standard"
},
{{end}}
"properties": {
"backendAddressPools": [
{
Expand Down Expand Up @@ -663,7 +640,7 @@
"apiVersion": "[variables('apiVersionKeyVault')]",
"location": "[variables('location')]",
{{ if UseManagedIdentity}}
"dependsOn":
"dependsOn":
[
{{$max := .MasterProfile.Count}}
{{$c := subtract $max 1}}
Expand Down Expand Up @@ -696,7 +673,7 @@
}
],
{{else}}
"accessPolicies":
"accessPolicies":
[
{{$max := .MasterProfile.Count}}
{{$c := subtract $max 1}}
Expand Down Expand Up @@ -754,9 +731,7 @@
},
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('masterVMNamePrefix'), 'nic-', copyIndex(variables('masterOffset')))]"
{{if not HaveMasterAvailabilityZones}}
,"[concat('Microsoft.Compute/availabilitySets/',variables('masterAvailabilitySet'))]"
{{end}}
{{if .MasterProfile.IsStorageAccount}}
,"[variables('masterStorageAccountName')]"
{{end}}
Expand All @@ -770,9 +745,6 @@
"poolName" : "master"
},
"location": "[variables('location')]",
{{ if HaveMasterAvailabilityZones}}
"zones": "[split(string(add(mod(copyIndex(),{{GetMasterAvailabilityZoneLength}}),{{GetMasterMinAvailabilityZone}})), ',')]",
{{ end }}
"name": "[concat(variables('masterVMNamePrefix'), copyIndex(variables('masterOffset')))]",
{{if UseManagedIdentity}}
"identity": {
Expand All @@ -787,11 +759,9 @@
},
{{end}}
"properties": {
{{if not HaveMasterAvailabilityZones}}
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('masterAvailabilitySet'))]"
},
{{end}}
"hardwareProfile": {
"vmSize": "[parameters('masterVMSize')]"
},
Expand Down Expand Up @@ -961,4 +931,4 @@
}
}
{{end}}
{{WriteLinkedTemplatesForExtensions}}
{{WriteLinkedTemplatesForExtensions}}
1 change: 0 additions & 1 deletion parts/k8s/kubernetesmastervars.t
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
{{end}}
"apiVersionDefault": "2016-03-30",
"apiVersionLinkDefault": "2015-01-01",
"apiVersionNetwork": "2018-05-01",
"locations": [
"[resourceGroup().location]",
"[parameters('location')]"
Expand Down
3 changes: 0 additions & 3 deletions parts/k8s/kuberneteswinagentresourcesvmas.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
{{end}}
],
"location": "[variables('location')]",
{{ if HaveAvailabilityZones .}}
"zones": "[variables('{{.Name}}AvailabilityZones')]",
{{ end }}
"name": "[concat(variables('{{.Name}}VMNamePrefix'), 'nic-', copyIndex(variables('{{.Name}}Offset')))]",
"properties": {
{{if .IsCustomVNET}}
Expand Down
9 changes: 7 additions & 2 deletions parts/k8s/kuberneteswinagentresourcesvmss.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"poolName" : "{{.Name}}"
},
"location": "[variables('location')]",
{{ if HaveAvailabilityZones .}}
"zones": "[variables('{{.Name}}AvailabilityZones')]",
{{ if HasAvailabilityZones .}}
"zones": "[parameters('{{.Name}}AvailabilityZones')]",
{{ end }}
"name": "[variables('{{.Name}}VMNamePrefix')]",
{{if UseManagedIdentity}}
Expand All @@ -41,6 +41,11 @@
"name": "[variables('{{.Name}}VMSize')]"
},
"properties": {
{{if UseSinglePlacementGroup .}}
"singlePlacementGroup": true,
{{else}}
"singlePlacementGroup": false,
{{end}}
"overprovision": false,
"upgradePolicy": {
"mode": "Manual"
Expand Down
8 changes: 0 additions & 8 deletions parts/masterparams.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@
},
"type": "string"
},
{{end}}
{{if HaveMasterAvailabilityZones}}
"masterAvailabilityZones": {
"metadata": {
"description": "Master availability zones"
},
"type": "array"
},
{{end}}
"sshRSAPublicKey": {
"metadata": {
Expand Down
28 changes: 28 additions & 0 deletions pkg/acsengine/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ func setPropertiesDefaults(cs *api.ContainerService, isUpgrade, isScale bool) (b

setStorageDefaults(properties)
setExtensionDefaults(properties)
setVMSSDefaults(properties)

certsGenerated, e := setDefaultCerts(properties)
if e != nil {
Expand Down Expand Up @@ -546,6 +547,33 @@ func setMasterNetworkDefaults(a *api.Properties, isUpgrade bool) {
}
}

// setVMSSDefaults
// singlePlacementGroup = false, the scale set can be composed of multiple placement groups and has a range of 0-1,000 VMs
// singlePlacementGroup = true,, default value, a scale set is composed of a single placement group, and has a range of 0-100 VMs
// Large scale sets require Azure Managed Disks.
// https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-placement-groups
// For availability zones, only standard load balancer is supported.
func setVMSSDefaults(a *api.Properties) {
for _, profile := range a.AgentPoolProfiles {
if profile.AvailabilityProfile == api.VirtualMachineScaleSets {
if profile.Count > 100 {
profile.SinglePlacementGroup = helpers.PointerToBool(false)
}
if profile.SinglePlacementGroup == helpers.PointerToBool(false) {
profile.StorageProfile = api.ManagedDisks
}
if len(profile.AvailabilityZones) > 0 {
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = "Standard"
a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = helpers.PointerToBool(api.DefaultExcludeMasterFromStandardLB)
}
if profile.SinglePlacementGroup == nil {
profile.SinglePlacementGroup = helpers.PointerToBool(api.DefaultSinglePlacementGroup)
}
}

}
}

// SetAgentNetworkDefaults for agents
func setAgentNetworkDefaults(a *api.Properties, isUpgrade, isScale bool) {
// configure the subnets if not in custom VNET
Expand Down
Loading

0 comments on commit 3804e7e

Please sign in to comment.