Skip to content

Commit

Permalink
feat: Enable cost analysis add-on in managed cluster module (#1682)
Browse files Browse the repository at this point in the history
## Description

This pull request adds the ability to enable the newly GA cost analysis
feature of AKS.
<!--
>Thank you for your contribution !
> Please include a summary of the change and which issue is fixed.
> Please also include the context.
> List any dependencies that are required for this change.

Fixes #123
Fixes #456
Closes #123
Closes #456
-->

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.container-service.managed-cluster](https://github.com/PixelRobots/bicep-registry-modules/actions/workflows/avm.res.container-service.managed-cluster.yml/badge.svg)](https://github.com/PixelRobots/bicep-registry-modules/actions/workflows/avm.res.container-service.managed-cluster.yml)
|

## Type of Change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utlities (Non-module effecting
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.
- [ ] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to day with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Signed-off-by: PixelRobots <[email protected]>
  • Loading branch information
PixelRobots authored Apr 17, 2024
1 parent b5d76b9 commit 3ef0a9b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
9 changes: 9 additions & 0 deletions avm/res/container-service/managed-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster:<vers
| [`autoUpgradeProfileUpgradeChannel`](#parameter-autoupgradeprofileupgradechannel) | string | Auto-upgrade channel on the AKS cluster. |
| [`azurePolicyEnabled`](#parameter-azurepolicyenabled) | bool | Specifies whether the azurepolicy add-on is enabled or not. For security reasons, this setting should be enabled. |
| [`azurePolicyVersion`](#parameter-azurepolicyversion) | string | Specifies the azure policy version to use. |
| [`costAnalysisEnabled`](#parameter-costanalysisenabled) | bool | Specifies whether the cost analysis add-on is enabled or not. If Enabled `enableStorageProfileDiskCSIDriver` is set to true as it is needed. |
| [`customerManagedKey`](#parameter-customermanagedkey) | object | The customer managed key definition. |
| [`diagnosticSettings`](#parameter-diagnosticsettings) | array | The diagnostic settings of the service. |
| [`disableLocalAccounts`](#parameter-disablelocalaccounts) | bool | If set to true, getting static credentials will be disabled for this cluster. This must only be used on Managed Clusters that are AAD enabled. |
Expand Down Expand Up @@ -2239,6 +2240,14 @@ Specifies the azure policy version to use.
- Type: string
- Default: `'v2'`

### Parameter: `costAnalysisEnabled`

Specifies whether the cost analysis add-on is enabled or not. If Enabled `enableStorageProfileDiskCSIDriver` is set to true as it is needed.

- Required: No
- Type: bool
- Default: `False`

### Parameter: `customerManagedKey`

The customer managed key definition.
Expand Down
10 changes: 9 additions & 1 deletion avm/res/container-service/managed-cluster/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ param primaryAgentPoolProfile array
@description('Optional. Define one or more secondary/additional agent pools.')
param agentPools agentPoolType

@description('Optional. Specifies whether the cost analysis add-on is enabled or not. If Enabled `enableStorageProfileDiskCSIDriver` is set to true as it is needed.')
param costAnalysisEnabled bool = false

@description('Optional. Specifies whether the httpApplicationRouting add-on is enabled or not.')
param httpApplicationRoutingEnabled bool = false

Expand Down Expand Up @@ -535,6 +538,11 @@ resource managedCluster 'Microsoft.ContainerService/managedClusters@2023-07-02-p
}
: null
servicePrincipalProfile: aksServicePrincipalProfile
metricsProfile: {
costAnalysis: {
enabled: skuTier == 'free' ? false : costAnalysisEnabled
}
}
ingressProfile: {
webAppRouting: {
enabled: webApplicationRoutingEnabled
Expand Down Expand Up @@ -716,7 +724,7 @@ resource managedCluster 'Microsoft.ContainerService/managedClusters@2023-07-02-p
enabled: enableStorageProfileBlobCSIDriver
}
diskCSIDriver: {
enabled: enableStorageProfileDiskCSIDriver
enabled: costAnalysisEnabled == true && skuTier != 'free' ? true : enableStorageProfileDiskCSIDriver
}
fileCSIDriver: {
enabled: enableStorageProfileFileCSIDriver
Expand Down
11 changes: 9 additions & 2 deletions avm/res/container-service/managed-cluster/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "4896491646814133286"
"templateHash": "11298093745131885845"
},
"name": "Azure Kubernetes Service (AKS) Managed Clusters",
"description": "This module deploys an Azure Kubernetes Service (AKS) Managed Cluster.",
Expand Down Expand Up @@ -957,6 +957,13 @@
"description": "Optional. Define one or more secondary/additional agent pools."
}
},
"costAnalysisEnabled": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Optional. Specifies whether the cost analysis add-on is enabled or not. If Enabled `enableStorageProfileDiskCSIDriver` is set to true as it is needed."
}
},
"httpApplicationRoutingEnabled": {
"type": "bool",
"defaultValue": false,
Expand Down Expand Up @@ -1633,7 +1640,7 @@
"enabled": "[parameters('enableStorageProfileBlobCSIDriver')]"
},
"diskCSIDriver": {
"enabled": "[parameters('enableStorageProfileDiskCSIDriver')]"
"enabled": "[if(equals(parameters('costAnalysisEnabled'), true()), true(), parameters('enableStorageProfileDiskCSIDriver'))]"
},
"fileCSIDriver": {
"enabled": "[parameters('enableStorageProfileFileCSIDriver')]"
Expand Down

0 comments on commit 3ef0a9b

Please sign in to comment.