mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
cache ttl is configurable
This commit is contained in:
parent
0d58709016
commit
4152f38d54
@ -174,6 +174,22 @@ type Config struct {
|
||||
// LoadBalancerResourceGroup determines the specific resource group of the load balancer user want to use, working
|
||||
// with LoadBalancerName
|
||||
LoadBalancerResourceGroup string `json:"loadBalancerResourceGroup,omitempty" yaml:"loadBalancerResourceGroup,omitempty"`
|
||||
|
||||
// AvailabilitySetNodesCacheTTL sets the Cache TTL for availabilitySetNodesCache
|
||||
// if not set, will use default value
|
||||
AvailabilitySetNodesCacheTTL int `json:"availabilitySetNodesCacheTTL,omitempty" yaml:"availabilitySetNodesCacheTTL,omitempty"`
|
||||
// VmssCacheTTL sets the cache TTL for VMSS
|
||||
VmssCacheTTL int `json:"vmssCacheTTL,omitempty" yaml:"vmssCacheTTL,omitempty"`
|
||||
// VmssVirtualMachinesCacheTTL sets the cache TTL for vmssVirtualMachines
|
||||
VmssVirtualMachinesCacheTTL int `json:"vmssVirtualMachinesCacheTTL,omitempty" yaml:"vmssVirtualMachinesCacheTTL,omitempty"`
|
||||
// VmCacheTTL sets the cache TTL for vm
|
||||
VMCacheTTL int `json:"vmCacheTTL,omitempty" yaml:"vmCacheTTL,omitempty"`
|
||||
// LbCacheTTL sets the cache TTL for load balancer
|
||||
LbCacheTTL int `json:"lbCacheTTL,omitempty" yaml:"lbcacheTTL,omitempty"`
|
||||
// NsgCacheTTL sets the cache TTL for network security group
|
||||
NsgCacheTTL int `json:"nsgCacheTTL,omityempty" yaml:"nsgCacheTTL,omitempty"`
|
||||
// RtCacheTTL sets the cache TTL for route table
|
||||
RtCacheTTL int `json:"rtCacheTTL,omitempty" yaml:"rtCacheTTL,omitempty"`
|
||||
}
|
||||
|
||||
var _ cloudprovider.Interface = (*Cloud)(nil)
|
||||
|
@ -38,9 +38,9 @@ var (
|
||||
vmssVirtualMachinesKey = "k8svmssVirtualMachinesKey"
|
||||
availabilitySetNodesKey = "k8sAvailabilitySetNodesKey"
|
||||
|
||||
availabilitySetNodesCacheTTL = 15 * time.Minute
|
||||
vmssTTL = 10 * time.Minute
|
||||
vmssVirtualMachinesTTL = 10 * time.Minute
|
||||
availabilitySetNodesCacheTTLDefault = 900 // in seconds
|
||||
vmssCacheTTLDefault = 600 // in seconds
|
||||
vmssVirtualMachinesCacheTTLDefault = 600 // in seconds
|
||||
)
|
||||
|
||||
type vmssVirtualMachinesEntry struct {
|
||||
@ -87,7 +87,10 @@ func (ss *scaleSet) newVMSSCache() (*timedCache, error) {
|
||||
return localCache, nil
|
||||
}
|
||||
|
||||
return newTimedcache(vmssTTL, getter)
|
||||
if ss.Config.VmssCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(vmssCacheTTLDefault)*time.Second, getter)
|
||||
}
|
||||
return newTimedcache(time.Duration(ss.Config.VmssCacheTTL)*time.Second, getter)
|
||||
}
|
||||
|
||||
func extractVmssVMName(name string) (string, string, error) {
|
||||
@ -147,7 +150,10 @@ func (ss *scaleSet) newVMSSVirtualMachinesCache() (*timedCache, error) {
|
||||
return localCache, nil
|
||||
}
|
||||
|
||||
return newTimedcache(vmssVirtualMachinesTTL, getter)
|
||||
if ss.Config.VmssVirtualMachinesCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(vmssVirtualMachinesCacheTTLDefault)*time.Second, getter)
|
||||
}
|
||||
return newTimedcache(time.Duration(ss.Config.VmssVirtualMachinesCacheTTL)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (ss *scaleSet) deleteCacheForNode(nodeName string) error {
|
||||
@ -186,7 +192,10 @@ func (ss *scaleSet) newAvailabilitySetNodesCache() (*timedCache, error) {
|
||||
return localCache, nil
|
||||
}
|
||||
|
||||
return newTimedcache(availabilitySetNodesCacheTTL, getter)
|
||||
if ss.Config.AvailabilitySetNodesCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(availabilitySetNodesCacheTTLDefault)*time.Second, getter)
|
||||
}
|
||||
return newTimedcache(time.Duration(ss.Config.AvailabilitySetNodesCacheTTL)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (ss *scaleSet) isNodeManagedByAvailabilitySet(nodeName string, crt cacheReadType) (bool, error) {
|
||||
|
@ -35,10 +35,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
vmCacheTTL = time.Minute
|
||||
lbCacheTTL = 2 * time.Minute
|
||||
nsgCacheTTL = 2 * time.Minute
|
||||
rtCacheTTL = 2 * time.Minute
|
||||
vmCacheTTLDefault = 60 // in seconds
|
||||
lbCacheTTLDefault = 120 // in seconds
|
||||
nsgCacheTTLDefault = 120 // in seconds
|
||||
rtCacheTTLDefault = 120 // in seconds
|
||||
|
||||
azureNodeProviderIDRE = regexp.MustCompile(`^azure:///subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/(?:.*)`)
|
||||
azureResourceGroupNameRE = regexp.MustCompile(`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/(?:.*)`)
|
||||
@ -228,7 +228,10 @@ func (az *Cloud) newVMCache() (*timedCache, error) {
|
||||
return &vm, nil
|
||||
}
|
||||
|
||||
return newTimedcache(vmCacheTTL, getter)
|
||||
if az.VMCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(vmCacheTTLDefault)*time.Second, getter)
|
||||
}
|
||||
return newTimedcache(time.Duration(az.VMCacheTTL)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) newLBCache() (*timedCache, error) {
|
||||
@ -250,7 +253,10 @@ func (az *Cloud) newLBCache() (*timedCache, error) {
|
||||
return &lb, nil
|
||||
}
|
||||
|
||||
return newTimedcache(lbCacheTTL, getter)
|
||||
if az.LbCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(lbCacheTTLDefault)*time.Second, getter)
|
||||
}
|
||||
return newTimedcache(time.Duration(az.LbCacheTTL)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) newNSGCache() (*timedCache, error) {
|
||||
@ -271,7 +277,10 @@ func (az *Cloud) newNSGCache() (*timedCache, error) {
|
||||
return &nsg, nil
|
||||
}
|
||||
|
||||
return newTimedcache(nsgCacheTTL, getter)
|
||||
if az.NsgCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(nsgCacheTTLDefault)*time.Second, getter)
|
||||
}
|
||||
return newTimedcache(time.Duration(az.NsgCacheTTL)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) newRouteTableCache() (*timedCache, error) {
|
||||
@ -292,7 +301,10 @@ func (az *Cloud) newRouteTableCache() (*timedCache, error) {
|
||||
return &rt, nil
|
||||
}
|
||||
|
||||
return newTimedcache(rtCacheTTL, getter)
|
||||
if az.RtCacheTTL == 0 {
|
||||
return newTimedcache(time.Duration(rtCacheTTLDefault)*time.Second, getter)
|
||||
}
|
||||
return newTimedcache(time.Duration(az.RtCacheTTL)*time.Second, getter)
|
||||
}
|
||||
|
||||
func (az *Cloud) useStandardLoadBalancer() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user