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

Commit

Permalink
Make AvailabilitySet profile for master use Availability Zones
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Rabot <[email protected]>
  • Loading branch information
Sylvain Rabot authored and sylr committed Nov 22, 2018
1 parent ba9630f commit 23bab6d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
16 changes: 13 additions & 3 deletions parts/k8s/kubernetesagentresourcesvmas.t
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"type": "Microsoft.Network/networkInterfaces"
},
{{if .IsManagedDisks}}
{
{{if not (HasAvailabilityZones .)}}
{
"location": "[variables('location')]",
"name": "[variables('{{.Name}}AvailabilitySet')]",
"apiVersion": "[variables('apiVersionCompute')]",
Expand All @@ -91,6 +92,7 @@
},
"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{{else if .IsStorageAccount}}
{
"apiVersion": "[variables('apiVersionStorage')]",
Expand Down Expand Up @@ -134,13 +136,15 @@
"type": "Microsoft.Storage/storageAccounts"
},
{{end}}
{{if not (HasAvailabilityZones .)}}
{
"location": "[variables('location')]",
"name": "[variables('{{.Name}}AvailabilitySet')]",
"apiVersion": "[variables('apiVersionCompute')]",
"properties": {},
"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{{end}}
{
"apiVersion": "[variables('apiVersionCompute')]",
Expand All @@ -156,8 +160,10 @@
"[concat('Microsoft.Storage/storageAccounts/',variables('storageAccountPrefixes')[mod(add(add(div(copyIndex(variables('{{.Name}}Offset')),variables('maxVMsPerStorageAccount')),variables('{{.Name}}StorageAccountOffset')),variables('dataStorageAccountPrefixSeed')),variables('storageAccountPrefixesCount'))],variables('storageAccountPrefixes')[div(add(add(div(copyIndex(variables('{{.Name}}Offset')),variables('maxVMsPerStorageAccount')),variables('{{.Name}}StorageAccountOffset')),variables('dataStorageAccountPrefixSeed')),variables('storageAccountPrefixesCount'))],variables('{{.Name}}DataAccountName'))]",
{{end}}
{{end}}
"[concat('Microsoft.Network/networkInterfaces/', variables('{{.Name}}VMNamePrefix'), 'nic-', copyIndex(variables('{{.Name}}Offset')))]",
"[concat('Microsoft.Compute/availabilitySets/', variables('{{.Name}}AvailabilitySet'))]"
{{if not (HasAvailabilityZones .)}}
"[concat('Microsoft.Compute/availabilitySets/', variables('{{.Name}}AvailabilitySet'))]",
{{end}}
"[concat('Microsoft.Network/networkInterfaces/', variables('{{.Name}}VMNamePrefix'), 'nic-', copyIndex(variables('{{.Name}}Offset')))]"
],
"tags":
{
Expand Down Expand Up @@ -191,9 +197,13 @@
},
{{end}}
"properties": {
{{if not (HasAvailabilityZones .)}}
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('{{.Name}}AvailabilitySet'))]"
},
{{ else}}
"zones": "split(string([parameters('availabilityZones')[mod(copyIndex(variables('{{.Name}}Offset')), length(parameters('availabilityZones')))]]), ',')"
{{end}}
"hardwareProfile": {
"vmSize": "[variables('{{.Name}}VMSize')]"
},
Expand Down
24 changes: 22 additions & 2 deletions parts/k8s/kubernetesmasterresources.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{if .MasterProfile.IsManagedDisks}}
{{if not .MasterProfile.HasAvailabilityZones}}
{
"apiVersion": "[variables('apiVersionCompute')]",
"location": "[variables('location')]",
Expand All @@ -13,14 +14,17 @@
},
"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{{else if .MasterProfile.IsStorageAccount}}
{{if not .MasterProfile.HasAvailabilityZones}}
{
"apiVersion": "[variables('apiVersionCompute')]",
"location": "[variables('location')]",
"name": "[variables('masterAvailabilitySet')]",
"properties": {},
"type": "Microsoft.Compute/availabilitySets"
},
{{end}}
{
"apiVersion": "[variables('apiVersionStorage')]",
{{if not IsPrivateCluster}}
Expand Down Expand Up @@ -180,7 +184,10 @@
"dnsSettings": {
"domainNameLabel": "[variables('masterFqdnPrefix')]"
},
"publicIPAllocationMethod": "Dynamic"
"publicIPAllocationMethod": "Static"
},
"sku": {
"name": "[variables('loadBalancerSku')]"
},
"type": "Microsoft.Network/publicIPAddresses"
},
Expand Down Expand Up @@ -241,6 +248,9 @@
}
]
},
"sku": {
"name": "[variables('loadBalancerSku')]"
},
"type": "Microsoft.Network/loadBalancers"
},
{
Expand Down Expand Up @@ -649,6 +659,9 @@
}
]
},
"sku": {
"name": "[variables('loadBalancerSku')]"
},
"type": "Microsoft.Network/loadBalancers"
},
{{end}}
Expand Down Expand Up @@ -696,7 +709,7 @@
"tenantId": "[variables('tenantID')]",
{{if UseManagedIdentity}}
{{if UserAssignedIDEnabled}}
"accessPolicies":
"accessPolicies":
[
{
"tenantId": "[variables('tenantID')]",
Expand Down Expand Up @@ -772,7 +785,9 @@
},
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('masterVMNamePrefix'), 'nic-', copyIndex(variables('masterOffset')))]"
{{if not .MasterProfile.HasAvailabilityZones}}
,"[concat('Microsoft.Compute/availabilitySets/',variables('masterAvailabilitySet'))]"
{{end}}
{{if .MasterProfile.IsStorageAccount}}
,"[variables('masterStorageAccountName')]"
{{end}}
Expand All @@ -787,6 +802,9 @@
},
"location": "[variables('location')]",
"name": "[concat(variables('masterVMNamePrefix'), copyIndex(variables('masterOffset')))]",
{{if .MasterProfile.HasAvailabilityZones}}
"zones": "[split(string(parameters('availabilityZones')[mod(copyIndex(variables('masterOffset')), length(parameters('availabilityZones')))]), ',')]",
{{end}}
{{if UseManagedIdentity}}
{{if UserAssignedIDEnabled}}
"identity": {
Expand All @@ -809,9 +827,11 @@
},
{{end}}
"properties": {
{{if not .MasterProfile.HasAvailabilityZones}}
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('masterAvailabilitySet'))]"
},
{{end}}
"hardwareProfile": {
"vmSize": "[parameters('masterVMSize')]"
},
Expand Down
3 changes: 0 additions & 3 deletions pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,6 @@ func (a *Properties) validateZones() error {
if a.HasAvailabilityZones() {
if a.MastersAndAgentsUseAvailabilityZones() {
// master profile
if a.MasterProfile.AvailabilityProfile != VirtualMachineScaleSets {
return errors.New("Availability Zones are not supported with an AvailabilitySet. Please set availabilityProfile to VirtualMachineScaleSets")
}
if a.MasterProfile.Count < len(a.MasterProfile.AvailabilityZones)*2 {
return errors.New("the node count and the number of availability zones provided can result in zone imbalance. To achieve zone balance, each zone should have at least 2 nodes or more")
}
Expand Down

0 comments on commit 23bab6d

Please sign in to comment.