Skip to content

Commit

Permalink
mgmt, AKS improvement (#21850)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored May 28, 2021
1 parent 73ad63d commit 34a7365
Show file tree
Hide file tree
Showing 12 changed files with 2,034 additions and 21 deletions.
3 changes: 2 additions & 1 deletion sdk/resourcemanager/api-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
"dir": "azure-resourcemanager-containerservice",
"source": "specification/containerservice/resource-manager/readme.md",
"package": "com.azure.resourcemanager.containerservice",
"args": "--payload-flattening-threshold=1 --tag=package-2021-03 --title=ContainerServiceManagementClient --description=\"Container Service Client\" --remove-model=BaseManagedCluster --rename-model=ManagedClusterIdentityUserAssignedIdentitiesValue:ManagedClusterIdentityUserAssignedIdentities,ManagedClusterPropertiesIdentityProfile:ManagedClusterPropertiesIdentityProfileValue"
"args": "--payload-flattening-threshold=1 --tag=package-2021-03 --title=ContainerServiceManagementClient --description=\"Container Service Client\" --remove-model=BaseManagedCluster --rename-model=ManagedClusterIdentityUserAssignedIdentitiesValue:ManagedClusterIdentityUserAssignedIdentities,ManagedClusterPropertiesIdentityProfile:ManagedClusterPropertiesIdentityProfileValue",
"note": "Remove 'final' from 'ManagedClusterAgentPoolProfile'"
},
"cosmos": {
"dir": "azure-resourcemanager-cosmos",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 2.5.0-beta.1 (Unreleased)

- Supported system-assigned managed identity and auto-scaler profile for `KubernetesCluster`.
- Supported auto-scaling, availability zones, node labels and taints for agent pool of `KubernetesCluster`.

## 2.4.0 (2021-04-28)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@
import com.azure.resourcemanager.containerservice.models.KubernetesClusterAgentPool;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.OSType;
import com.azure.resourcemanager.containerservice.models.PowerState;
import com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.ChildResourceImpl;
import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;

/** The implementation for KubernetesClusterAgentPool and its create and update interfaces. */
public class KubernetesClusterAgentPoolImpl
Expand Down Expand Up @@ -78,6 +87,51 @@ public String networkId() {
return (subnetId != null) ? ResourceUtils.parentResourceIdFromResourceId(subnetId) : null;
}

@Override
public List<String> availabilityZones() {
return innerModel().availabilityZones();
}

@Override
public Map<String, String> nodeLabels() {
return innerModel().nodeLabels() == null ? null : Collections.unmodifiableMap(innerModel().nodeLabels());
}

@Override
public List<String> nodeTaints() {
return innerModel().nodeTaints() == null ? null : Collections.unmodifiableList(innerModel().nodeTaints());
}

@Override
public PowerState powerState() {
return innerModel().powerState();
}

@Override
public boolean isAutoScalingEnabled() {
return ResourceManagerUtils.toPrimitiveBoolean(innerModel().enableAutoScaling());
}

@Override
public int nodeSize() {
return ResourceManagerUtils.toPrimitiveInt(innerModel().count());
}

@Override
public int maximumPodsPerNode() {
return ResourceManagerUtils.toPrimitiveInt(innerModel().maxPods());
}

@Override
public int minimumNodeSize() {
return ResourceManagerUtils.toPrimitiveInt(innerModel().minCount());
}

@Override
public int maximumNodeSize() {
return ResourceManagerUtils.toPrimitiveInt(innerModel().maxCount());
}

@Override
public KubernetesClusterAgentPoolImpl withVirtualMachineSize(ContainerServiceVMSizeTypes vmSize) {
this.innerModel().withVmSize(vmSize.toString());
Expand Down Expand Up @@ -162,6 +216,7 @@ public AgentPoolInner getAgentPoolInner() {
agentPoolInner.withKubeletConfig(innerModel().kubeletConfig());
agentPoolInner.withLinuxOSConfig(innerModel().linuxOSConfig());
agentPoolInner.withEnableEncryptionAtHost(innerModel().enableEncryptionAtHost());
agentPoolInner.withEnableFips(innerModel().enableFips());
agentPoolInner.withGpuInstanceProfile(innerModel().gpuInstanceProfile());
return agentPoolInner;
}
Expand All @@ -171,4 +226,38 @@ public KubernetesClusterAgentPoolImpl withAgentPoolMode(AgentPoolMode agentPoolM
innerModel().withMode(agentPoolMode);
return this;
}

@Override
public KubernetesClusterAgentPoolImpl withAutoScaling(int minimumNodeSize, int maximumNodeSize) {
innerModel().withEnableAutoScaling(true);
innerModel().withMinCount(minimumNodeSize);
innerModel().withMaxCount(maximumNodeSize);
return this;
}

@Override
public Update<KubernetesClusterImpl> withoutAutoScaling() {
innerModel().withEnableAutoScaling(false);
innerModel().withMinCount(null);
innerModel().withMaxCount(null);
return this;
}

@Override
public KubernetesClusterAgentPoolImpl withAvailabilityZones(Integer... zones) {
innerModel().withAvailabilityZones(Arrays.stream(zones).map(String::valueOf).collect(Collectors.toList()));
return this;
}

@Override
public KubernetesClusterAgentPoolImpl withNodeLabels(Map<String, String> nodeLabels) {
innerModel().withNodeLabels(nodeLabels == null ? null : new TreeMap<>(nodeLabels));
return this;
}

@Override
public KubernetesClusterAgentPoolImpl withNodeTaints(List<String> nodeTaints) {
innerModel().withNodeTaints(nodeTaints);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
import com.azure.resourcemanager.containerservice.models.ManagedClusterAddonProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterApiServerAccessProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterIdentity;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesAutoScalerProfile;
import com.azure.resourcemanager.containerservice.models.ManagedClusterPropertiesIdentityProfileValue;
import com.azure.resourcemanager.containerservice.models.ManagedClusterServicePrincipalProfile;
import com.azure.resourcemanager.containerservice.models.PowerState;
import com.azure.resourcemanager.containerservice.models.ResourceIdentityType;
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpoint;
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnection;
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnectionProvisioningState;
Expand Down Expand Up @@ -183,6 +188,24 @@ public boolean enableRBAC() {
return this.innerModel().enableRbac();
}

@Override
public PowerState powerState() {
return this.innerModel().powerState();
}

@Override
public String systemAssignedManagedServiceIdentityPrincipalId() {
String objectId = null;
if (this.innerModel().identityProfile() != null) {
ManagedClusterPropertiesIdentityProfileValue identity =
this.innerModel().identityProfile().get("kubeletidentity");
if (identity != null) {
objectId = identity.objectId();
}
}
return objectId;
}

private Mono<List<CredentialResult>> listAdminConfig(final KubernetesClusterImpl self) {
return this
.manager()
Expand Down Expand Up @@ -289,6 +312,18 @@ public KubernetesClusterImpl withServicePrincipalClientId(String clientId) {
return this;
}

@Override
public KubernetesClusterImpl withSystemAssignedManagedServiceIdentity() {
this.innerModel().withIdentity(new ManagedClusterIdentity().withType(ResourceIdentityType.SYSTEM_ASSIGNED));
return this;
}

// @Override
// public KubernetesClusterImpl enableRoleBasedAccessControl() {
// this.innerModel().withEnableRbac(true);
// return this;
// }

@Override
public KubernetesClusterImpl withServicePrincipalSecret(String secret) {
this.innerModel().servicePrincipalProfile().withSecret(secret);
Expand Down Expand Up @@ -319,6 +354,21 @@ public KubernetesClusterAgentPoolImpl updateAgentPool(String name) {
"Cannot get agent pool named %s", name)));
}

@Override
public Update withoutAgentPool(String name) {
if (innerModel().agentPoolProfiles() != null) {
innerModel().withAgentPoolProfiles(
innerModel().agentPoolProfiles().stream()
.filter(p -> !name.equals(p.name()))
.collect(Collectors.toList()));

this.addDependency(context ->
manager().serviceClient().getAgentPools().deleteAsync(resourceGroupName(), name(), name)
.then(context.voidMono()));
}
return this;
}

@Override
public KubernetesCluster.DefinitionStages.NetworkProfileDefinitionStages.Blank<
KubernetesCluster.DefinitionStages.WithCreate>
Expand Down Expand Up @@ -361,6 +411,12 @@ public KubernetesClusterImpl addNewAgentPool(KubernetesClusterAgentPoolImpl agen
return this;
}

@Override
public KubernetesClusterImpl withAutoScalerProfile(ManagedClusterPropertiesAutoScalerProfile autoScalerProfile) {
this.innerModel().withAutoScalerProfile(autoScalerProfile);
return this;
}

@Override
public KubernetesClusterImpl enablePrivateCluster() {
if (innerModel().apiServerAccessProfile() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.azure.resourcemanager.containerservice.models.ContainerServiceNetworkProfile;
import com.azure.resourcemanager.containerservice.models.KubernetesCluster;
import com.azure.resourcemanager.containerservice.models.LoadBalancerSku;
import com.azure.resourcemanager.containerservice.models.NetworkPlugin;
import com.azure.resourcemanager.containerservice.models.NetworkPolicy;

Expand Down Expand Up @@ -54,6 +55,12 @@ public KubernetesClusterNetworkProfileImpl withDockerBridgeCidr(String dockerBri
return this;
}

@Override
public KubernetesClusterNetworkProfileImpl withLoadBalancerSku(LoadBalancerSku loadBalancerSku) {
ensureNetworkProfile().withLoadBalancerSku(loadBalancerSku);
return this;
}

@Override
public KubernetesClusterImpl attach() {
return parentKubernetesCluster;
Expand Down
Loading

0 comments on commit 34a7365

Please sign in to comment.