Skip to content

Commit 20fcc96

Browse files
committed
Rename config vars
1 parent 8602947 commit 20fcc96

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

cluster-autoscaler/cloudprovider/azure/azure_cache.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ type azureCache struct {
107107
}
108108

109109
func newAzureCache(client *azClient, cacheTTL time.Duration, config Config) (*azureCache, error) {
110+
nodeResourceGroup := config.ResourceGroup
111+
if config.HostedResourceGroup != "" {
112+
nodeResourceGroup = config.HostedResourceGroup
113+
}
110114
cache := &azureCache{
111115
interrupt: make(chan struct{}),
112116
azClient: client,
113117
refreshInterval: cacheTTL,
114-
resourceGroup: config.ResourceGroup,
118+
resourceGroup: nodeResourceGroup,
115119
clusterResourceGroup: config.ClusterResourceGroup,
116120
clusterName: config.ClusterName,
117121
enableVMsAgentPool: config.EnableVMsAgentPool,

cluster-autoscaler/cloudprovider/azure/azure_config.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ type Config struct {
6565
// It can override the default public ARM endpoint for VMs pool scale operations.
6666
ARMBaseURLForAPClient string `json:"armBaseURLForAPClient" yaml:"armBaseURLForAPClient"`
6767

68+
// Hosted (on-behalf-of) system pool configuration for automatic cluster.
69+
// HostedSubscriptionID is the subscription ID of the hosted resources under AKS internal tenant.
70+
HostedSubscriptionID string `json:"hostedSubscriptionID" yaml:"hostedSubscriptionID"`
71+
// HostedResourceGroup is the resource group of the hosted resources under AKS internal tenant.
72+
HostedResourceGroup string `json:"hostedResourceGroup" yaml:"hostedResourceGroup"`
73+
// HostedResourceProxyURL is the URL to use for retrieving hosted resources under AKS internal tenant.
74+
// It can override the default public ARM endpoint for operations like VM/SKU GET.
75+
HostedResourceProxyURL string `json:"hostedResourceProxyURL" yaml:"hostedResourceProxyURL"`
76+
6877
// AuthMethod determines how to authorize requests for the Azure
6978
// cloud. Valid options are "principal" (= the traditional
7079
// service principle approach) and "cli" (= load az command line
@@ -223,6 +232,15 @@ func BuildAzureConfig(configReader io.Reader) (*Config, error) {
223232
if _, err = assignFromEnvIfExists(&cfg.SubscriptionID, "ARM_SUBSCRIPTION_ID"); err != nil {
224233
return nil, err
225234
}
235+
if _, err = assignFromEnvIfExists(&cfg.HostedResourceProxyURL, "HOSTED_RESOURCE_PROXY_URL"); err != nil {
236+
return nil, err
237+
}
238+
if _, err = assignFromEnvIfExists(&cfg.HostedSubscriptionID, "HOSTED_SUBSCRIPTION_ID"); err != nil {
239+
return nil, err
240+
}
241+
if _, err = assignFromEnvIfExists(&cfg.HostedResourceGroup, "HOSTED_RESOURCE_GROUP"); err != nil {
242+
return nil, err
243+
}
226244
if _, err = assignBoolFromEnvIfExists(&cfg.UseManagedIdentityExtension, "ARM_USE_MANAGED_IDENTITY_EXTENSION"); err != nil {
227245
return nil, err
228246
}
@@ -387,6 +405,17 @@ func (cfg *Config) getAzureClientConfig(authorizer autorest.Authorizer, env *azu
387405
}
388406
}
389407

408+
// A proxy service is required to access resources for the managed system pool within automatic clusters.
409+
if cfg.HostedResourceProxyURL != "" {
410+
azClientConfig.ResourceManagerEndpoint = cfg.HostedResourceProxyURL
411+
}
412+
413+
// Managed system pool resources are hosted under AKS internal tenant and subscription.
414+
// it is different from the customer subscription where the cluster is created.
415+
if cfg.HostedSubscriptionID != "" {
416+
azClientConfig.SubscriptionID = cfg.HostedSubscriptionID
417+
}
418+
390419
return azClientConfig
391420
}
392421

cluster-autoscaler/cloudprovider/azure/azure_vms_pool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ func (vmPool *VMPool) IncreaseSize(delta int) error {
154154
if len(versionedAP.Properties.VirtualMachinesProfile.Scale.Manual) > 0 {
155155
requestBody = buildRequestBodyForScaleUp(versionedAP, count, vmPool.sku)
156156

157-
} else { // AKS-managed CAS will use custom header for setting the target count
158-
header := make(http.Header)
159-
header.Set("Target-Count", fmt.Sprintf("%d", count))
160-
updateCtx = policy.WithHTTPHeader(updateCtx, header)
161157
}
158+
header := make(http.Header)
159+
header.Set("Target-Count", fmt.Sprintf("%d", count))
160+
header.Set("SKU", fmt.Sprintf("%s", vmPool.sku))
161+
updateCtx = policy.WithHTTPHeader(updateCtx, header)
162162

163163
defer vmPool.manager.invalidateCache()
164164
poller, err := vmPool.manager.azClient.agentPoolClient.BeginCreateOrUpdate(

0 commit comments

Comments
 (0)