Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into users/krbar/dcrKind
  • Loading branch information
krbar committed Sep 6, 2024
2 parents dd9ddf7 + d03d954 commit 98a89d1
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 30 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 @@ -1658,6 +1658,7 @@ module managedCluster 'br/public:avm/res/container-service/managed-cluster:<vers
| [`supportPlan`](#parameter-supportplan) | string | The support plan for the Managed Cluster. |
| [`syslogPort`](#parameter-syslogport) | int | The syslog host port. If not specified, the default port is 28330. |
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`vpaAddon`](#parameter-vpaaddon) | bool | Whether to enable VPA add-on in cluster. Default value is false. |
| [`webApplicationRoutingEnabled`](#parameter-webapplicationroutingenabled) | bool | Specifies whether the webApplicationRoutingEnabled add-on is enabled or not. |

### Parameter: `name`
Expand Down Expand Up @@ -3344,6 +3345,14 @@ Tags of the resource.
- Required: No
- Type: object

### Parameter: `vpaAddon`

Whether to enable VPA add-on in cluster. Default value is false.

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

### Parameter: `webApplicationRoutingEnabled`

Specifies whether the webApplicationRoutingEnabled add-on is enabled or not.
Expand Down
6 changes: 6 additions & 0 deletions avm/res/container-service/managed-cluster/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ param identityProfile object?
@description('Optional. Enables Kubernetes Event-driven Autoscaling (KEDA).')
param kedaAddon bool = false

@description('Optional. Whether to enable VPA add-on in cluster. Default value is false.')
param vpaAddon bool = false

@description('Optional. The customer managed key definition.')
param customerManagedKey customerManagedKeyType

Expand Down Expand Up @@ -626,6 +629,9 @@ resource managedCluster 'Microsoft.ContainerService/managedClusters@2024-03-02-p
keda: {
enabled: kedaAddon
}
verticalPodAutoscaler: {
enabled: vpaAddon
}
}
networkProfile: {
networkDataplane: networkDataplane
Expand Down
10 changes: 10 additions & 0 deletions avm/res/container-service/managed-cluster/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,13 @@
"description": "Optional. Enables Kubernetes Event-driven Autoscaling (KEDA)."
}
},
"vpaAddon": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Optional. Whether to enable VPA add-on in cluster. Default value is false."
}
},
"customerManagedKey": {
"$ref": "#/definitions/customerManagedKeyType",
"metadata": {
Expand Down Expand Up @@ -1618,6 +1625,9 @@
"workloadAutoScalerProfile": {
"keda": {
"enabled": "[parameters('kedaAddon')]"
},
"verticalPodAutoscaler": {
"enabled": "[parameters('vpaAddon')]"
}
},
"networkProfile": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,47 @@ function Get-AvailableResourceLocation {

# Configure Resource Type
$fullModuleIdentifier = ($ModuleRoot -split '[\/|\\]{0,1}avm[\/|\\]{1}(res|ptn)[\/|\\]{1}')[2] -replace '\\', '/'
Write-Verbose "Full module identifier: $fullModuleIdentifier"
$formattedResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $fullModuleIdentifier -Verbose
Write-Verbose "Formatted resource type: $formattedResourceType"

# Get the resource provider and resource name
$formattedResourceProvider = ($formattedResourceType -split '[\/|\\]{1}')[0]
Write-Verbose "Resource type: $formattedResourceProvider"
$formattedServiceName = ($formattedResourceType -split '[\/|\\]{1}')[1]
Write-Verbose "Resource: $formattedServiceName"

$resourceRegionList = @()
$ResourceRegionList = (Get-AzResourceProvider | Where-Object { $_.ProviderNamespace -eq $formattedResourceProvider }).ResourceTypes | Where-Object { $_.ResourceTypeName -eq $formattedServiceName } | Select-Object -ExpandProperty Locations
Write-Verbose "Region list: $($resourceRegionList | ConvertTo-Json)"

if ($resourceRegionList -eq 'global' -or $null -eq $resourceRegionList) {
Write-Verbose "Resource is global or does not have a location in the Resource Providers API, default region [$GlobalResourceGroupLocation] will be used for resource group creation"
$location = $GlobalResourceGroupLocation # Set Location to resource group location. Globabl resources should have hardocded location in `main.bicep`
} else {

$locations = Get-AzLocation | Where-Object {
$_.DisplayName -in $ResourceRegionList -and
$_.Location -notin $ExcludedRegions -and
$_.PairedRegion -ne '{}' -and
$_.RegionCategory -eq 'Recommended'
} | Select-Object -ExpandProperty Location
Write-Verbose "Available Locations: $($locations | ConvertTo-Json)"

$filteredAllowedLocations = @($locations | Where-Object { $_ -in $AllowedRegionsList })
Write-Verbose "Filtered allowed locations: $($filteredAllowedLocations | ConvertTo-Json)"
$index = Get-Random -Maximum ($filteredAllowedLocations.Count)
if ($ModuleRoot -like 'avm/res*') {

Write-Verbose "Full module identifier: $fullModuleIdentifier"
$formattedResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $fullModuleIdentifier -Verbose
Write-Verbose "Formatted resource type: $formattedResourceType"

# Get the resource provider and resource name
$formattedResourceProvider = ($formattedResourceType -split '[\/|\\]{1}')[0]
Write-Verbose "Resource type: $formattedResourceProvider"
$formattedServiceName = ($formattedResourceType -split '[\/|\\]{1}')[1]
Write-Verbose "Resource: $formattedServiceName"

$resourceRegionList = @()
$ResourceRegionList = (Get-AzResourceProvider | Where-Object { $_.ProviderNamespace -eq $formattedResourceProvider }).ResourceTypes | Where-Object { $_.ResourceTypeName -eq $formattedServiceName } | Select-Object -ExpandProperty Locations
Write-Verbose "Region list: $($resourceRegionList | ConvertTo-Json)"

if ($resourceRegionList -eq 'global' -or $null -eq $resourceRegionList) {
Write-Verbose "Resource is global or does not have a location in the Resource Providers API, default region [$GlobalResourceGroupLocation] will be used for resource group creation"
$location = $GlobalResourceGroupLocation # Set Location to resource group location. Globabl resources should have hardocded location in `main.bicep`
} else {

$locations = Get-AzLocation | Where-Object {
$_.DisplayName -in $ResourceRegionList -and
$_.Location -notin $ExcludedRegions -and
$_.PairedRegion -ne '{}' -and
$_.RegionCategory -eq 'Recommended'
} | Select-Object -ExpandProperty Location
Write-Verbose "Available Locations: $($locations | ConvertTo-Json)"

$filteredAllowedLocations = @($locations | Where-Object { $_ -in $AllowedRegionsList })
Write-Verbose "Filtered allowed locations: $($filteredAllowedLocations | ConvertTo-Json)"
$index = Get-Random -Maximum ($filteredAllowedLocations.Count)
Write-Verbose "Generated random index [$index]"
$location = $filteredAllowedLocations[$index]
}
} else {
Write-Verbose 'Module is not resource so defaulting to the allowed region list'
$index = Get-Random -Maximum ($AllowedRegionsList.Count)
Write-Verbose "Generated random index [$index]"
$location = $filteredAllowedLocations[$index]
$location = $AllowedRegionsList[$index]
}

Write-Verbose "Selected location [$location]" -Verbose
Expand Down

0 comments on commit 98a89d1

Please sign in to comment.