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

Make AvailabilitySet profile for master use Availability Zones #4286

Merged
merged 2 commits into from
Nov 28, 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
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')))]), ',')]",
Copy link
Member

Choose a reason for hiding this comment

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

How does this handle copyIndex 0, for example:

        "AvailabilityZones": [
            "1",
            "2"
        ]

and cases where the AvailabilityZones array is not contiguous, which can happen.

        "AvailabilityZones": [
            "1",
            "3"
        ]

Copy link
Contributor Author

@sylr sylr Nov 27, 2018

Choose a reason for hiding this comment

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

I use the mod() functions to generate the <index> of parameters('availabilityZones')[<index>] so the contiguity of the values is not a problem.

{{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