Skip to content

Commit b6099b2

Browse files
mgmt, AKS, support AAD integration (Azure#27729)
* support rbac in create * aks with aad integration * changelog * javadoc
1 parent a37770e commit b6099b2

File tree

14 files changed

+2812
-47
lines changed

14 files changed

+2812
-47
lines changed

sdk/resourcemanager/azure-resourcemanager-authorization/CHANGELOG.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
### Features Added
66

7-
### Breaking Changes
8-
9-
### Bugs Fixed
10-
11-
### Other Changes
7+
- Supported Azure Kubernetes Service related roles to `BuiltInRole`.
128

139
## 2.13.0 (2022-03-11)
1410

sdk/resourcemanager/azure-resourcemanager-authorization/src/main/java/com/azure/resourcemanager/authorization/models/BuiltInRole.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77

88
import java.util.Collection;
99

10-
/** Defines values for roles. */
10+
/**
11+
* Defines values for roles.
12+
* <p>
13+
* It is not the complete list of roles.
14+
* See {@link RoleDefinitions#listByScope(String)} for all viable roles,
15+
* and {@link RoleDefinition#roleName()} as {@link BuiltInRole}.
16+
*/
1117
public final class BuiltInRole extends ExpandableStringEnum<BuiltInRole> {
1218
/** A role that can manage API Management service and the APIs. */
1319
public static final BuiltInRole API_MANAGEMENT_SERVICE_CONTRIBUTOR =
@@ -211,6 +217,29 @@ public final class BuiltInRole extends ExpandableStringEnum<BuiltInRole> {
211217
public static final BuiltInRole KEY_VAULT_CRYPTO_SERVICE_ENCRYPTION_USER =
212218
BuiltInRole.fromString("Key Vault Crypto Service Encryption User");
213219

220+
// AKS related roles
221+
/** Lets you manage all resources in the cluster. */
222+
public static final BuiltInRole AZURE_KUBERNETES_SERVICE_RBAC_CLUSTER_ADMIN =
223+
BuiltInRole.fromString("Azure Kubernetes Service RBAC Cluster Admin");
224+
/** Lets you manage all resources under cluster/namespace,
225+
* except update or delete resource quotas and namespaces. */
226+
public static final BuiltInRole AZURE_KUBERNETES_SERVICE_RBAC_ADMIN =
227+
BuiltInRole.fromString("Azure Kubernetes Service RBAC Admin");
228+
/** Allows read-only access to see most objects in a namespace. It does not allow viewing roles or role bindings.
229+
* This role does not allow viewing Secrets, since reading the contents of Secrets enables access to ServiceAccount
230+
* credentials in the namespace, which would allow API access as any ServiceAccount in the namespace
231+
* (a form of privilege escalation).
232+
* Applying this role at cluster scope will give access across all namespaces. */
233+
public static final BuiltInRole AZURE_KUBERNETES_SERVICE_RBAC_READER =
234+
BuiltInRole.fromString("Azure Kubernetes Service RBAC Reader");
235+
/** Allows read/write access to most objects in a namespace.
236+
* This role does not allow viewing or modifying roles or role bindings.
237+
* However, this role allows accessing Secrets and running Pods as any ServiceAccount in the namespace,
238+
* so it can be used to gain the API access levels of any ServiceAccount in the namespace.
239+
* Applying this role at cluster scope will give access across all namespaces. */
240+
public static final BuiltInRole AZURE_KUBERNETES_SERVICE_RBAC_WRITER =
241+
BuiltInRole.fromString("Azure Kubernetes Service RBAC Writer");
242+
214243
/**
215244
* Finds or creates a role instance based on the specified name.
216245
*

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachine.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ interface WithEphemeralOSDisk {
12331233
interface WithVMSize {
12341234
/**
12351235
* Selects the size of the virtual machine.
1236-
*
1236+
* <p>
12371237
* See {@link ComputeSkus#listByRegion(Region)} for virtual machine sizes in region,
12381238
* and {@link AvailabilitySet#listVirtualMachineSizes()} for virtual machine sizes in availability set.
12391239
*
@@ -1244,7 +1244,7 @@ interface WithVMSize {
12441244

12451245
/**
12461246
* Specifies the size of the virtual machine.
1247-
*
1247+
* <p>
12481248
* {@link VirtualMachineSizeTypes} is not the complete list of virtual machine sizes.
12491249
* See {@link ComputeSkus#listByRegion(Region)} for virtual machine sizes in region,
12501250
* and {@link AvailabilitySet#listVirtualMachineSizes()} for virtual machine sizes in availability set.
@@ -1863,7 +1863,7 @@ interface WithNetworkInterfaceDeleteOptions {
18631863
interface WithAdditionalCapacities {
18641864
/**
18651865
* Enables hibernation feature.
1866-
*
1866+
* <p>
18671867
* Hibernation is supported on premium general purpose SKUs, e.g. STANDARD_D2S_V3.
18681868
* Hibernation is supported on Windows 10 19H1 and higher, and Windows Server 2019 and higher.
18691869
* For Ubuntu 18.04 or higher, hibernation-setup-tool is required to be installed on the virtual machine.
@@ -2447,7 +2447,7 @@ interface Update
24472447

24482448
/**
24492449
* Specifies a new size for the virtual machine.
2450-
*
2450+
* <p>
24512451
* See {@link VirtualMachine#availableSizes()} for resizing.
24522452
*
24532453
* @param sizeName the name of a size for the virtual machine as text
@@ -2457,7 +2457,7 @@ interface Update
24572457

24582458
/**
24592459
* Specifies a new size for the virtual machine.
2460-
*
2460+
* <p>
24612461
* {@link VirtualMachineSizeTypes} is not the complete list of virtual machine sizes.
24622462
* See {@link VirtualMachine#availableSizes()} for resizing.
24632463
*

sdk/resourcemanager/azure-resourcemanager-containerservice/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22

33
## 2.14.0-beta.1 (Unreleased)
44

5+
### Features Added
6+
7+
- Supported disabling Kubernetes Role-Based Access Control for `KubernetesCluster` during create.
8+
- Supported enabling Azure AD integration for `KubernetesCluster`.
9+
- Supported disabling local accounts for `KubernetesCluster`.
10+
511
### Other Changes
612

713
- Changed behavior that `KubernetesCluster` no longer retrieves admin and user KubeConfig during create, update, refresh.
14+
- Changed behavior that Linux profile is not required for `KubernetesCluster` during create.
815

916
## 2.13.0 (2022-03-11)
1017

@@ -38,6 +45,12 @@
3845

3946
- Updated `api-version` to `2022-01-01`.
4047

48+
## 2.12.2 (2022-03-17)
49+
50+
### Other Changes
51+
52+
- Changed behavior that `KubernetesCluster` no longer retrieves admin and user KubeConfig during create, update, refresh.
53+
4154
## 2.12.1 (2022-02-22)
4255

4356
### Bugs Fixed

sdk/resourcemanager/azure-resourcemanager-containerservice/src/main/java/com/azure/resourcemanager/containerservice/implementation/KubernetesClusterImpl.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.azure.core.http.rest.PagedIterable;
77
import com.azure.core.http.rest.Response;
88
import com.azure.core.http.rest.SimpleResponse;
9+
import com.azure.core.util.CoreUtils;
910
import com.azure.core.util.logging.ClientLogger;
1011
import com.azure.resourcemanager.containerservice.ContainerServiceManager;
1112
import com.azure.resourcemanager.containerservice.fluent.models.ManagedClusterInner;
@@ -19,6 +20,7 @@
1920
import com.azure.resourcemanager.containerservice.models.Format;
2021
import com.azure.resourcemanager.containerservice.models.KubernetesCluster;
2122
import com.azure.resourcemanager.containerservice.models.KubernetesClusterAgentPool;
23+
import com.azure.resourcemanager.containerservice.models.ManagedClusterAadProfile;
2224
import com.azure.resourcemanager.containerservice.models.ManagedClusterAddonProfile;
2325
import com.azure.resourcemanager.containerservice.models.ManagedClusterAgentPoolProfile;
2426
import com.azure.resourcemanager.containerservice.models.ManagedClusterApiServerAccessProfile;
@@ -34,6 +36,7 @@
3436
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateLinkResource;
3537
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
3638
import com.azure.resourcemanager.resources.fluentcore.utils.PagedConverter;
39+
import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils;
3740
import reactor.core.publisher.Mono;
3841

3942
import java.util.ArrayList;
@@ -238,6 +241,27 @@ public String systemAssignedManagedServiceIdentityPrincipalId() {
238241
return objectId;
239242
}
240243

244+
@Override
245+
public List<String> azureActiveDirectoryGroupIds() {
246+
if (innerModel().aadProfile() == null
247+
|| CoreUtils.isNullOrEmpty(innerModel().aadProfile().adminGroupObjectIDs())) {
248+
return Collections.emptyList();
249+
} else {
250+
return Collections.unmodifiableList(innerModel().aadProfile().adminGroupObjectIDs());
251+
}
252+
}
253+
254+
@Override
255+
public boolean isLocalAccountsEnabled() {
256+
return !ResourceManagerUtils.toPrimitiveBoolean(innerModel().disableLocalAccounts());
257+
}
258+
259+
@Override
260+
public boolean isAzureRbacEnabled() {
261+
return innerModel().aadProfile() != null
262+
&& ResourceManagerUtils.toPrimitiveBoolean(innerModel().aadProfile().enableAzureRbac());
263+
}
264+
241265
@Override
242266
public void start() {
243267
this.startAsync().block();
@@ -479,6 +503,49 @@ public PagedFlux<PrivateEndpointConnection> listPrivateEndpointConnectionsAsync(
479503
return PagedConverter.convertListToPagedFlux(retList);
480504
}
481505

506+
@Override
507+
public KubernetesClusterImpl withAzureActiveDirectoryGroup(String activeDirectoryGroupObjectId) {
508+
this.withRBACEnabled();
509+
510+
if (innerModel().aadProfile() == null) {
511+
innerModel().withAadProfile(new ManagedClusterAadProfile().withManaged(true));
512+
}
513+
if (innerModel().aadProfile().adminGroupObjectIDs() == null) {
514+
innerModel().aadProfile().withAdminGroupObjectIDs(new ArrayList<>());
515+
}
516+
innerModel().aadProfile().adminGroupObjectIDs().add(activeDirectoryGroupObjectId);
517+
return this;
518+
}
519+
520+
@Override
521+
public KubernetesClusterImpl enableAzureRbac() {
522+
this.withRBACEnabled();
523+
524+
if (innerModel().aadProfile() == null) {
525+
innerModel().withAadProfile(new ManagedClusterAadProfile().withManaged(true));
526+
}
527+
innerModel().aadProfile().withEnableAzureRbac(true);
528+
return this;
529+
}
530+
531+
@Override
532+
public KubernetesClusterImpl enableLocalAccounts() {
533+
innerModel().withDisableLocalAccounts(false);
534+
return this;
535+
}
536+
537+
@Override
538+
public KubernetesClusterImpl disableLocalAccounts() {
539+
innerModel().withDisableLocalAccounts(true);
540+
return this;
541+
}
542+
543+
@Override
544+
public KubernetesCluster.DefinitionStages.WithCreate disableKubernetesRbac() {
545+
this.innerModel().withEnableRbac(false);
546+
return this;
547+
}
548+
482549
private static final class PrivateLinkResourceImpl implements PrivateLinkResource {
483550
private final PrivateLinkResourceInner innerModel;
484551

0 commit comments

Comments
 (0)