Skip to content

Commit b8fb3cc

Browse files
authored
fix(applications): use correct scale configuration (#1311)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue(s) - #{issue number} ## Verification - [ ] **Your** code builds clean without any errors or warnings - [ ] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced scaling configurations for container apps, allowing for more flexible and efficient resource management. - Introduced new types for scaling rules, improving clarity and structure in scaling configurations. - **Improvements** - Updated parameter declarations for scaling, providing better type safety and default values for minimum and maximum replicas. - Removed unnecessary fields in scaling rules to streamline configurations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 8b8862f commit b8fb3cc

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

.azure/applications/graphql/main.bicep

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
targetScope = 'resourceGroup'
22

3+
import { Scale } from '../../modules/containerApp/main.bicep'
4+
35
@description('The tag of the image to be used')
46
@minLength(3)
57
param imageTag string
@@ -106,24 +108,25 @@ var probes = [
106108
}
107109
]
108110

109-
var scale = {
111+
@description('The scaling configuration for the container app')
112+
param scale Scale = {
110113
minReplicas: 2
111114
maxReplicas: 10
112115
rules: [
113116
{
114117
custom: {
115118
type: 'cpu'
116-
metricType: 'Utilization'
117119
metadata: {
120+
type: 'Utilization'
118121
value: '70'
119122
}
120123
}
121124
}
122125
{
123126
custom: {
124127
type: 'memory'
125-
metricType: 'Utilization'
126128
metadata: {
129+
type: 'Utilization'
127130
value: '70'
128131
}
129132
}

.azure/applications/web-api-eu/main.bicep

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
targetScope = 'resourceGroup'
22

3+
import { Scale } from '../../modules/containerApp/main.bicep'
4+
35
@description('The tag of the image to be used')
46
@minLength(3)
57
param imageTag string
@@ -77,30 +79,32 @@ var containerAppEnvVars = [
7779
}
7880
]
7981

80-
var scale = {
82+
@description('The scaling configuration for the container app')
83+
param scale Scale = {
8184
minReplicas: 2
8285
maxReplicas: 10
8386
rules: [
8487
{
8588
custom: {
8689
type: 'cpu'
87-
metricType: 'Utilization'
8890
metadata: {
91+
type: 'Utilization'
8992
value: '70'
9093
}
9194
}
9295
}
9396
{
9497
custom: {
9598
type: 'memory'
96-
metricType: 'Utilization'
9799
metadata: {
100+
type: 'Utilization'
98101
value: '70'
99102
}
100103
}
101104
}
102105
]
103106
}
107+
104108
resource environmentKeyVaultResource 'Microsoft.KeyVault/vaults@2023-07-01' existing = {
105109
name: environmentKeyVaultName
106110
}

.azure/modules/containerApp/main.bicep

+22-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,30 @@ param revisionSuffix string
3131
@description('The probes for the container app')
3232
param probes array = []
3333

34+
@export()
35+
type ScaleRule = {
36+
// add additional types as needed: https://keda.sh/docs/2.15/scalers/
37+
custom: {
38+
type: 'cpu' | 'memory'
39+
metadata: {
40+
type: 'Utilization'
41+
value: string
42+
}
43+
}
44+
}
45+
46+
@export()
47+
type Scale = {
48+
minReplicas: int
49+
maxReplicas: int
50+
rules: ScaleRule[]
51+
}
52+
3453
@description('The scaling configuration for the container app')
35-
param scale object = {
54+
param scale Scale = {
3655
minReplicas: 1
37-
maxReplicas: 1 // temp disable scaling by default for outbox scheduling
56+
maxReplicas: 1
57+
rules: []
3858
}
3959

4060
// TODO: Refactor to make userAssignedIdentityId a required parameter once all container apps use user-assigned identities

0 commit comments

Comments
 (0)