Skip to content

Commit

Permalink
Merge pull request #2523 from zmyzheng/vmssflex-vmtype
Browse files Browse the repository at this point in the history
VMSS Flex Support: Add a new vmType for pure VMSS Flex cluster to bypass the node type check
  • Loading branch information
k8s-ci-robot committed Oct 21, 2022
2 parents b0d976d + 4ebdb52 commit c60daf9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const (
VMTypeVMSS = "vmss"
// VMTypeStandard is the vmas vm type
VMTypeStandard = "standard"
// VMTypeVmssFlex is the vmssflex vm type
VMTypeVmssFlex = "vmssflex"

// ExternalResourceGroupLabel is the label representing the node is in a different
// resource group from other cloud provider components
Expand Down
5 changes: 5 additions & 0 deletions pkg/provider/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret, callFromC
if err != nil {
return err
}
} else if strings.EqualFold(consts.VMTypeVmssFlex, az.Config.VMType) {
az.VMSet, err = newFlexScaleSet(az)
if err != nil {
return err
}
} else {
az.VMSet, err = newAvailabilitySet(az)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions pkg/provider/azure_controller_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ type ExtendedLocation struct {

// getNodeVMSet gets the VMSet interface based on config.VMType and the real virtual machine type.
func (c *controllerCommon) getNodeVMSet(nodeName types.NodeName, crt azcache.AzureCacheReadType) (VMSet, error) {
// 1. vmType is standard, return cloud.VMSet directly.
if c.cloud.VMType == consts.VMTypeStandard {
// 1. vmType is standard or vmssflex, return cloud.VMSet directly.
// 1.1 all the nodes in the cluster are avset nodes.
// 1.2 all the nodes in the cluster are vmssflex nodes.
if c.cloud.VMType == consts.VMTypeStandard || c.cloud.VMType == consts.VMTypeVmssFlex {
return c.cloud.VMSet, nil
}

// 2. vmType is Virtual Machine Scale Set (vmss), convert vmSet to ScaleSet.
// 2.1 all the nodes in the cluster are vmss unifrom nodes.
// 2.2 mix node: the nodes in the cluster can be any of avset nodes, vmss uniform nodes and vmssflex nodes.
ss, ok := c.cloud.VMSet.(*ScaleSet)
if !ok {
return nil, fmt.Errorf("error of converting vmSet (%q) to ScaleSet with vmType %q", c.cloud.VMSet, c.cloud.VMType)
Expand Down

0 comments on commit c60daf9

Please sign in to comment.