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 (#4286)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylr authored and jackfrancis committed Nov 28, 2018
1 parent 09aba18 commit 7df12dd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
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
20 changes: 0 additions & 20 deletions pkg/api/vlabs/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1739,26 +1739,6 @@ func TestProperties_ValidateZones(t *testing.T) {
},
expectedErr: "availabilityZone is only available in Kubernetes version 1.12 or greater",
},
{
name: "Master profile with zones vmas",
orchestratorRelease: "1.12",
masterProfile: &MasterProfile{
Count: 3,
DNSPrefix: "foo",
VMSize: "Standard_DS2_v2",
AvailabilityZones: []string{"1", "2"},
},
agentProfiles: []*AgentPoolProfile{
{
Name: "agentpool",
VMSize: "Standard_DS2_v2",
Count: 4,
AvailabilityProfile: VirtualMachineScaleSets,
AvailabilityZones: []string{"1", "2"},
},
},
expectedErr: "Availability Zones are not supported with an AvailabilitySet. Please set availabilityProfile to VirtualMachineScaleSets",
},
{
name: "Master profile with zones node count",
orchestratorRelease: "1.12",
Expand Down

0 comments on commit 7df12dd

Please sign in to comment.