From 75bf76155fa685e1bfb6408697043ca9f8ebb395 Mon Sep 17 00:00:00 2001 From: "Menghua Chen (MSFT)" <111940661+Menghua1@users.noreply.github.com> Date: Thu, 12 Dec 2024 06:59:20 +0800 Subject: [PATCH] fix: Update parameters to implement non-AAD integrated clusters in Kubernetes (#3828) ## Description This PR introduces a conditional check for `aadProfile` configuration in Kubernetes cluster settings. Adds a user-defined type for the `aadProfile` parameter, and when the `aadProfile` parameter is empty, it disables AAD (Azure Active Directory). Ensures that AAD integration is completely skipped when not needed, optimizing resource usage and configuration complexity. Requested by the AZD team: https://github.com/Azure/Azure-Verified-Modules/issues/261, to ensure consistency with the functionality implemented in the [aks-managed-cluster.bicep](https://github.com/Azure/azure-dev/blob/main/templates/common/infra/bicep/core/host/aks-managed-cluster.bicep#L81-L85) file located in infra/core. ## Pipeline Reference | Pipeline | | -------- | | [![avm.res.container-service.managed-cluster](https://github.com/Menghua1/bicep-registry-modules/actions/workflows/avm.res.container-service.managed-cluster.yml/badge.svg?branch=fix%2Fadd-aad-profile-conditional)](https://github.com/Menghua1/bicep-registry-modules/actions/workflows/avm.res.container-service.managed-cluster.yml) | ## Type of Change - [ ] Update to CI Environment or utilities (Non-module affecting changes) - [x] Azure Verified Module updates: - [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`: - [ ] Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] Feature update backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [ ] Breaking changes and I have bumped the MAJOR version in `version.json`. - [ ] Update to documentation ## Checklist - [x] I'm sure there are no other open Pull Requests for the same update/change - [x] I have run `Set-AVMModule` locally to generate the supporting module files. - [x] My corresponding pipelines / checks run clean and green without any errors or warnings @rajeshkamal5050 for notification. --- .../managed-cluster/README.md | 281 ++++++++++++++++-- .../managed-cluster/agent-pool/main.json | 9 +- .../managed-cluster/main.bicep | 66 ++-- .../managed-cluster/main.json | 145 ++++----- .../maintenance-configurations/main.json | 4 +- .../tests/e2e/automatic/main.test.bicep | 4 + .../tests/e2e/azure/main.test.bicep | 4 + .../tests/e2e/defaults/main.test.bicep | 4 + .../tests/e2e/istio/main.test.bicep | 4 + .../tests/e2e/kubenet/main.test.bicep | 4 + .../tests/e2e/non-aad-cluster/main.test.bicep | 57 ++++ .../tests/e2e/priv/main.test.bicep | 4 + .../tests/e2e/waf-aligned/main.test.bicep | 4 + 13 files changed, 458 insertions(+), 132 deletions(-) create mode 100644 avm/res/container-service/managed-cluster/tests/e2e/non-aad-cluster/main.test.bicep diff --git a/avm/res/container-service/managed-cluster/README.md b/avm/res/container-service/managed-cluster/README.md index 8ff9e062da..df3ae5fcb5 100644 --- a/avm/res/container-service/managed-cluster/README.md +++ b/avm/res/container-service/managed-cluster/README.md @@ -37,8 +37,9 @@ The following section provides usage examples for the module, which were used to - [Using only defaults](#example-3-using-only-defaults) - [Using Istio Service Mesh add-on](#example-4-using-istio-service-mesh-add-on) - [Using Kubenet Network Plugin.](#example-5-using-kubenet-network-plugin) -- [Using Private Cluster.](#example-6-using-private-cluster) -- [WAF-aligned](#example-7-waf-aligned) +- [Deploying Non-AAD Cluster](#example-6-deploying-non-aad-cluster) +- [Using Private Cluster.](#example-7-using-private-cluster) +- [WAF-aligned](#example-8-waf-aligned) ### Example 1: _Using only defaults and use AKS Automatic mode_ @@ -64,6 +65,10 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster:' managedIdentities: { systemAssigned: true @@ -1162,6 +1195,12 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster:" }, @@ -1195,6 +1234,10 @@ param primaryAgentPoolProfiles = [ } ] // Non-required parameters +param aadProfile = { + aadProfileEnableAzureRBAC: true + aadProfileManaged: true +} param location = '' param managedIdentities = { systemAssigned: true @@ -1228,6 +1271,10 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster:

-### Example 6: _Using Private Cluster._ +### Example 6: _Deploying Non-AAD Cluster_ + +This instance deploys the module with a non-AAD integrated cluster. + + +

+ +via Bicep module + +```bicep +module managedCluster 'br/public:avm/res/container-service/managed-cluster:' = { + name: 'managedClusterDeployment' + params: { + // Required parameters + name: 'csnonaad001' + primaryAgentPoolProfiles: [ + { + count: 3 + mode: 'System' + name: 'systempool' + vmSize: 'Standard_DS2_v2' + } + ] + // Non-required parameters + aadProfile: '' + disableLocalAccounts: false + location: '' + managedIdentities: { + systemAssigned: true + } + } +} +``` + +
+

+ +

+ +via JSON parameters file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + // Required parameters + "name": { + "value": "csnonaad001" + }, + "primaryAgentPoolProfiles": { + "value": [ + { + "count": 3, + "mode": "System", + "name": "systempool", + "vmSize": "Standard_DS2_v2" + } + ] + }, + // Non-required parameters + "aadProfile": { + "value": "" + }, + "disableLocalAccounts": { + "value": false + }, + "location": { + "value": "" + }, + "managedIdentities": { + "value": { + "systemAssigned": true + } + } + } +} +``` + +
+

+ +

+ +via Bicep parameters file + +```bicep-params +using 'br/public:avm/res/container-service/managed-cluster:' + +// Required parameters +param name = 'csnonaad001' +param primaryAgentPoolProfiles = [ + { + count: 3 + mode: 'System' + name: 'systempool' + vmSize: 'Standard_DS2_v2' + } +] +// Non-required parameters +param aadProfile = '' +param disableLocalAccounts = false +param location = '' +param managedIdentities = { + systemAssigned: true +} +``` + +
+

+ +### Example 7: _Using Private Cluster._ This instance deploys the module with a private cluster instance. @@ -1796,6 +1978,10 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster:

-### Example 7: _WAF-aligned_ +### Example 8: _WAF-aligned_ This instance deploys the module in alignment with the best-practices of the Well-Architected Framework. @@ -2106,6 +2302,10 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster: