Skip to content

Commit 91fbd38

Browse files
authored
[Aks] Add some properties for New-AzAksCluster and Set-AzAksCluster (Azure#19280)
* Add properties * Add some properties for New-AzAksCluster and Set-AzAksCluster Co-authored-by: wyunchi-ms <[email protected]>
1 parent aae4e15 commit 91fbd38

18 files changed

+856
-12
lines changed

src/Aks/Aks/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
* Added support of `FQDN` in `Import-AzAksCredential` [#17711]
2222
* Added hint when `Import-AzAksCredential` meets bad formatted kubernetes configuration file [#16741]
2323
* Added parameter `-NodeResourceGroup` for `New-AzAksCluster`. [#19014]
24+
* Added support for `Auto Upgrade` in `New-AzAksCluster` and `Set-AzAksCluster`.
25+
* Added support for `Http Proxy` in `New-AzAksCluster` and `Set-AzAksCluster`.
26+
* Added parameter `DisableLocalAccount` and `DiskEncryptionSetID` in `New-AzAksCluster` and `Set-AzAksCluster`.
2427

2528
## Version 4.2.1
2629
* Removed the warning messages for MSGraph migration [#18856]

src/Aks/Aks/Commands/CreateOrUpdateKubeBase.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,28 @@ public abstract class CreateOrUpdateKubeBase : KubeCmdletBase
164164
[Parameter(Mandatory = false, HelpMessage = "ResourceId of user assign managed identity for cluster.")]
165165
public string AssignIdentity { get; set; }
166166

167+
[Parameter(Mandatory = false, HelpMessage = "The upgrade channel for auto upgrade. For more information see https://docs.microsoft.com/azure/aks/upgrade-cluster#set-auto-upgrade-channel.")]
168+
[PSArgumentCompleter("rapid", "stable", "patch", "node-image", "none")]
169+
public string AutoUpgradeChannel { get; set; }
170+
171+
[Parameter(Mandatory = false, HelpMessage = "The resource ID of the disk encryption set to use for enabling encryption.")]
172+
public string DiskEncryptionSetID { get; set; }
173+
174+
[Parameter(Mandatory = false, HelpMessage = "Local accounts should be disabled on the Managed Cluster.")]
175+
public SwitchParameter DisableLocalAccount { get; set; }
176+
177+
[Parameter(Mandatory = false, HelpMessage = "The HTTP proxy server endpoint to use.")]
178+
public string HttpProxy { get; set; }
179+
180+
[Parameter(Mandatory = false, HelpMessage = "The HTTPS proxy server endpoint to use")]
181+
public string HttpsProxy { get; set; }
182+
183+
[Parameter(Mandatory = false, HelpMessage = "The endpoints that should not go through proxy.")]
184+
public string[] HttpProxyConfigNoProxyEndpoint { get; set; }
185+
186+
[Parameter(Mandatory = false, HelpMessage = "Alternative CA cert to use for connecting to proxy servers.")]
187+
public string HttpProxyConfigTrustedCa { get; set; }
188+
167189
protected void BeforeBuildNewCluster()
168190
{
169191
if (!string.IsNullOrEmpty(ResourceGroupName) && string.IsNullOrEmpty(Location))
@@ -528,6 +550,49 @@ protected ManagedClusterLoadBalancerProfile CreateOrUpdateLoadBalancerProfile(Ma
528550
return loadBalancerProfile;
529551
}
530552

553+
protected ManagedClusterAutoUpgradeProfile CreateOrUpdateAutoUpgradeProfile(ManagedClusterAutoUpgradeProfile autoUpgradeProfile)
554+
{
555+
if (this.IsParameterBound(c => c.AutoUpgradeChannel) && autoUpgradeProfile == null)
556+
{
557+
autoUpgradeProfile = new ManagedClusterAutoUpgradeProfile();
558+
}
559+
if (this.IsParameterBound(c => c.AutoUpgradeChannel))
560+
{
561+
autoUpgradeProfile.UpgradeChannel = AutoUpgradeChannel;
562+
}
563+
return autoUpgradeProfile;
564+
}
565+
566+
protected ManagedClusterHTTPProxyConfig CreateOrUpdateHttpProxyConfig(ManagedClusterHTTPProxyConfig httpProxyConfig)
567+
{
568+
if ((this.IsParameterBound(c => c.HttpProxy) ||
569+
this.IsParameterBound(c => c.HttpsProxy) ||
570+
this.IsParameterBound(c => c.HttpProxyConfigNoProxyEndpoint) ||
571+
this.IsParameterBound(c => c.HttpProxyConfigTrustedCa)) &&
572+
httpProxyConfig == null)
573+
{
574+
httpProxyConfig = new ManagedClusterHTTPProxyConfig();
575+
}
576+
if (this.IsParameterBound(c => c.HttpProxy))
577+
{
578+
httpProxyConfig.HttpProxy = HttpProxy;
579+
}
580+
if (this.IsParameterBound(c => c.HttpsProxy))
581+
{
582+
httpProxyConfig.HttpsProxy = HttpsProxy;
583+
}
584+
if (this.IsParameterBound(c => c.HttpProxyConfigNoProxyEndpoint))
585+
{
586+
httpProxyConfig.NoProxy = HttpProxyConfigNoProxyEndpoint;
587+
}
588+
if (this.IsParameterBound(c => c.HttpProxyConfigTrustedCa))
589+
{
590+
httpProxyConfig.TrustedCa = HttpProxyConfigTrustedCa;
591+
}
592+
593+
return httpProxyConfig;
594+
}
595+
531596
protected ManagedClusterAPIServerAccessProfile CreateOrUpdateApiServerAccessProfile(ManagedClusterAPIServerAccessProfile apiServerAccessProfile)
532597
{
533598
if ((this.IsParameterBound(c => c.ApiServerAccessAuthorizedIpRange) ||

src/Aks/Aks/Commands/NewAzureRmAks.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ private ManagedCluster BuildNewCluster()
343343

344344
var apiServerAccessProfile = CreateOrUpdateApiServerAccessProfile(null);
345345

346+
var httpProxyConfig = CreateOrUpdateHttpProxyConfig(null);
347+
348+
var autoUpgradeProfile = CreateOrUpdateAutoUpgradeProfile(null);
349+
346350
var addonProfiles = CreateAddonsProfiles();
347351

348352
WriteVerbose(string.Format(Resources.DeployingYourManagedKubeCluster, AcsSpFilePath));
@@ -361,7 +365,9 @@ private ManagedCluster BuildNewCluster()
361365
aadProfile: aadProfile,
362366
addonProfiles: addonProfiles,
363367
networkProfile: networkProfile,
364-
apiServerAccessProfile: apiServerAccessProfile);
368+
apiServerAccessProfile: apiServerAccessProfile,
369+
httpProxyConfig: httpProxyConfig,
370+
autoUpgradeProfile: autoUpgradeProfile);
365371

366372
SetIdentity(managedCluster);
367373

@@ -373,6 +379,14 @@ private ManagedCluster BuildNewCluster()
373379
{
374380
managedCluster.FqdnSubdomain = FqdnSubdomain;
375381
}
382+
if (this.IsParameterBound(c => c.DiskEncryptionSetID))
383+
{
384+
managedCluster.DiskEncryptionSetID = DiskEncryptionSetID;
385+
}
386+
if (DisableLocalAccount.IsPresent)
387+
{
388+
managedCluster.DisableLocalAccounts = DisableLocalAccount;
389+
}
376390
//if(EnablePodSecurityPolicy.IsPresent)
377391
//{
378392
// managedCluster.EnablePodSecurityPolicy = EnablePodSecurityPolicy;

src/Aks/Aks/Commands/SetAzureRmAks.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ public override void ExecuteCmdlet()
376376
}
377377
cluster.NetworkProfile = SetNetworkProfile(cluster.NetworkProfile);
378378
cluster.ApiServerAccessProfile = CreateOrUpdateApiServerAccessProfile(cluster.ApiServerAccessProfile);
379+
cluster.HttpProxyConfig = CreateOrUpdateHttpProxyConfig(cluster.HttpProxyConfig);
380+
cluster.AutoUpgradeProfile = CreateOrUpdateAutoUpgradeProfile(cluster.AutoUpgradeProfile);
379381
if (this.IsParameterBound(c => c.FqdnSubdomain))
380382
{
381383
cluster.FqdnSubdomain = FqdnSubdomain;
@@ -384,6 +386,15 @@ public override void ExecuteCmdlet()
384386

385387
var kubeCluster = Client.ManagedClusters.CreateOrUpdate(ResourceGroupName, Name, cluster);
386388

389+
if (this.IsParameterBound(c => c.DiskEncryptionSetID))
390+
{
391+
cluster.DiskEncryptionSetID = DiskEncryptionSetID;
392+
}
393+
if (DisableLocalAccount.IsPresent)
394+
{
395+
cluster.DisableLocalAccounts = DisableLocalAccount;
396+
}
397+
387398
WriteObject(PSMapper.Instance.Map<PSKubernetesCluster>(kubeCluster));
388399
});
389400
}

src/Aks/Aks/Models/Mapper.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ static PSMapper()
4747
cfg.CreateMap<ManagedClusterPoolUpgradeProfileUpgradesItem,PSManagedClusterPoolUpgradeProfileUpgradesItem>().ReverseMap();
4848
cfg.CreateMap<ManagedClusterUpgradeProfile,PSManagedClusterUpgradeProfile>().ReverseMap();
4949
cfg.CreateMap<ManagedClusterWindowsProfile, PSManagedClusterWindowsProfile>().ReverseMap();
50+
cfg.CreateMap<ManagedClusterAutoUpgradeProfile, PSManagedClusterAutoUpgradeProfile>().ReverseMap();
51+
cfg.CreateMap<ManagedClusterHTTPProxyConfig, PSManagedClusterHTTPProxyConfig>().ReverseMap();
52+
cfg.CreateMap<ManagedClusterPodIdentity, PSManagedClusterPodIdentity>().ReverseMap();
53+
cfg.CreateMap<ManagedClusterPodIdentityException, PSManagedClusterPodIdentityException>().ReverseMap();
54+
cfg.CreateMap<ManagedClusterPodIdentityProfile, PSManagedClusterPodIdentityProfile>().ReverseMap();
55+
cfg.CreateMap<UserAssignedIdentity, PSManagedClusterPodIdentityProfileUserAssignedIdentity>().ReverseMap();
56+
cfg.CreateMap<ManagedClusterPodIdentityProvisioningError, PSManagedClusterPodIdentityProvisioningError>().ReverseMap();
57+
cfg.CreateMap<ManagedClusterPodIdentityProvisioningErrorBody, PSManagedClusterPodIdentityProvisioningErrorBody>().ReverseMap();
58+
cfg.CreateMap<ManagedClusterPodIdentityProvisioningInfo, PSManagedClusterPodIdentityProvisioningInfo>().ReverseMap();
59+
cfg.CreateMap<ManagedClusterPropertiesAutoScalerProfile, PSManagedClusterAutoScalerProfile>().ReverseMap();
5060
cfg.CreateMap<Resource,PSResource>().ReverseMap();
5161
cfg.CreateMap<ResourceIdentityType, PSResourceIdentityType>().ReverseMap();
5262
cfg.CreateMap<AgentPool, PSNodePool>().ReverseMap();

src/Aks/Aks/Models/PSKubernetesCluster.cs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ public class PSKubernetesCluster : PSResource
9494
/// </summary>
9595
public string DnsPrefix { get; set; }
9696

97+
/// <summary>
98+
/// Gets or sets the FQDN subdomain of the private cluster with custom private dns.
99+
/// </summary>
100+
public string FqdnSubdomain { get; set; }
101+
97102
/// <summary>
98103
/// Gets FQDN for the master pool.
99104
/// </summary>
@@ -104,6 +109,13 @@ public class PSKubernetesCluster : PSResource
104109
/// </summary>
105110
public string PrivateFQDN { get; private set; }
106111

112+
/// <summary>
113+
/// Gets the special FQDN used by the Azure Portal to access the Managed Cluster.
114+
/// This FQDN is for use only by the Azure Portal and should not be used by other
115+
/// clients.
116+
/// </summary>
117+
public string AzurePortalFQDN { get; private set; }
118+
107119
/// <summary>
108120
/// Gets or sets properties of the agent pool.
109121
/// </summary>
@@ -120,6 +132,11 @@ public class PSKubernetesCluster : PSResource
120132
/// </summary>
121133
public IDictionary<string, PSManagedClusterAddonProfile> AddonProfiles { get; set; }
122134

135+
/// <summary>
136+
/// Gets or sets the pod identity profile of the Managed Cluster.
137+
/// </summary>
138+
public PSManagedClusterPodIdentityProfile PodIdentityProfile { get; set; }
139+
123140
/// <summary>
124141
/// Gets or sets name of the resource group containing agent pool
125142
/// nodes.
@@ -147,17 +164,43 @@ public class PSKubernetesCluster : PSResource
147164
/// Gets or sets profile of Azure Active Directory configuration.
148165
/// </summary>
149166
public PSManagedClusterAadProfile AadProfile { get; set; }
167+
168+
/// <summary>
169+
/// Gets or sets the auto upgrade configuration.
170+
/// </summary>
171+
public PSManagedClusterAutoUpgradeProfile AutoUpgradeProfile { get; set; }
172+
173+
/// <summary>
174+
/// Gets or sets parameters to be applied to the cluster-autoscaler when enabled
175+
/// </summary>
176+
public PSManagedClusterAutoScalerProfile AutoScalerProfile;
177+
178+
/// <summary>
179+
/// Gets or sets the Resource ID of the disk encryption set to use for enabling encryption
180+
/// at rest.
181+
/// </summary>
182+
public string DiskEncryptionSetID { get; set; }
150183

151184
/// <summary>
152185
/// Gets or sets access profile for managed cluster API server.
153186
/// </summary>
154187
public PSManagedClusterAPIServerAccessProfile ApiServerAccessProfile { get; set; }
155188

156-
//
157-
// Summary:
158-
// Gets or sets identities associated with the cluster.
189+
/// <summary>
190+
/// Gets or sets identities associated with the cluster.
191+
/// </summary>
159192
public IDictionary<string, PSManagedClusterPropertiesIdentityProfile> IdentityProfile { get; set; }
160193

194+
/// <summary>
195+
/// Gets or sets if local accounts should be disabled on the Managed Cluster.
196+
/// </summary>
197+
public bool? DisableLocalAccounts { get; set; }
198+
199+
/// <summary>
200+
/// Gets or sets configurations for provisioning the cluster with HTTP proxy servers.
201+
/// </summary>
202+
public PSManagedClusterHTTPProxyConfig HttpProxyConfig { get; set; }
203+
161204
/// <summary>
162205
/// Gets or sets the identity of the managed cluster, if configured.
163206
/// </summary>
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
17+
namespace Microsoft.Azure.Commands.Aks.Models
18+
{
19+
/// <summary>
20+
/// Parameters to be applied to the cluster-autoscaler when enabled.
21+
/// </summary>
22+
public partial class PSManagedClusterAutoScalerProfile
23+
{
24+
/// <summary>
25+
/// Gets or sets detects similar node pools and balances the number of nodes between
26+
/// them.
27+
/// </summary>
28+
public string BalanceSimilarNodeGroups { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the expander to use when scaling up
32+
/// </summary>
33+
public string Expander { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets the maximum number of empty nodes that can be deleted at the same
37+
/// time. This must be a positive integer.
38+
/// </summary>
39+
public string MaxEmptyBulkDelete { get; set; }
40+
41+
/// <summary>
42+
/// Gets or sets the maximum number of seconds the cluster autoscaler waits for pod
43+
/// termination when trying to scale down a node.
44+
/// </summary>
45+
public string MaxGracefulTerminationSec { get; set; }
46+
47+
/// <summary>
48+
/// Gets or sets the maximum time the autoscaler waits for a node to be provisioned.
49+
/// </summary>
50+
public string MaxNodeProvisionTime { get; set; }
51+
52+
/// <summary>
53+
/// Gets or sets the maximum percentage of unready nodes in the cluster. After this
54+
/// percentage is exceeded, cluster autoscaler halts operations.
55+
/// </summary>
56+
public string MaxTotalUnreadyPercentage { get; set; }
57+
58+
/// <summary>
59+
/// Gets or sets ignore unscheduled pods before they're a certain age.
60+
/// </summary>
61+
public string NewPodScaleUpDelay { get; set; }
62+
63+
/// <summary>
64+
/// Gets or sets the number of allowed unready nodes, irrespective of max-total-unready-percentage.
65+
/// </summary>
66+
public string OkTotalUnreadyCount { get; set; }
67+
68+
/// <summary>
69+
/// Gets or sets how often cluster is reevaluated for scale up or down.
70+
/// </summary>
71+
public string ScanInterval { get; set; }
72+
73+
/// <summary>
74+
/// Gets or sets how long after scale up that scale down evaluation resumes
75+
/// </summary>
76+
public string ScaleDownDelayAfterAdd { get; set; }
77+
78+
/// <summary>
79+
/// Gets or sets how long after node deletion that scale down evaluation resumes.
80+
/// </summary>
81+
public string ScaleDownDelayAfterDelete { get; set; }
82+
83+
/// <summary>
84+
/// Gets or sets how long after scale down failure that scale down evaluation resumes.
85+
/// </summary>
86+
public string ScaleDownDelayAfterFailure { get; set; }
87+
88+
/// <summary>
89+
/// Gets or sets how long a node should be unneeded before it is eligible for scale
90+
/// </summary>
91+
/// down.
92+
public string ScaleDownUnneededTime { get; set; }
93+
94+
/// <summary>
95+
/// Gets or sets how long an unready node should be unneeded before it is eligible
96+
/// for scale down
97+
/// </summary>
98+
public string ScaleDownUnreadyTime { get; set; }
99+
100+
/// <summary>
101+
/// Gets or sets node utilization level, defined as sum of requested resources divided
102+
/// by capacity, below which a node can be considered for scale down.
103+
/// </summary>
104+
public string ScaleDownUtilizationThreshold { get; set; }
105+
106+
/// <summary>
107+
/// Gets or sets if cluster autoscaler will skip deleting nodes with pods with local
108+
/// storage, for example, EmptyDir or HostPath.
109+
/// </summary>
110+
public string SkipNodesWithLocalStorage { get; set; }
111+
112+
/// <summary>
113+
/// Gets or sets if cluster autoscaler will skip deleting nodes with pods from kube-system
114+
/// (except for DaemonSet or mirror pods)
115+
/// </summary>
116+
public string SkipNodesWithSystemPods { get; set; }
117+
118+
}
119+
}

0 commit comments

Comments
 (0)