-
Notifications
You must be signed in to change notification settings - Fork 457
/
deploy.bicep
647 lines (537 loc) · 29 KB
/
deploy.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
@description('Required. Specifies the name of the AKS cluster.')
param name string
@description('Optional. Specifies the location of AKS cluster. It picks up Resource Group\'s location by default.')
param location string = resourceGroup().location
@description('Optional. Specifies the DNS prefix specified when creating the managed cluster.')
param aksClusterDnsPrefix string = name
@description('Optional. Enables system assigned managed identity on the resource.')
param systemAssignedIdentity bool = false
@description('Optional. The ID(s) to assign to the resource.')
param userAssignedIdentities object = {}
@description('Optional. Specifies the network plugin used for building Kubernetes network. - azure or kubenet.')
@allowed([
''
'azure'
'kubenet'
])
param aksClusterNetworkPlugin string = ''
@description('Optional. Specifies the network policy used for building Kubernetes network. - calico or azure.')
@allowed([
''
'azure'
'calico'
])
param aksClusterNetworkPolicy string = ''
@description('Optional. Specifies the CIDR notation IP range from which to assign pod IPs when kubenet is used.')
param aksClusterPodCidr string = ''
@description('Optional. A CIDR notation IP range from which to assign service cluster IPs. It must not overlap with any Subnet IP ranges.')
param aksClusterServiceCidr string = ''
@description('Optional. Specifies the IP address assigned to the Kubernetes DNS service. It must be within the Kubernetes service address range specified in serviceCidr.')
param aksClusterDnsServiceIP string = ''
@description('Optional. Specifies the CIDR notation IP range assigned to the Docker bridge network. It must not overlap with any Subnet IP ranges or the Kubernetes service address range.')
param aksClusterDockerBridgeCidr string = ''
@description('Optional. Specifies the sku of the load balancer used by the virtual machine scale sets used by nodepools.')
@allowed([
'basic'
'standard'
])
param aksClusterLoadBalancerSku string = 'standard'
@description('Optional. Outbound IP Count for the Load balancer.')
param managedOutboundIPCount int = 0
@description('Optional. Specifies outbound (egress) routing method. - loadBalancer or userDefinedRouting.')
@allowed([
'loadBalancer'
'userDefinedRouting'
])
param aksClusterOutboundType string = 'loadBalancer'
@description('Optional. Tier of a managed cluster SKU. - Free or Paid.')
@allowed([
'Free'
'Paid'
])
param aksClusterSkuTier string = 'Free'
@description('Optional. Version of Kubernetes specified when creating the managed cluster.')
param aksClusterKubernetesVersion string = ''
@description('Optional. Specifies the administrator username of Linux virtual machines.')
param aksClusterAdminUsername string = 'azureuser'
@description('Optional. Specifies the SSH RSA public key string for the Linux nodes.')
param aksClusterSshPublicKey string = ''
@description('Optional. Information about a service principal identity for the cluster to use for manipulating Azure APIs.')
param aksServicePrincipalProfile object = {}
@description('Optional. The client AAD application ID.')
param aadProfileClientAppID string = ''
@description('Optional. The server AAD application ID.')
param aadProfileServerAppID string = ''
@description('Optional. The server AAD application secret.')
#disable-next-line secure-secrets-in-params // Not a secret
param aadProfileServerAppSecret string = ''
@description('Optional. Specifies the tenant ID of the Azure Active Directory used by the AKS cluster for authentication.')
param aadProfileTenantId string = subscription().tenantId
@description('Optional. Specifies the AAD group object IDs that will have admin role of the cluster.')
param aadProfileAdminGroupObjectIDs array = []
@description('Optional. Specifies whether to enable managed AAD integration.')
param aadProfileManaged bool = true
@description('Optional. Whether to enable Kubernetes Role-Based Access Control.')
param enableRBAC bool = true
@description('Optional. Specifies whether to enable Azure RBAC for Kubernetes authorization.')
param aadProfileEnableAzureRBAC bool = enableRBAC
@description('Optional. 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.')
param disableLocalAccounts bool = false
@description('Optional. Name of the resource group containing agent pool nodes.')
param nodeResourceGroup string = '${resourceGroup().name}_aks_${name}_nodes'
@description('Optional. IP ranges are specified in CIDR format, e.g. 137.117.106.88/29. This feature is not compatible with clusters that use Public IP Per Node, or clusters that are using a Basic Load Balancer.')
param authorizedIPRanges array = []
@description('Optional. Whether to disable run command for the cluster or not.')
param disableRunCommand bool = false
@description('Optional. Specifies whether to create the cluster as a private cluster or not.')
param enablePrivateCluster bool = false
@description('Optional. Whether to create additional public FQDN for private cluster or not.')
param enablePrivateClusterPublicFQDN bool = false
@description('Optional. If AKS will create a Private DNS Zone in the Node Resource Group.')
param usePrivateDNSZone bool = false
@description('Required. Properties of the primary agent pool.')
param primaryAgentPoolProfile array
@description('Optional. Define one or more secondary/additional agent pools.')
param agentPools array = []
@description('Optional. Specifies whether the httpApplicationRouting add-on is enabled or not.')
param httpApplicationRoutingEnabled bool = false
@description('Optional. Specifies whether the ingressApplicationGateway (AGIC) add-on is enabled or not.')
param ingressApplicationGatewayEnabled bool = false
@description('Conditional. Specifies the resource ID of connected application gateway. Required if `ingressApplicationGatewayEnabled` is set to `true`.')
param appGatewayResourceId string = ''
@description('Optional. Specifies whether the aciConnectorLinux add-on is enabled or not.')
param aciConnectorLinuxEnabled bool = false
@description('Optional. Specifies whether the azurepolicy add-on is enabled or not. For security reasons, this setting should be enabled.')
param azurePolicyEnabled bool = true
@description('Optional. Specifies whether the openServiceMesh add-on is enabled or not.')
param openServiceMeshEnabled bool = false
@description('Optional. Specifies the azure policy version to use.')
param azurePolicyVersion string = 'v2'
@description('Optional. Specifies whether the kubeDashboard add-on is enabled or not.')
param kubeDashboardEnabled bool = false
@description('Optional. Specifies whether the KeyvaultSecretsProvider add-on is enabled or not.')
#disable-next-line secure-secrets-in-params // Not a secret
param enableKeyvaultSecretsProvider bool = false
@allowed([
'false'
'true'
])
@description('Optional. Specifies whether the KeyvaultSecretsProvider add-on uses secret rotation.')
#disable-next-line secure-secrets-in-params // Not a secret
param enableSecretRotation string = 'false'
@description('Optional. Specifies the scan interval of the auto-scaler of the AKS cluster.')
param autoScalerProfileScanInterval string = '10s'
@description('Optional. Specifies the scale down delay after add of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownDelayAfterAdd string = '10m'
@description('Optional. Specifies the scale down delay after delete of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownDelayAfterDelete string = '20s'
@description('Optional. Specifies scale down delay after failure of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownDelayAfterFailure string = '3m'
@description('Optional. Specifies the scale down unneeded time of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownUnneededTime string = '10m'
@description('Optional. Specifies the scale down unready time of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownUnreadyTime string = '20m'
@description('Optional. Specifies the utilization threshold of the auto-scaler of the AKS cluster.')
param autoScalerProfileUtilizationThreshold string = '0.5'
@description('Optional. Specifies the max graceful termination time interval in seconds for the auto-scaler of the AKS cluster.')
param autoScalerProfileMaxGracefulTerminationSec string = '600'
@allowed([
'false'
'true'
])
@description('Optional. Specifies the balance of similar node groups for the auto-scaler of the AKS cluster.')
param autoScalerProfileBalanceSimilarNodeGroups string = 'false'
@allowed([
'least-waste'
'most-pods'
'priority'
'random'
])
@description('Optional. Specifies the expand strategy for the auto-scaler of the AKS cluster.')
param autoScalerProfileExpander string = 'random'
@description('Optional. Specifies the maximum empty bulk delete for the auto-scaler of the AKS cluster.')
param autoScalerProfileMaxEmptyBulkDelete string = '10'
@description('Optional. Specifies the maximum node provisioning time for the auto-scaler of the AKS cluster. Values must be an integer followed by an "m". No unit of time other than minutes (m) is supported.')
param autoScalerProfileMaxNodeProvisionTime string = '15m'
@description('Optional. Specifies the mximum total unready percentage for the auto-scaler of the AKS cluster. The maximum is 100 and the minimum is 0.')
param autoScalerProfileMaxTotalUnreadyPercentage string = '45'
@description('Optional. For scenarios like burst/batch scale where you do not want CA to act before the kubernetes scheduler could schedule all the pods, you can tell CA to ignore unscheduled pods before they are a certain age. Values must be an integer followed by a unit ("s" for seconds, "m" for minutes, "h" for hours, etc).')
param autoScalerProfileNewPodScaleUpDelay string = '0s'
@description('Optional. Specifies the OK total unready count for the auto-scaler of the AKS cluster.')
param autoScalerProfileOkTotalUnreadyCount string = '3'
@allowed([
'false'
'true'
])
@description('Optional. Specifies if nodes with local storage should be skipped for the auto-scaler of the AKS cluster.')
param autoScalerProfileSkipNodesWithLocalStorage string = 'true'
@allowed([
'false'
'true'
])
@description('Optional. Specifies if nodes with system pods should be skipped for the auto-scaler of the AKS cluster.')
param autoScalerProfileSkipNodesWithSystemPods string = 'true'
@description('Optional. Running in Kubenet is disabled by default due to the security related nature of AAD Pod Identity and the risks of IP spoofing.')
param podIdentityProfileAllowNetworkPluginKubenet bool = false
@description('Optional. Whether the pod identity addon is enabled.')
param podIdentityProfileEnable bool = false
@description('Optional. The pod identities to use in the cluster.')
param podIdentityProfileUserAssignedIdentities array = []
@description('Optional. The pod identity exceptions to allow.')
param podIdentityProfileUserAssignedIdentityExceptions array = []
@description('Optional. Whether the The OIDC issuer profile of the Managed Cluster is enabled.')
param enableOidcIssuerProfile bool = false
@description('Optional. Whether to enable Azure Defender.')
param enableAzureDefender bool = false
@description('Optional. Whether to enable Kubernetes pod security policy.')
param enablePodSecurityPolicy bool = false
@description('Optional. Resource ID of the diagnostic storage account.')
param diagnosticStorageAccountId string = ''
@description('Optional. Resource ID of the diagnostic log analytics workspace.')
param diagnosticWorkspaceId string = ''
@description('Optional. Specifies whether the OMS agent is enabled.')
param omsAgentEnabled bool = true
@description('Optional. Resource ID of the monitoring log analytics workspace.')
param monitoringWorkspaceId string = ''
@description('Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to.')
param diagnosticEventHubAuthorizationRuleId string = ''
@description('Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category.')
param diagnosticEventHubName string = ''
@description('Optional. Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely.')
@minValue(0)
@maxValue(365)
param diagnosticLogsRetentionInDays int = 365
@description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).')
param enableDefaultTelemetry bool = true
@description('Optional. Array of role assignment objects that contain the \'roleDefinitionIdOrName\' and \'principalId\' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
param roleAssignments array = []
@allowed([
''
'CanNotDelete'
'ReadOnly'
])
@description('Optional. Specify the type of lock.')
param lock string = ''
@description('Optional. Tags of the resource.')
param tags object = {}
@description('Optional. The resource ID of the disc encryption set to apply to the cluster. For security reasons, this value should be provided.')
param diskEncryptionSetID string = ''
@description('Optional. Configuration settings that are sensitive, as name-value pairs for configuring this extension.')
@secure()
param fluxConfigurationProtectedSettings object = {}
@description('Optional. Settings and configurations for the flux extension.')
param fluxExtension object = {}
@description('Optional. The name of logs that will be streamed. "allLogs" includes all possible logs for the resource.')
@allowed([
'allLogs'
'kube-apiserver'
'kube-audit'
'kube-controller-manager'
'kube-scheduler'
'cluster-autoscaler'
'kube-audit-admin'
'guard'
])
param diagnosticLogCategoriesToEnable array = [
'allLogs'
]
@description('Optional. The name of metrics that will be streamed.')
@allowed([
'AllMetrics'
])
param diagnosticMetricsToEnable array = [
'AllMetrics'
]
@description('Optional. The name of the diagnostic setting, if deployed. If left empty, it defaults to "<resourceName>-diagnosticSettings".')
param diagnosticSettingsName string = ''
var diagnosticsLogsSpecified = [for category in filter(diagnosticLogCategoriesToEnable, item => item != 'allLogs'): {
category: category
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]
var diagnosticsLogs = contains(diagnosticLogCategoriesToEnable, 'allLogs') ? [
{
categoryGroup: 'allLogs'
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}
] : diagnosticsLogsSpecified
var diagnosticsMetrics = [for metric in diagnosticMetricsToEnable: {
category: metric
timeGrain: null
enabled: true
retentionPolicy: {
enabled: true
days: diagnosticLogsRetentionInDays
}
}]
var identityType = systemAssignedIdentity ? 'SystemAssigned' : (!empty(userAssignedIdentities) ? 'UserAssigned' : 'None')
var identity = {
type: identityType
userAssignedIdentities: !empty(userAssignedIdentities) ? userAssignedIdentities : null
}
var aksClusterLinuxProfile = {
adminUsername: aksClusterAdminUsername
ssh: {
publicKeys: [
{
keyData: aksClusterSshPublicKey
}
]
}
}
var lbProfile = {
managedOutboundIPs: {
count: managedOutboundIPCount
}
effectiveOutboundIPs: []
}
var enableReferencedModulesTelemetry = false
resource defaultTelemetry 'Microsoft.Resources/deployments@2022-09-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}'
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
}
}
}
resource managedCluster 'Microsoft.ContainerService/managedClusters@2022-11-01' = {
name: name
location: location
tags: tags
identity: identity
sku: {
name: 'Basic'
tier: aksClusterSkuTier
}
properties: {
diskEncryptionSetID: !empty(diskEncryptionSetID) ? diskEncryptionSetID : null
kubernetesVersion: (empty(aksClusterKubernetesVersion) ? null : aksClusterKubernetesVersion)
dnsPrefix: aksClusterDnsPrefix
agentPoolProfiles: primaryAgentPoolProfile
linuxProfile: (empty(aksClusterSshPublicKey) ? null : aksClusterLinuxProfile)
servicePrincipalProfile: (empty(aksServicePrincipalProfile) ? null : aksServicePrincipalProfile)
addonProfiles: {
httpApplicationRouting: {
enabled: httpApplicationRoutingEnabled
}
ingressApplicationGateway: {
enabled: ingressApplicationGatewayEnabled && !empty(appGatewayResourceId)
config: ingressApplicationGatewayEnabled && !empty(appGatewayResourceId) ? {
applicationGatewayId: !empty(appGatewayResourceId) ? any(appGatewayResourceId) : null
effectiveApplicationGatewayId: !empty(appGatewayResourceId) ? any(appGatewayResourceId) : null
} : null
}
omsagent: {
enabled: omsAgentEnabled && !empty(monitoringWorkspaceId)
config: omsAgentEnabled && !empty(monitoringWorkspaceId) ? {
logAnalyticsWorkspaceResourceID: !empty(monitoringWorkspaceId) ? any(monitoringWorkspaceId) : null
} : null
}
aciConnectorLinux: {
enabled: aciConnectorLinuxEnabled
}
azurepolicy: {
enabled: azurePolicyEnabled
config: azurePolicyEnabled ? {
version: azurePolicyVersion
} : null
}
openServiceMesh: {
enabled: openServiceMeshEnabled
config: openServiceMeshEnabled ? {} : null
}
kubeDashboard: {
enabled: kubeDashboardEnabled
}
azureKeyvaultSecretsProvider: {
enabled: enableKeyvaultSecretsProvider
config: enableKeyvaultSecretsProvider ? {
enableSecretRotation: enableSecretRotation
} : null
}
}
oidcIssuerProfile: enableOidcIssuerProfile ? {
enabled: enableOidcIssuerProfile
} : null
enableRBAC: enableRBAC
disableLocalAccounts: disableLocalAccounts
nodeResourceGroup: nodeResourceGroup
enablePodSecurityPolicy: enablePodSecurityPolicy
networkProfile: {
networkPlugin: !empty(aksClusterNetworkPlugin) ? any(aksClusterNetworkPlugin) : null
networkPolicy: !empty(aksClusterNetworkPolicy) ? any(aksClusterNetworkPolicy) : null
podCidr: !empty(aksClusterPodCidr) ? aksClusterPodCidr : null
serviceCidr: !empty(aksClusterServiceCidr) ? aksClusterServiceCidr : null
dnsServiceIP: !empty(aksClusterDnsServiceIP) ? aksClusterDnsServiceIP : null
dockerBridgeCidr: !empty(aksClusterDockerBridgeCidr) ? aksClusterDockerBridgeCidr : null
outboundType: aksClusterOutboundType
loadBalancerSku: aksClusterLoadBalancerSku
loadBalancerProfile: managedOutboundIPCount != 0 ? lbProfile : null
}
aadProfile: {
clientAppID: aadProfileClientAppID
serverAppID: aadProfileServerAppID
serverAppSecret: aadProfileServerAppSecret
managed: aadProfileManaged
enableAzureRBAC: aadProfileEnableAzureRBAC
adminGroupObjectIDs: aadProfileAdminGroupObjectIDs
tenantID: aadProfileTenantId
}
autoScalerProfile: {
'balance-similar-node-groups': autoScalerProfileBalanceSimilarNodeGroups
expander: autoScalerProfileExpander
'max-empty-bulk-delete': autoScalerProfileMaxEmptyBulkDelete
'max-graceful-termination-sec': autoScalerProfileMaxGracefulTerminationSec
'max-node-provision-time': autoScalerProfileMaxNodeProvisionTime
'max-total-unready-percentage': autoScalerProfileMaxTotalUnreadyPercentage
'new-pod-scale-up-delay': autoScalerProfileNewPodScaleUpDelay
'ok-total-unready-count': autoScalerProfileOkTotalUnreadyCount
'scale-down-delay-after-add': autoScalerProfileScaleDownDelayAfterAdd
'scale-down-delay-after-delete': autoScalerProfileScaleDownDelayAfterDelete
'scale-down-delay-after-failure': autoScalerProfileScaleDownDelayAfterFailure
'scale-down-unneeded-time': autoScalerProfileScaleDownUnneededTime
'scale-down-unready-time': autoScalerProfileScaleDownUnreadyTime
'scale-down-utilization-threshold': autoScalerProfileUtilizationThreshold
'scan-interval': autoScalerProfileScanInterval
'skip-nodes-with-local-storage': autoScalerProfileSkipNodesWithLocalStorage
'skip-nodes-with-system-pods': autoScalerProfileSkipNodesWithSystemPods
}
apiServerAccessProfile: {
authorizedIPRanges: authorizedIPRanges
disableRunCommand: disableRunCommand
enablePrivateCluster: enablePrivateCluster
enablePrivateClusterPublicFQDN: enablePrivateClusterPublicFQDN
privateDNSZone: usePrivateDNSZone ? 'system' : ''
}
podIdentityProfile: {
allowNetworkPluginKubenet: podIdentityProfileAllowNetworkPluginKubenet
enabled: podIdentityProfileEnable
userAssignedIdentities: podIdentityProfileUserAssignedIdentities
userAssignedIdentityExceptions: podIdentityProfileUserAssignedIdentityExceptions
}
securityProfile: enableAzureDefender ? {
azureDefender: {
enabled: enableAzureDefender
logAnalyticsWorkspaceResourceId: !empty(monitoringWorkspaceId) ? monitoringWorkspaceId : null
}
} : null
}
}
module managedCluster_agentPools 'agentPools/deploy.bicep' = [for (agentPool, index) in agentPools: {
name: '${uniqueString(deployment().name, location)}-ManagedCluster-AgentPool-${index}'
params: {
managedClusterName: managedCluster.name
name: agentPool.name
availabilityZones: contains(agentPool, 'availabilityZones') ? agentPool.availabilityZones : []
count: contains(agentPool, 'count') ? agentPool.count : 1
sourceResourceId: contains(agentPool, 'sourceResourceId') ? agentPool.sourceResourceId : ''
enableAutoScaling: contains(agentPool, 'enableAutoScaling') ? agentPool.enableAutoScaling : false
enableEncryptionAtHost: contains(agentPool, 'enableEncryptionAtHost') ? agentPool.enableEncryptionAtHost : false
enableFIPS: contains(agentPool, 'enableFIPS') ? agentPool.enableFIPS : false
enableNodePublicIP: contains(agentPool, 'enableNodePublicIP') ? agentPool.enableNodePublicIP : false
enableUltraSSD: contains(agentPool, 'enableUltraSSD') ? agentPool.enableUltraSSD : false
gpuInstanceProfile: contains(agentPool, 'gpuInstanceProfile') ? agentPool.gpuInstanceProfile : ''
kubeletDiskType: contains(agentPool, 'kubeletDiskType') ? agentPool.kubeletDiskType : ''
maxCount: contains(agentPool, 'maxCount') ? agentPool.maxCount : -1
maxPods: contains(agentPool, 'maxPods') ? agentPool.maxPods : -1
minCount: contains(agentPool, 'minCount') ? agentPool.minCount : -1
mode: contains(agentPool, 'mode') ? agentPool.mode : ''
nodeLabels: contains(agentPool, 'nodeLabels') ? agentPool.nodeLabels : {}
nodePublicIpPrefixId: contains(agentPool, 'nodePublicIpPrefixId') ? agentPool.nodePublicIpPrefixId : ''
nodeTaints: contains(agentPool, 'nodeTaints') ? agentPool.nodeTaints : []
orchestratorVersion: contains(agentPool, 'orchestratorVersion') ? agentPool.orchestratorVersion : aksClusterKubernetesVersion
osDiskSizeGB: contains(agentPool, 'osDiskSizeGB') ? agentPool.osDiskSizeGB : -1
osDiskType: contains(agentPool, 'osDiskType') ? agentPool.osDiskType : ''
osSku: contains(agentPool, 'osSku') ? agentPool.osSku : ''
osType: contains(agentPool, 'osType') ? agentPool.osType : 'Linux'
podSubnetId: contains(agentPool, 'podSubnetId') ? agentPool.podSubnetId : ''
proximityPlacementGroupId: contains(agentPool, 'proximityPlacementGroupId') ? agentPool.proximityPlacementGroupId : ''
scaleDownMode: contains(agentPool, 'scaleDownMode') ? agentPool.scaleDownMode : 'Delete'
scaleSetEvictionPolicy: contains(agentPool, 'scaleSetEvictionPolicy') ? agentPool.scaleSetEvictionPolicy : 'Delete'
scaleSetPriority: contains(agentPool, 'scaleSetPriority') ? agentPool.scaleSetPriority : ''
spotMaxPrice: contains(agentPool, 'spotMaxPrice') ? agentPool.spotMaxPrice : -1
tags: contains(agentPool, 'tags') ? agentPool.tags : {}
type: contains(agentPool, 'type') ? agentPool.type : ''
maxSurge: contains(agentPool, 'maxSurge') ? agentPool.maxSurge : ''
vmSize: contains(agentPool, 'vmSize') ? agentPool.vmSize : 'Standard_D2s_v3'
vnetSubnetId: contains(agentPool, 'vnetSubnetId') ? agentPool.vnetSubnetId : ''
workloadRuntime: contains(agentPool, 'workloadRuntime') ? agentPool.workloadRuntime : ''
enableDefaultTelemetry: enableReferencedModulesTelemetry
}
}]
module managedCluster_extension '../../Microsoft.KubernetesConfiguration/extensions/deploy.bicep' = if (!empty(fluxExtension)) {
name: '${uniqueString(deployment().name, location)}-ManagedCluster-FluxExtension'
params: {
clusterName: managedCluster.name
configurationProtectedSettings: !empty(fluxConfigurationProtectedSettings) ? fluxConfigurationProtectedSettings : {}
configurationSettings: contains(fluxExtension, 'configurationSettings') ? fluxExtension.configurationSettings : {}
enableDefaultTelemetry: enableReferencedModulesTelemetry
extensionType: 'microsoft.flux'
fluxConfigurations: fluxExtension.configurations
location: location
name: 'flux'
releaseNamespace: 'flux-system'
releaseTrain: contains(fluxExtension, 'releaseTrain') ? fluxExtension.releaseTrain : 'Stable'
version: contains(fluxExtension, 'version') ? fluxExtension.version : ''
}
}
resource managedCluster_lock 'Microsoft.Authorization/locks@2020-05-01' = if (!empty(lock)) {
name: '${managedCluster.name}-${lock}-lock'
properties: {
level: any(lock)
notes: lock == 'CanNotDelete' ? 'Cannot delete resource or child resources.' : 'Cannot modify the resource or child resources.'
}
scope: managedCluster
}
resource managedCluster_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if ((!empty(diagnosticStorageAccountId)) || (!empty(diagnosticWorkspaceId)) || (!empty(diagnosticEventHubAuthorizationRuleId)) || (!empty(diagnosticEventHubName))) {
name: !empty(diagnosticSettingsName) ? diagnosticSettingsName : '${name}-diagnosticSettings'
properties: {
storageAccountId: !empty(diagnosticStorageAccountId) ? diagnosticStorageAccountId : null
workspaceId: !empty(diagnosticWorkspaceId) ? diagnosticWorkspaceId : null
eventHubAuthorizationRuleId: !empty(diagnosticEventHubAuthorizationRuleId) ? diagnosticEventHubAuthorizationRuleId : null
eventHubName: !empty(diagnosticEventHubName) ? diagnosticEventHubName : null
metrics: diagnosticsMetrics
logs: diagnosticsLogs
}
scope: managedCluster
}
module managedCluster_roleAssignments '.bicep/nested_roleAssignments.bicep' = [for (roleAssignment, index) in roleAssignments: {
name: '${uniqueString(deployment().name, location)}-ManagedCluster-Rbac-${index}'
params: {
description: contains(roleAssignment, 'description') ? roleAssignment.description : ''
principalIds: roleAssignment.principalIds
principalType: contains(roleAssignment, 'principalType') ? roleAssignment.principalType : ''
roleDefinitionIdOrName: roleAssignment.roleDefinitionIdOrName
condition: contains(roleAssignment, 'condition') ? roleAssignment.condition : ''
delegatedManagedIdentityResourceId: contains(roleAssignment, 'delegatedManagedIdentityResourceId') ? roleAssignment.delegatedManagedIdentityResourceId : ''
resourceId: managedCluster.id
}
}]
@description('The resource ID of the managed cluster.')
output resourceId string = managedCluster.id
@description('The resource group the managed cluster was deployed into.')
output resourceGroupName string = resourceGroup().name
@description('The name of the managed cluster.')
output name string = managedCluster.name
@description('The control plane FQDN of the managed cluster.')
output controlPlaneFQDN string = enablePrivateCluster ? managedCluster.properties.privateFQDN : managedCluster.properties.fqdn
@description('The principal ID of the system assigned identity.')
output systemAssignedPrincipalId string = systemAssignedIdentity && contains(managedCluster.identity, 'principalId') ? managedCluster.identity.principalId : ''
@description('The Object ID of the AKS identity.')
output kubeletidentityObjectId string = contains(managedCluster.properties, 'identityProfile') ? contains(managedCluster.properties.identityProfile, 'kubeletidentity') ? managedCluster.properties.identityProfile.kubeletidentity.objectId : '' : ''
@description('The Object ID of the OMS agent identity.')
output omsagentIdentityObjectId string = contains(managedCluster.properties, 'addonProfiles') ? contains(managedCluster.properties.addonProfiles, 'omsagent') ? contains(managedCluster.properties.addonProfiles.omsagent, 'identity') ? managedCluster.properties.addonProfiles.omsagent.identity.objectId : '' : '' : ''
@description('The location the resource was deployed into.')
output location string = managedCluster.location
@description('The OIDC token issuer URL.')
output oidcIssuerUrl string = enableOidcIssuerProfile ? managedCluster.properties.oidcIssuerProfile.issuerURL : ''