-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.bicep
1252 lines (1036 loc) · 50 KB
/
main.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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@description('Specifies the prefix for all the Azure resources.')
param prefix string = uniqueString(resourceGroup().id)
@description('Specifies the object id of an Azure Active Directory user. In general, this the object id of the system administrator who deploys the Azure resources.')
param userId string = ''
@description('Specifies whether name resources are in CamelCase, UpperCamelCase, or KebabCase.')
@allowed([
'CamelCase'
'UpperCamelCase'
'KebabCase'
])
param letterCaseType string = 'UpperCamelCase'
@description('Specifies the location of the AKS cluster.')
param location string = resourceGroup().location
@description('Specifies the name of the AKS cluster.')
param aksClusterName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}Aks'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}Aks' : '${toLower(prefix)}-aks'
@description('Specifies whether creating metric alerts or not.')
param createMetricAlerts bool = true
@description('Specifies whether metric alerts as either enabled or disabled.')
param metricAlertsEnabled bool = true
@description('Specifies metric alerts eval frequency.')
param metricAlertsEvalFrequency string = 'PT1M'
@description('Specifies metric alerts window size.')
param metricAlertsWindowsSize string = 'PT1H'
@description('Specifies the DNS prefix specified when creating the managed cluster.')
param aksClusterDnsPrefix string = aksClusterName
@description('Specifies the network plugin used for building Kubernetes network. - azure or kubenet.')
@allowed([
'azure'
'kubenet'
])
param aksClusterNetworkPlugin string = 'azure'
@description('Specifies the Network plugin mode used for building the Kubernetes network.')
@allowed([
''
'overlay'
])
param aksClusterNetworkPluginMode string = ''
@description('Specifies the network policy used for building Kubernetes network. - calico or azure')
@allowed([
'azure'
'calico'
'cilium'
'none'
])
param aksClusterNetworkPolicy string = 'azure'
@description('Specifies the network dataplane used in the Kubernetes cluster..')
@allowed([
'azure'
'cilium'
])
param aksClusterNetworkDataplane string = 'azure'
@description('Specifies the network mode. This cannot be specified if networkPlugin is anything other than azure.')
@allowed([
'bridge'
'transparent'
])
param aksClusterNetworkMode string = 'transparent'
@description('Specifies the CIDR notation IP range from which to assign pod IPs when kubenet is used.')
param aksClusterPodCidr string = '192.168.0.0/16'
@description('A CIDR notation IP range from which to assign service cluster IPs. It must not overlap with any Subnet IP ranges.')
param aksClusterServiceCidr string = '172.16.0.0/16'
@description('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 = '172.16.0.10'
@description('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('Specifies the type of the managed inbound Load Balancer BackendPool.')
@allowed([
'nodeIP'
'nodeIPConfiguration'
])
param loadBalancerBackendPoolType string = 'nodeIPConfiguration'
@description('Specifies Advanced Networking profile for enabling observability on a cluster. Note that enabling advanced networking features may incur additional costs. For more information see aka.ms/aksadvancednetworking.')
param advancedNetworking object = {
observability: {
enabled: true
tlsManagement: 'Managed'
}
security: aksClusterNetworkDataplane == 'cilium'
? {
fqdnPolicy: {
enabled: true
}
}
: null
}
@description('Specifies the IP families are used to determine single-stack or dual-stack clusters. For single-stack, the expected value is IPv4. For dual-stack, the expected values are IPv4 and IPv6.')
param aksClusterIpFamilies array = ['IPv4']
@description('Specifies outbound (egress) routing method. - loadBalancer or userDefinedRouting.')
@allowed([
'loadBalancer'
'managedNATGateway'
'userAssignedNATGateway'
'userDefinedRouting'
])
param aksClusterOutboundType string = 'loadBalancer'
@description('Specifies the tier of a managed cluster SKU: Paid or Free')
@allowed([
'Free'
'Standard'
'Premium'
])
param aksClusterSkuTier string = 'Standard'
@description('Specifies the version of Kubernetes specified when creating the managed cluster.')
param aksClusterKubernetesVersion string = '1.18.8'
@description('Specifies the administrator username of Linux virtual machines.')
param aksClusterAdminUsername string = 'azureuser'
@description('Specifies the SSH RSA public key string for the Linux nodes.')
param aksClusterSshPublicKey string
@description('Specifies the tenant id of the Azure Active Directory used by the AKS cluster for authentication.')
param aadProfileTenantId string = subscription().tenantId
@description('Specifies the AAD group object IDs that will have admin role of the cluster.')
param aadProfileAdminGroupObjectIDs array = []
@description('Specifies the node OS upgrade channel. The default is Unmanaged, but may change to either NodeImage or SecurityPatch at GA. .')
@allowed([
'NodeImage'
'None'
'SecurityPatch'
'Unmanaged'
])
param aksClusterNodeOSUpgradeChannel string = 'Unmanaged'
@description('Specifies the upgrade channel for auto upgrade. Allowed values include rapid, stable, patch, node-image, none.')
@allowed([
'rapid'
'stable'
'patch'
'node-image'
'none'
])
param aksClusterUpgradeChannel string = 'stable'
@description('Specifies whether to create the cluster as a private cluster or not.')
param aksClusterEnablePrivateCluster bool = true
@description('Specifies whether the managed NGINX Ingress Controller application routing addon is enabled.')
param aksClusterWebAppRoutingEnabled bool = true
@description('Specifies the ingress type for the default NginxIngressController custom resource')
@allowed([
'AnnotationControlled'
'External'
'Internal'
'None'
])
param aksClusterNginxDefaultIngressControllerType string = 'Internal'
@description('Specifies the Private DNS Zone mode for private cluster. When the value is equal to None, a Public DNS Zone is used in place of a Private DNS Zone')
param aksPrivateDNSZone string = 'none'
@description('Specifies whether to create additional public FQDN for private cluster or not.')
param aksEnablePrivateClusterPublicFQDN bool = true
@description('Specifies whether to enable managed AAD integration.')
param aadProfileManaged bool = true
@description('Specifies whether to to enable Azure RBAC for Kubernetes authorization.')
param aadProfileEnableAzureRBAC bool = true
@description('Specifies the unique name of of the system node pool profile in the context of the subscription and resource group.')
param systemAgentPoolName string = 'nodepool1'
@description('Specifies the vm size of nodes in the system node pool.')
param systemAgentPoolVmSize string = 'Standard_DS5_v2'
@description('Specifies the OS Disk Size in GB to be used to specify the disk size for every machine in the system agent pool. If you specify 0, it will apply the default osDisk size according to the vmSize specified.')
param systemAgentPoolOsDiskSizeGB int = 100
@description('Specifies the OS disk type to be used for machines in a given agent pool. Allowed values are \'Ephemeral\' and \'Managed\'. If unspecified, defaults to \'Ephemeral\' when the VM supports ephemeral OS and has a cache disk larger than the requested OSDiskSizeGB. Otherwise, defaults to \'Managed\'. May not be changed after creation. - Managed or Ephemeral')
@allowed([
'Ephemeral'
'Managed'
])
param systemAgentPoolOsDiskType string = 'Ephemeral'
@description('Specifies the number of agents (VMs) to host docker containers in the system node pool. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 1.')
param systemAgentPoolAgentCount int = 3
@description('Specifies the OS type for the vms in the system node pool. Choose from Linux and Windows. Default to Linux.')
@allowed([
'Linux'
'Windows'
])
param systemAgentPoolOsType string = 'Linux'
@description('Specifies the OS SKU used by the system agent pool. If not specified, the default is Ubuntu if OSType=Linux or Windows2019 if OSType=Windows. And the default Windows OSSKU will be changed to Windows2022 after Windows2019 is deprecated.')
@allowed([
'Ubuntu'
'Windows2019'
'Windows2022'
'AzureLinux'
])
param systemAgentPoolOsSKU string = 'Ubuntu'
@description('Specifies the maximum number of pods that can run on a node in the system node pool. The maximum number of pods per node in an AKS cluster is 250. The default maximum number of pods per node varies between kubenet and Azure CNI networking, and the method of cluster deployment.')
param systemAgentPoolMaxPods int = 30
@description('Specifies the maximum number of nodes for auto-scaling for the system node pool.')
param systemAgentPoolMaxCount int = 5
@description('Specifies the minimum number of nodes for auto-scaling for the system node pool.')
param systemAgentPoolMinCount int = 3
@description('Specifies whether to enable auto-scaling for the system node pool.')
param systemAgentPoolEnableAutoScaling bool = true
@description('Specifies the virtual machine scale set priority in the system node pool: Spot or Regular.')
@allowed([
'Spot'
'Regular'
])
param systemAgentPoolScaleSetPriority string = 'Regular'
@description('Specifies the ScaleSetEvictionPolicy to be used to specify eviction policy for spot virtual machine scale set. Default to Delete. Allowed values are Delete or Deallocate.')
@allowed([
'Delete'
'Deallocate'
])
param systemAgentPoolScaleSetEvictionPolicy string = 'Delete'
@description('Specifies the Agent pool node labels to be persisted across all nodes in the system node pool.')
param systemAgentPoolNodeLabels object = {}
@description('Specifies the taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule.')
param systemAgentPoolNodeTaints array = []
@description('Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage.')
@allowed([
'OS'
'Temporary'
])
param systemAgentPoolKubeletDiskType string = 'OS'
@description('Specifies the type for the system node pool: VirtualMachineScaleSets or AvailabilitySet')
@allowed([
'VirtualMachineScaleSets'
'AvailabilitySet'
])
param systemAgentPoolType string = 'VirtualMachineScaleSets'
@description('Specifies the availability zones for the agent nodes in the system node pool. Requirese the use of VirtualMachineScaleSets as node pool type.')
param systemAgentPoolAvailabilityZones array = [
'1'
'2'
'3'
]
@description('Specifies the unique name of of the user node pool profile in the context of the subscription and resource group.')
param userAgentPoolName string = 'nodepool1'
@description('Specifies the vm size of nodes in the user node pool.')
param userAgentPoolVmSize string = 'Standard_DS5_v2'
@description('Specifies the OS Disk Size in GB to be used to specify the disk size for every machine in the system agent pool. If you specify 0, it will apply the default osDisk size according to the vmSize specified..')
param userAgentPoolOsDiskSizeGB int = 100
@description('Specifies the OS disk type to be used for machines in a given agent pool. Allowed values are \'Ephemeral\' and \'Managed\'. If unspecified, defaults to \'Ephemeral\' when the VM supports ephemeral OS and has a cache disk larger than the requested OSDiskSizeGB. Otherwise, defaults to \'Managed\'. May not be changed after creation. - Managed or Ephemeral')
@allowed([
'Ephemeral'
'Managed'
])
param userAgentPoolOsDiskType string = 'Ephemeral'
@description('Specifies the number of agents (VMs) to host docker containers in the user node pool. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 1.')
param userAgentPoolAgentCount int = 3
@description('Specifies the OS type for the vms in the user node pool. Choose from Linux and Windows. Default to Linux.')
@allowed([
'Linux'
'Windows'
])
param userAgentPoolOsType string = 'Linux'
@description('Specifies the OS SKU used by the system agent pool. If not specified, the default is Ubuntu if OSType=Linux or Windows2019 if OSType=Windows. And the default Windows OSSKU will be changed to Windows2022 after Windows2019 is deprecated.')
@allowed([
'Ubuntu'
'Windows2019'
'Windows2022'
'AzureLinux'
])
param userAgentPoolOsSKU string = 'Ubuntu'
@description('Specifies the maximum number of pods that can run on a node in the user node pool. The maximum number of pods per node in an AKS cluster is 250. The default maximum number of pods per node varies between kubenet and Azure CNI networking, and the method of cluster deployment.')
param userAgentPoolMaxPods int = 30
@description('Specifies the maximum number of nodes for auto-scaling for the user node pool.')
param userAgentPoolMaxCount int = 5
@description('Specifies the minimum number of nodes for auto-scaling for the user node pool.')
param userAgentPoolMinCount int = 3
@description('Specifies whether to enable auto-scaling for the user node pool.')
param userAgentPoolEnableAutoScaling bool = true
@description('Specifies the virtual machine scale set priority in the user node pool: Spot or Regular.')
@allowed([
'Spot'
'Regular'
])
param userAgentPoolScaleSetPriority string = 'Regular'
@description('Specifies the ScaleSetEvictionPolicy to be used to specify eviction policy for spot virtual machine scale set. Default to Delete. Allowed values are Delete or Deallocate.')
@allowed([
'Delete'
'Deallocate'
])
param userAgentPoolScaleSetEvictionPolicy string = 'Delete'
@description('Specifies the Agent pool node labels to be persisted across all nodes in the user node pool.')
param userAgentPoolNodeLabels object = {}
@description('Specifies the taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule.')
param userAgentPoolNodeTaints array = []
@description('Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage.')
@allowed([
'OS'
'Temporary'
])
param userAgentPoolKubeletDiskType string = 'OS'
@description('Specifies the type for the user node pool: VirtualMachineScaleSets or AvailabilitySet')
@allowed([
'VirtualMachineScaleSets'
'AvailabilitySet'
])
param userAgentPoolType string = 'VirtualMachineScaleSets'
@description('Specifies the availability zones for the agent nodes in the user node pool. Requirese the use of VirtualMachineScaleSets as node pool type.')
param userAgentPoolAvailabilityZones array = [
'1'
'2'
'3'
]
@description('Specifies whether the httpApplicationRouting add-on is enabled or not.')
param httpApplicationRoutingEnabled bool = false
@description('Specifies whether the Istio Service Mesh add-on is enabled or not.')
param istioServiceMeshEnabled bool = false
@description('Specifies whether the Istio Ingress Gateway is enabled or not.')
param istioIngressGatewayEnabled bool = false
@description('Specifies the type of the Istio Ingress Gateway.')
@allowed([
'Internal'
'External'
])
param istioIngressGatewayType string = 'External'
@description('Specifies whether the Kubernetes Event-Driven Autoscaler (KEDA) add-on is enabled or not.')
param kedaEnabled bool = false
@description('Specifies whether the Dapr extension is enabled or not.')
param daprEnabled bool = false
@description('Enable high availability (HA) mode for the Dapr control plane')
param daprHaEnabled bool = false
@description('Specifies whether the Flux V2 extension is enabled or not.')
param fluxGitOpsEnabled bool = false
@description('Specifies whether the Vertical Pod Autoscaler is enabled or not.')
param verticalPodAutoscalerEnabled bool = false
@description('Specifies whether the aciConnectorLinux add-on is enabled or not.')
param aciConnectorLinuxEnabled bool = false
@description('Specifies whether the azurepolicy add-on is enabled or not.')
param azurePolicyEnabled bool = true
@description('Specifies whether the Azure Key Vault Provider for Secrets Store CSI Driver addon is enabled or not.')
param azureKeyvaultSecretsProviderEnabled bool = true
@description('Specifies whether the kubeDashboard add-on is enabled or not.')
param kubeDashboardEnabled bool = false
@description('Specifies whether the pod identity addon is enabled..')
param podIdentityProfileEnabled bool = false
@description('Specifies the scan interval of the auto-scaler of the AKS cluster.')
param autoScalerProfileScanInterval string = '10s'
@description('Specifies the scale down delay after add of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownDelayAfterAdd string = '10m'
@description('Specifies the scale down delay after delete of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownDelayAfterDelete string = '20s'
@description('Specifies scale down delay after failure of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownDelayAfterFailure string = '3m'
@description('Specifies the scale down unneeded time of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownUnneededTime string = '10m'
@description('Specifies the scale down unready time of the auto-scaler of the AKS cluster.')
param autoScalerProfileScaleDownUnreadyTime string = '20m'
@description('Specifies the utilization threshold of the auto-scaler of the AKS cluster.')
param autoScalerProfileUtilizationThreshold string = '0.5'
@description('Specifies the max graceful termination time interval in seconds for the auto-scaler of the AKS cluster.')
param autoScalerProfileMaxGracefulTerminationSec string = '600'
@description('Specifies whether to enable API server VNET integration for the cluster or not.')
param enableVnetIntegration bool = true
@description('Specifies the name of the virtual network.')
param virtualNetworkName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}VNet'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}VNet' : '${toLower(prefix)}-vnet'
@description('Specifies the address prefixes of the virtual network.')
param virtualNetworkAddressPrefixes string = '10.0.0.0/8'
@description('Specifies the name of the subnet hosting the worker nodes of the default system agent pool of the AKS cluster.')
param systemAgentPoolSubnetName string = 'SystemSubnet'
@description('Specifies the address prefix of the subnet hosting the worker nodes of the default system agent pool of the AKS cluster.')
param systemAgentPoolSubnetAddressPrefix string = '10.0.0.0/16'
@description('Specifies the name of the subnet hosting the worker nodes of the user agent pool of the AKS cluster.')
param userAgentPoolSubnetName string = 'UserSubnet'
@description('Specifies the address prefix of the subnet hosting the worker nodes of the user agent pool of the AKS cluster.')
param userAgentPoolSubnetAddressPrefix string = '10.1.0.0/16'
@description('Specifies whether to enable the Azure Blob CSI Driver. The default value is false.')
param blobCSIDriverEnabled bool = false
@description('Specifies whether to enable the Azure Disk CSI Driver. The default value is true.')
param diskCSIDriverEnabled bool = true
@description('Specifies whether to enable the Azure File CSI Driver. The default value is true.')
param fileCSIDriverEnabled bool = true
@description('Specifies whether to enable the Snapshot Controller. The default value is true.')
param snapshotControllerEnabled bool = true
@description('Specifies whether to enable Defender threat detection. The default value is false.')
param defenderSecurityMonitoringEnabled bool = false
@description('Specifies whether to enable ImageCleaner on AKS cluster. The default value is false.')
param imageCleanerEnabled bool = false
@description('Specifies whether ImageCleaner scanning interval in hours.')
param imageCleanerIntervalHours int = 24
@description('Specifies whether to enable Node Restriction. The default value is false.')
param nodeRestrictionEnabled bool = false
@description('Specifies whether to enable Workload Identity. The default value is false.')
param workloadIdentityEnabled bool = true
@description('Specifies whether the OIDC issuer is enabled.')
param oidcIssuerProfileEnabled bool = true
@description('Specifies the name of the subnet hosting the pods running in the AKS cluster.')
param podSubnetName string = letterCaseType == 'UpperCamelCase'
? 'PodSubnet'
: letterCaseType == 'CamelCase' ? 'podSubnet' : 'pod-subnet'
@description('Specifies the address prefix of the subnet hosting the pods running in the AKS cluster.')
param podSubnetAddressPrefix string = '10.2.0.0/16'
@description('Specifies the name of the subnet delegated to the API server when configuring the AKS cluster to use API server VNET integration.')
param apiServerSubnetName string = letterCaseType == 'UpperCamelCase'
? 'ApiServerSubnet'
: letterCaseType == 'CamelCase' ? 'apiServerSubnet' : 'api-server-subnet'
@description('Specifies the address prefix of the subnet delegated to the API server when configuring the AKS cluster to use API server VNET integration.')
param apiServerSubnetAddressPrefix string = '10.3.0.0/28'
@description('Specifies the name of the subnet which contains the virtual machine.')
param vmSubnetName string = letterCaseType == 'UpperCamelCase'
? 'VmSubnet'
: letterCaseType == 'CamelCase' ? 'vmSubnet' : 'vm-subnet'
@description('Specifies the address prefix of the subnet which contains the virtual machine.')
param vmSubnetAddressPrefix string = '10.3.1.0/24'
@description('Specifies the Bastion subnet IP prefix. This prefix must be within vnet IP prefix address space.')
param bastionSubnetAddressPrefix string = '10.3.2.0/24'
@description('Specifies the name of the Log Analytics Workspace.')
param logAnalyticsWorkspaceName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}Workspace'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}Workspace' : '${toLower(prefix)}-workspace'
@description('Specifies the service tier of the workspace: Free, Standalone, PerNode, Per-GB.')
@allowed([
'Free'
'Standalone'
'PerNode'
'PerGB2018'
])
param logAnalyticsSku string = 'PerNode'
@description('Specifies the workspace data retention in days. -1 means Unlimited retention for the Unlimited Sku. 730 days is the maximum allowed for all other Skus.')
param logAnalyticsRetentionInDays int = 60
@description('Specifies whether creating or not a jumpbox virtual machine in the AKS cluster virtual network.')
param vmEnabled bool = true
@description('Specifies the name of the virtual machine.')
param vmName string = 'TestVm'
@description('Specifies the size of the virtual machine.')
param vmSize string = 'Standard_DS3_v2'
@description('Specifies the image publisher of the disk image used to create the virtual machine.')
param imagePublisher string = 'Canonical'
@description('Specifies the offer of the platform image or marketplace image used to create the virtual machine.')
param imageOffer string = '0001-com-ubuntu-server-jammy'
@description('Specifies the Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version.')
param imageSku string = '22_04-lts-gen2'
@description('Specifies the type of authentication when accessing the Virtual Machine. SSH key is recommended.')
@allowed([
'sshPublicKey'
'password'
])
param authenticationType string = 'password'
@description('Specifies the name of the administrator account of the virtual machine.')
param vmAdminUsername string
@description('Specifies the SSH Key or password for the virtual machine. SSH key is recommended.')
@secure()
param vmAdminPasswordOrKey string
@description('Specifies the storage account type for OS and data disk.')
@allowed([
'Premium_LRS'
'StandardSSD_LRS'
'Standard_LRS'
'UltraSSD_LRS'
])
param diskStorageAccountType string = 'Premium_LRS'
@description('Specifies the number of data disks of the virtual machine.')
@minValue(0)
@maxValue(64)
param numDataDisks int = 1
@description('Specifies the size in GB of the OS disk of the VM.')
param osDiskSize int = 50
@description('Specifies the size in GB of the OS disk of the virtual machine.')
param dataDiskSize int = 50
@description('Specifies the caching requirements for the data disks.')
param dataDiskCaching string = 'ReadWrite'
@description('Specifies the globally unique name for the storage account used to store the boot diagnostics logs of the virtual machine.')
param blobStorageAccountName string = '${toLower(prefix)}${uniqueString(resourceGroup().id)}'
@description('Specifies the name of the private link to the boot diagnostics storage account.')
param blobStorageAccountPrivateEndpointName string = letterCaseType == 'UpperCamelCase'
? 'BlobStorageAccountPrivateEndpoint'
: letterCaseType == 'CamelCase' ? 'blobStorageAccountPrivateEndpoint' : 'blob-storage-account-private-endpoint'
@description('Specifies the name of the private link to the Azure Container Registry.')
param acrPrivateEndpointName string = letterCaseType == 'UpperCamelCase'
? 'AcrPrivateEndpoint'
: letterCaseType == 'CamelCase' ? 'acrPrivateEndpoint' : 'acr-private-endpoint'
@description('Name of your Azure Container Registry')
@minLength(5)
@maxLength(50)
param acrName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}Registry'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}Registry' : '${toLower(prefix)}-registry'
@description('Enable admin user that have push / pull permission to the registry.')
param acrAdminUserEnabled bool = false
@description('Tier of your Azure Container Registry.')
@allowed([
'Basic'
'Standard'
'Premium'
])
param acrSku string = 'Premium'
@description('Whether to allow public network access. Defaults to Enabled.')
@allowed([
'Disabled'
'Enabled'
])
param acrPublicNetworkAccess string = 'Disabled'
@description('Specifies whether or not registry-wide pull is enabled from unauthenticated clients.')
param acrAnonymousPullEnabled bool = true
@description('Specifies whether or not a single data endpoint is enabled per region for serving data.')
param acrDataEndpointEnabled bool = true
@description('Specifies the network rule set for the container registry.')
param acrNetworkRuleSet object = {
defaultAction: 'Allow'
}
@description('Specifies ehether to allow trusted Azure services to access a network restricted registry.')
@allowed([
'AzureServices'
'None'
])
param acrNetworkRuleBypassOptions string = 'AzureServices'
@description('Specifies whether or not zone redundancy is enabled for this container registry.')
@allowed([
'Disabled'
'Enabled'
])
param acrZoneRedundancy string = 'Enabled'
@description('Specifies whether Azure Bastion should be created.')
param bastionHostEnabled bool = true
@description('Specifies the name of the Azure Bastion resource.')
param bastionHostName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}Bastion'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}Bastion' : '${toLower(prefix)}-bastion'
@description('Specifies the name of the Azure NAT Gateway.')
param natGatewayName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}NatGateway'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}NatGateway' : '${toLower(prefix)}-nat-gateway'
@description('Specifies a list of availability zones denoting the zone in which Nat Gateway should be deployed.')
param natGatewayZones array = []
@description('Specifies the number of Public IPs to create for the Azure NAT Gateway.')
param natGatewayPublicIps int = 1
@description('Specifies the idle timeout in minutes for the Azure NAT Gateway.')
param natGatewayIdleTimeoutMins int = 30
@description('Specifies the name of the private link to the Key Vault.')
param keyVaultPrivateEndpointName string = letterCaseType == 'UpperCamelCase'
? 'KeyVaultPrivateEndpoint'
: letterCaseType == 'CamelCase' ? 'keyVaultPrivateEndpoint' : 'key-vault-private-endpoint'
@description('Specifies the name of the Azure Key Vault resource.')
param keyVaultName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}KeyVault'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}KeyVault' : '${toLower(prefix)}-key-vault'
@description('Specifies whether to allow public network access for Key Vault.')
@allowed([
'Disabled'
'Enabled'
])
param keyVaultPublicNetworkAccess string = 'Disabled'
@description('Specifies the default action of allow or deny when no other rules match for the Azure Key Vault resource. Allowed values: Allow or Deny')
@allowed([
'Allow'
'Deny'
])
param keyVaultNetworkAclsDefaultAction string = 'Allow'
@description('Specifies whether the Azure Key Vault resource is enabled for deployments.')
param keyVaultEnabledForDeployment bool = true
@description('Specifies whether the Azure Key Vault resource is enabled for disk encryption.')
param keyVaultEnabledForDiskEncryption bool = true
@description('Specifies whether the Azure Key Vault resource is enabled for template deployment.')
param keyVaultEnabledForTemplateDeployment bool = true
@description('Specifies whether the soft delete is enabled for this Azure Key Vault resource.')
param keyVaultEnableSoftDelete bool = true
@description('Specifies whether purge protection is enabled for this Azure Key Vault resource.')
param keyVaultEnablePurgeProtection bool = true
@description('Specifies whether enable the RBAC authorization for the Azure Key Vault resource.')
param keyVaultEnableRbacAuthorization bool = true
@description('Specifies the soft delete retention in days.')
param keyVaultSoftDeleteRetentionInDays int = 7
@description('Specifies the resource tags.')
param tags object = {
IaC: 'Bicep'
}
@description('Specifies the resource tags.')
param clusterTags object = {
IaC: 'Bicep'
ApiServerVnetIntegration: true
}
@description('Specifies the name of the Action Group.')
param actionGroupName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}ActionGroup'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}ActionGroup' : '${toLower(prefix)}-action-group'
@description('Specifies the short name of the action group. This will be used in SMS messages..')
param actionGroupShortName string = 'AksAlerts'
@description('Specifies whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications.')
param actionGroupEnabled bool = true
@description('Specifies the email address of the receiver.')
param actionGroupEmailAddress string
@description('Specifies whether to use common alert schema..')
param actionGroupUseCommonAlertSchema bool = false
@description('Specifies the country code of the SMS receiver.')
param actionGroupCountryCode string = '39'
@description('Specifies the phone number of the SMS receiver.')
param actionGroupPhoneNumber string = ''
@description('Specifies a comma-separated list of additional Kubernetes label keys that will be used in the resource labels metric.')
param metricAnnotationsAllowList string = ''
@description('Specifies a comma-separated list of Kubernetes annotations keys that will be used in the resource labels metric.')
param metricLabelsAllowlist string = ''
@description('Specifies the name of the Azure Monitor managed service for Prometheus resource.')
param prometheusName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}Prometheus'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}Prometheus' : '${toLower(prefix)}-prometheus'
@description('Specifies whether or not public endpoint access is allowed for the Azure Monitor managed service for Prometheus resource.')
@allowed([
'Enabled'
'Disabled'
])
param prometheusPublicNetworkAccess string = 'Enabled'
@description('Specifies the name of the Azure Managed Grafana resource.')
param grafanaName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}Grafana'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}Grafana' : '${toLower(prefix)}-grafana'
@description('Specifies the sku of the Azure Managed Grafana resource.')
param grafanaSkuName string = 'Standard'
@description('Specifies the api key setting of the Azure Managed Grafana resource.')
@allowed([
'Disabled'
'Enabled'
])
param grafanaApiKey string = 'Enabled'
@description('Specifies the scope for dns deterministic name hash calculation.')
@allowed([
'TenantReuse'
])
param grafanaAutoGeneratedDomainNameLabelScope string = 'TenantReuse'
@description('Specifies whether the Azure Managed Grafana resource uses deterministic outbound IPs.')
@allowed([
'Disabled'
'Enabled'
])
param grafanaDeterministicOutboundIP string = 'Disabled'
@description('Specifies the the state for enable or disable traffic over the public interface for the the Azure Managed Grafana resource.')
@allowed([
'Disabled'
'Enabled'
])
param grafanaPublicNetworkAccess string = 'Enabled'
@description('The zone redundancy setting of the Azure Managed Grafana resource.')
@allowed([
'Disabled'
'Enabled'
])
param grafanaZoneRedundancy string = 'Disabled'
@description('Specifies whether to deploy Prometheus and Grafana to the AKS cluster using a Helm chart.')
param deployPrometheusAndGrafanaViaHelm bool = true
@description('Specifies whether to whether to deploy the Certificate Manager to the AKS cluster using a Helm chart.')
param deployCertificateManagerViaHelm bool = true
@description('Specifies the list of ingress classes for which a cert-manager cluster issuer should be created.')
param ingressClassNames array = ['nginx', 'webapprouting.kubernetes.azure.com']
@description('Specifies the list of the names for the cert-manager cluster issuers.')
param clusterIssuerNames array = ['letsencrypt-nginx', 'letsencrypt-webapprouting']
@description('Specifies whether and how to deploy the NGINX Ingress Controller to the AKS cluster using a Helm chart. Possible values are None, Internal, and External.')
@allowed([
'None'
'Internal'
'External'
])
param deployNginxIngressControllerViaHelm string = 'Internal'
@description('Specifies the email address for the cert-manager cluster issuer.')
param email string = '[email protected]'
@description('Specifies the name of the deployment script uri.')
param deploymentScripName string = letterCaseType == 'UpperCamelCase'
? '${toUpper(first(prefix))}${toLower(substring(prefix, 1, length(prefix) - 1))}BashScript'
: letterCaseType == 'CamelCase' ? '${toLower(prefix)}BashScript' : '${toLower(prefix)}-bash-script'
@description('Specifies the uri of the deployment script.')
param deploymentScriptUri string
@description('Specifies the Azure CLI module version.')
param azCliVersion string = '2.61.0'
@description('Specifies the maximum allowed script execution time specified in ISO 8601 format. Default value is P1D.')
param timeout string = 'PT30M'
@description('Specifies the clean up preference when the script execution gets in a terminal state. Default setting is Always.')
@allowed([
'Always'
'OnExpiration'
'OnSuccess'
])
param cleanupPreference string = 'OnSuccess'
@description('Specifies the interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires.')
param retentionInterval string = 'P1D'
@description('Specifies the name of an existing public DNS zone.')
param dnsZoneName string
@description('Specifies the name of the resource group which contains the public DNS zone.')
param dnsZoneResourceGroupName string
// Modules
module keyVault 'keyVault.bicep' = {
name: 'keyVault'
params: {
// properties
name: keyVaultName
location: location
tags: tags
publicNetworkAccess: keyVaultPublicNetworkAccess
networkAclsDefaultAction: keyVaultNetworkAclsDefaultAction
enabledForDeployment: keyVaultEnabledForDeployment
enabledForDiskEncryption: keyVaultEnabledForDiskEncryption
enabledForTemplateDeployment: keyVaultEnabledForTemplateDeployment
enablePurgeProtection: keyVaultEnablePurgeProtection
enableRbacAuthorization: keyVaultEnableRbacAuthorization
enableSoftDelete: keyVaultEnableSoftDelete
softDeleteRetentionInDays: keyVaultSoftDeleteRetentionInDays
workspaceId: workspace.outputs.id
// role assignments
userId: userId
}
}
module workspace 'logAnalytics.bicep' = {
name: 'workspace'
params: {
name: logAnalyticsWorkspaceName
location: location
sku: logAnalyticsSku
retentionInDays: logAnalyticsRetentionInDays
tags: tags
}
}
module containerRegistry 'containerRegistry.bicep' = {
name: 'containerRegistry'
params: {
name: acrName
sku: acrSku
adminUserEnabled: acrAdminUserEnabled
anonymousPullEnabled: acrAnonymousPullEnabled
dataEndpointEnabled: acrDataEndpointEnabled
networkRuleBypassOptions: acrNetworkRuleBypassOptions
networkRuleSet: acrNetworkRuleSet
publicNetworkAccess: acrPublicNetworkAccess
zoneRedundancy: acrZoneRedundancy
workspaceId: workspace.outputs.id
location: location
tags: tags
}
}
module storageAccount 'storageAccount.bicep' = {
name: 'storageAccount'
params: {
name: blobStorageAccountName
createContainers: false
containerNames: []
workspaceId: workspace.outputs.id
location: location
tags: tags
}
}
module network 'network.bicep' = {
name: 'network'
params: {
podSubnetEnabled: aksClusterNetworkPluginMode != 'overlay' && podSubnetName != '' && podSubnetAddressPrefix != ''
enableVnetIntegration: enableVnetIntegration
bastionHostEnabled: bastionHostEnabled
virtualNetworkName: virtualNetworkName
virtualNetworkAddressPrefixes: virtualNetworkAddressPrefixes
systemAgentPoolSubnetName: systemAgentPoolSubnetName
systemAgentPoolSubnetAddressPrefix: systemAgentPoolSubnetAddressPrefix
userAgentPoolSubnetName: userAgentPoolSubnetName
userAgentPoolSubnetAddressPrefix: userAgentPoolSubnetAddressPrefix
podSubnetName: podSubnetName
podSubnetAddressPrefix: podSubnetAddressPrefix
apiServerSubnetName: apiServerSubnetName
apiServerSubnetAddressPrefix: apiServerSubnetAddressPrefix
vmSubnetName: vmSubnetName
vmSubnetAddressPrefix: vmSubnetAddressPrefix
vmSubnetNsgName: letterCaseType == 'UpperCamelCase'
? '${toUpper(first(vmSubnetName))}${substring(vmSubnetName, 1, length(vmSubnetName) - 1)}Nsg'
: letterCaseType == 'CamelCase'
? '${toLower(first(vmSubnetName))}${substring(vmSubnetName, 1, length(vmSubnetName) - 1)}Nsg'
: '${toLower(vmSubnetName)}-nsg'
bastionSubnetAddressPrefix: bastionSubnetAddressPrefix
bastionSubnetNsgName: letterCaseType == 'UpperCamelCase'
? 'AzureBastionSubnetNsg'
: letterCaseType == 'CamelCase' ? 'azureBastionSubnetNsg' : 'azure-bastion-nsg'
bastionHostName: bastionHostName
natGatewayName: natGatewayName
natGatewayEnabled: aksClusterOutboundType == 'userAssignedNATGateway'
natGatewayZones: natGatewayZones
natGatewayPublicIps: natGatewayPublicIps
natGatewayIdleTimeoutMins: natGatewayIdleTimeoutMins
createAcrPrivateEndpoint: acrSku == 'Premium'
storageAccountPrivateEndpointName: blobStorageAccountPrivateEndpointName
storageAccountId: storageAccount.outputs.id
keyVaultPrivateEndpointName: keyVaultPrivateEndpointName
keyVaultId: keyVault.outputs.id
acrPrivateEndpointName: acrPrivateEndpointName
acrId: containerRegistry.outputs.id
workspaceId: workspace.outputs.id
location: location
tags: tags
}
}
module jumpboxVirtualMachine 'virtualMachine.bicep' = if (vmEnabled) {
name: 'jumpboxVirtualMachine'
params: {
vmName: vmName
vmSize: vmSize
vmSubnetId: network.outputs.vmSubnetId
storageAccountName: vmEnabled ? storageAccount.outputs.name : ''
imagePublisher: imagePublisher
imageOffer: imageOffer
imageSku: imageSku
authenticationType: authenticationType
vmAdminUsername: vmAdminUsername
vmAdminPasswordOrKey: vmAdminPasswordOrKey
diskStorageAccountType: diskStorageAccountType
numDataDisks: numDataDisks
osDiskSize: osDiskSize
dataDiskSize: dataDiskSize
dataDiskCaching: dataDiskCaching
managedIdentityName: letterCaseType == 'UpperCamelCase'