mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #87685 from feiskyer/vmas-disable
Add disableAvailabilitySetNodes to avoid VM list for VMSS clusters
This commit is contained in:
commit
21e6ec0ba5
@ -213,6 +213,9 @@ type Config struct {
|
|||||||
NsgCacheTTLInSeconds int `json:"nsgCacheTTLInSeconds,omitempty" yaml:"nsgCacheTTLInSeconds,omitempty"`
|
NsgCacheTTLInSeconds int `json:"nsgCacheTTLInSeconds,omitempty" yaml:"nsgCacheTTLInSeconds,omitempty"`
|
||||||
// RouteTableCacheTTLInSeconds sets the cache TTL for route table
|
// RouteTableCacheTTLInSeconds sets the cache TTL for route table
|
||||||
RouteTableCacheTTLInSeconds int `json:"routeTableCacheTTLInSeconds,omitempty" yaml:"routeTableCacheTTLInSeconds,omitempty"`
|
RouteTableCacheTTLInSeconds int `json:"routeTableCacheTTLInSeconds,omitempty" yaml:"routeTableCacheTTLInSeconds,omitempty"`
|
||||||
|
|
||||||
|
// DisableAvailabilitySetNodes disables VMAS nodes support when "VMType" is set to "vmss".
|
||||||
|
DisableAvailabilitySetNodes bool `json:"disableAvailabilitySetNodes,omitempty" yaml:"disableAvailabilitySetNodes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ cloudprovider.Interface = (*Cloud)(nil)
|
var _ cloudprovider.Interface = (*Cloud)(nil)
|
||||||
@ -353,6 +356,10 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret bool) erro
|
|||||||
config.VMType = vmTypeStandard
|
config.VMType = vmTypeStandard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.DisableAvailabilitySetNodes && config.VMType != vmTypeVMSS {
|
||||||
|
return fmt.Errorf("disableAvailabilitySetNodes %v is only supported when vmType is 'vmss'", config.DisableAvailabilitySetNodes)
|
||||||
|
}
|
||||||
|
|
||||||
if config.CloudConfigType == "" {
|
if config.CloudConfigType == "" {
|
||||||
// The default cloud config type is cloudConfigTypeMerge.
|
// The default cloud config type is cloudConfigTypeMerge.
|
||||||
config.CloudConfigType = cloudConfigTypeMerge
|
config.CloudConfigType = cloudConfigTypeMerge
|
||||||
|
@ -1511,6 +1511,8 @@ func TestNewCloudFromJSON(t *testing.T) {
|
|||||||
"loadBalancerCacheTTLInSeconds": 100,
|
"loadBalancerCacheTTLInSeconds": 100,
|
||||||
"nsgCacheTTLInSeconds": 100,
|
"nsgCacheTTLInSeconds": 100,
|
||||||
"routeTableCacheTTLInSeconds": 100,
|
"routeTableCacheTTLInSeconds": 100,
|
||||||
|
"vmType": "vmss",
|
||||||
|
"disableAvailabilitySetNodes": true
|
||||||
}`
|
}`
|
||||||
validateConfig(t, config)
|
validateConfig(t, config)
|
||||||
}
|
}
|
||||||
@ -1568,6 +1570,8 @@ vmCacheTTLInSeconds: 100
|
|||||||
loadBalancerCacheTTLInSeconds: 100
|
loadBalancerCacheTTLInSeconds: 100
|
||||||
nsgCacheTTLInSeconds: 100
|
nsgCacheTTLInSeconds: 100
|
||||||
routeTableCacheTTLInSeconds: 100
|
routeTableCacheTTLInSeconds: 100
|
||||||
|
vmType: vmss
|
||||||
|
disableAvailabilitySetNodes: true
|
||||||
`
|
`
|
||||||
validateConfig(t, config)
|
validateConfig(t, config)
|
||||||
}
|
}
|
||||||
@ -1665,6 +1669,12 @@ func validateConfig(t *testing.T, config string) {
|
|||||||
if azureCloud.RouteTableCacheTTLInSeconds != 100 {
|
if azureCloud.RouteTableCacheTTLInSeconds != 100 {
|
||||||
t.Errorf("got incorrect value for routeTableCacheTTLInSeconds")
|
t.Errorf("got incorrect value for routeTableCacheTTLInSeconds")
|
||||||
}
|
}
|
||||||
|
if azureCloud.VMType != vmTypeVMSS {
|
||||||
|
t.Errorf("got incorrect value for vmType")
|
||||||
|
}
|
||||||
|
if !azureCloud.DisableAvailabilitySetNodes {
|
||||||
|
t.Errorf("got incorrect value for disableAvailabilitySetNodes")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCloudFromConfig(t *testing.T, config string) *Cloud {
|
func getCloudFromConfig(t *testing.T, config string) *Cloud {
|
||||||
|
@ -75,9 +75,11 @@ func newScaleSet(az *Cloud) (VMSet, error) {
|
|||||||
availabilitySet: newAvailabilitySet(az),
|
availabilitySet: newAvailabilitySet(az),
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.availabilitySetNodesCache, err = ss.newAvailabilitySetNodesCache()
|
if !ss.DisableAvailabilitySetNodes {
|
||||||
if err != nil {
|
ss.availabilitySetNodesCache, err = ss.newAvailabilitySetNodesCache()
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.vmssCache, err = ss.newVMSSCache()
|
ss.vmssCache, err = ss.newVMSSCache()
|
||||||
|
@ -256,6 +256,12 @@ func (ss *scaleSet) newAvailabilitySetNodesCache() (*timedCache, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ss *scaleSet) isNodeManagedByAvailabilitySet(nodeName string, crt cacheReadType) (bool, error) {
|
func (ss *scaleSet) isNodeManagedByAvailabilitySet(nodeName string, crt cacheReadType) (bool, error) {
|
||||||
|
// Assume all nodes are managed by VMSS when DisableAvailabilitySetNodes is enabled.
|
||||||
|
if ss.DisableAvailabilitySetNodes {
|
||||||
|
klog.V(2).Infof("Assuming node %q is managed by VMSS since DisableAvailabilitySetNodes is set to true", nodeName)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
cached, err := ss.availabilitySetNodesCache.Get(availabilitySetNodesKey, crt)
|
cached, err := ss.availabilitySetNodesCache.Get(availabilitySetNodesKey, crt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
Loading…
Reference in New Issue
Block a user