-
Notifications
You must be signed in to change notification settings - Fork 207
/
types.go
2176 lines (1972 loc) · 92.8 KB
/
types.go
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package datamodel
import (
"bytes"
"encoding/json"
"fmt"
"hash/fnv"
"math/rand"
neturl "net/url"
"sort"
"strings"
"sync"
"github.com/Azure/go-autorest/autorest/to"
"github.com/Masterminds/semver/v3"
)
// TypeMeta describes an individual API model object.
type TypeMeta struct {
// APIVersion is on every object.
APIVersion string `json:"apiVersion"`
}
/*
CustomSearchDomain represents the Search Domain when the custom vnet has a windows server DNS as a
nameserver.
*/
type CustomSearchDomain struct {
Name string `json:"name,omitempty"`
RealmUser string `json:"realmUser,omitempty"`
RealmPassword string `json:"realmPassword,omitempty"`
}
// PublicKey represents an SSH key for LinuxProfile.
type PublicKey struct {
KeyData string `json:"keyData"`
}
/*
KeyVaultCertificate specifies a certificate to install.
On Linux, the certificate file is placed under the /var/lib/waagent directory
with the file name <UppercaseThumbprint>.crt for the X509 certificate file
and <UppercaseThumbprint>.prv for the private key. Both of these files are .pem formatted.
On windows the certificate will be saved in the specified store.
*/
type KeyVaultCertificate struct {
CertificateURL string `json:"certificateUrl,omitempty"`
CertificateStore string `json:"certificateStore,omitempty"`
}
// KeyVaultID specifies a key vault.
type KeyVaultID struct {
ID string `json:"id,omitempty"`
}
// KeyVaultRef represents a reference to KeyVault instance on Azure.
type KeyVaultRef struct {
KeyVault KeyVaultID `json:"keyVault"`
SecretName string `json:"secretName"`
SecretVersion string `json:"secretVersion,omitempty"`
}
// KeyVaultSecrets specifies certificates to install on the pool of machines from a given key vault.
// the key vault specified must have been granted read permissions to CRP.
type KeyVaultSecrets struct {
SourceVault *KeyVaultID `json:"sourceVault,omitempty"`
VaultCertificates []KeyVaultCertificate `json:"vaultCertificates,omitempty"`
}
// ImageReference represents a reference to an Image resource in Azure.
type ImageReference struct {
Name string `json:"name,omitempty"`
ResourceGroup string `json:"resourceGroup,omitempty"`
SubscriptionID string `json:"subscriptionId,omitempty"`
Gallery string `json:"gallery,omitempty"`
Version string `json:"version,omitempty"`
}
// VMDiagnostics contains settings to on/off boot diagnostics collection in RD Host.
type VMDiagnostics struct {
Enabled bool `json:"enabled"`
// Specifies storage account Uri where Boot Diagnostics (CRP &
// VMSS BootDiagostics) and VM Diagnostics logs (using Linux
// Diagnostics Extension) will be stored. Uri will be of standard
// blob domain. i.e. https://storageaccount.blob.core.windows.net/
// This field is readonly as ACS RP will create a storage account
// for the customer.
StorageURL *neturl.URL `json:"storageUrl"`
}
// OSType represents OS types of agents.
type OSType string
// the OSTypes supported by vlabs.
const (
Windows OSType = "Windows"
Linux OSType = "Linux"
)
// KubeletDiskType describes options for placement of the primary kubelet partition.
// docker images, emptyDir volumes, and pod logs.
type KubeletDiskType string
const (
// OSDisk indicates data wil be shared with the OS.
OSDisk KubeletDiskType = "OS"
// TempDisk indicates date will be isolated on the temporary disk.
TempDisk KubeletDiskType = "Temporary"
)
// WorkloadRuntime describes choices for the type of workload: container or wasm-wasi, currently.
type WorkloadRuntime string
const (
// OCIContainer indicates that kubelet will be used for a container workload.
OCIContainer WorkloadRuntime = "OCIContainer"
// WasmWasi indicates Krustlet will be used for a WebAssembly workload.
WasmWasi WorkloadRuntime = "WasmWasi"
)
/*
CommandLineOmittedKubeletConfigFlags are the flags set by RP that should NOT be included within the set of
command line flags when configuring kubelet.
*/
func GetCommandLineOmittedKubeletConfigFlags() map[string]bool {
flags := map[string]bool{"--node-status-report-frequency": true}
return flags
}
// Distro represents Linux distro to use for Linux VMs.
type Distro string
// Distro string consts.
const (
Ubuntu Distro = "ubuntu"
Ubuntu1804 Distro = "ubuntu-18.04"
Ubuntu1804Gen2 Distro = "ubuntu-18.04-gen2"
AKSUbuntu1804Gen2 Distro = "ubuntu-18.04-gen2" // same distro as Ubuntu1804Gen2, renamed for clarity
AKSUbuntu1604 Distro = "aks-ubuntu-16.04"
AKSUbuntu1804 Distro = "aks-ubuntu-18.04"
AKSUbuntuGPU1804 Distro = "aks-ubuntu-gpu-18.04"
AKSUbuntuGPU1804Gen2 Distro = "aks-ubuntu-gpu-18.04-gen2"
AKSUbuntuContainerd1804 Distro = "aks-ubuntu-containerd-18.04"
AKSUbuntuContainerd1804Gen2 Distro = "aks-ubuntu-containerd-18.04-gen2"
AKSUbuntuGPUContainerd1804 Distro = "aks-ubuntu-gpu-containerd-18.04"
AKSUbuntuGPUContainerd1804Gen2 Distro = "aks-ubuntu-gpu-containerd-18.04-gen2"
AKSCBLMarinerV1 Distro = "aks-cblmariner-v1"
AKSCBLMarinerV2 Distro = "aks-cblmariner-v2"
AKSAzureLinuxV2 Distro = "aks-azurelinux-v2"
AKSCBLMarinerV2Gen2 Distro = "aks-cblmariner-v2-gen2"
AKSAzureLinuxV2Gen2 Distro = "aks-azurelinux-v2-gen2"
AKSCBLMarinerV2FIPS Distro = "aks-cblmariner-v2-fips"
AKSAzureLinuxV2FIPS Distro = "aks-azurelinux-v2-fips"
AKSCBLMarinerV2Gen2FIPS Distro = "aks-cblmariner-v2-gen2-fips"
AKSAzureLinuxV2Gen2FIPS Distro = "aks-azurelinux-v2-gen2-fips"
AKSCBLMarinerV2Gen2Kata Distro = "aks-cblmariner-v2-gen2-kata"
AKSAzureLinuxV2Gen2Kata Distro = "aks-azurelinux-v2-gen2-kata"
AKSCBLMarinerV2Gen2TL Distro = "aks-cblmariner-v2-gen2-tl"
AKSAzureLinuxV2Gen2TL Distro = "aks-azurelinux-v2-gen2-tl"
AKSCBLMarinerV2KataGen2TL Distro = "aks-cblmariner-v2-kata-gen2-tl"
AKSUbuntuFipsContainerd1804 Distro = "aks-ubuntu-fips-containerd-18.04"
AKSUbuntuFipsContainerd1804Gen2 Distro = "aks-ubuntu-fips-containerd-18.04-gen2"
AKSUbuntuFipsContainerd2004 Distro = "aks-ubuntu-fips-containerd-20.04"
AKSUbuntuFipsContainerd2004Gen2 Distro = "aks-ubuntu-fips-containerd-20.04-gen2"
AKSUbuntuEdgeZoneContainerd1804 Distro = "aks-ubuntu-edgezone-containerd-18.04"
AKSUbuntuEdgeZoneContainerd1804Gen2 Distro = "aks-ubuntu-edgezone-containerd-18.04-gen2"
AKSUbuntuEdgeZoneContainerd2204 Distro = "aks-ubuntu-edgezone-containerd-22.04"
AKSUbuntuEdgeZoneContainerd2204Gen2 Distro = "aks-ubuntu-edgezone-containerd-22.04-gen2"
AKSUbuntuContainerd2204 Distro = "aks-ubuntu-containerd-22.04"
AKSUbuntuContainerd2204Gen2 Distro = "aks-ubuntu-containerd-22.04-gen2"
AKSUbuntuContainerd2004CVMGen2 Distro = "aks-ubuntu-containerd-20.04-cvm-gen2"
AKSUbuntuArm64Containerd2204Gen2 Distro = "aks-ubuntu-arm64-containerd-22.04-gen2"
AKSCBLMarinerV2Arm64Gen2 Distro = "aks-cblmariner-v2-arm64-gen2"
AKSAzureLinuxV2Arm64Gen2 Distro = "aks-azurelinux-v2-arm64-gen2"
AKSUbuntuContainerd2204TLGen2 Distro = "aks-ubuntu-containerd-22.04-tl-gen2"
AKSUbuntuMinimalContainerd2204 Distro = "aks-ubuntu-minimal-containerd-22.04"
AKSUbuntuMinimalContainerd2204Gen2 Distro = "aks-ubuntu-minimal-containerd-22.04-gen2"
AKSUbuntuEgressContainerd2204Gen2 Distro = "aks-ubuntu-egress-containerd-22.04-gen2"
RHEL Distro = "rhel"
CoreOS Distro = "coreos"
AKS1604Deprecated Distro = "aks" // deprecated AKS 16.04 distro. Equivalent to aks-ubuntu-16.04.
AKS1804Deprecated Distro = "aks-1804" // deprecated AKS 18.04 distro. Equivalent to aks-ubuntu-18.04.
// Windows string const.
// AKSWindows2019 stands for distro of windows server 2019 SIG image with docker.
AKSWindows2019 Distro = "aks-windows-2019"
// AKSWindows2019Containerd stands for distro for windows server 2019 SIG image with containerd.
AKSWindows2019Containerd Distro = "aks-windows-2019-containerd"
// AKSWindows2022Containerd stands for distro for windows server 2022 SIG image with containerd.
AKSWindows2022Containerd Distro = "aks-windows-2022-containerd"
// AKSWindows2022ContainerdGen2 stands for distro for windows server 2022 Gen 2 SIG image with containerd.
AKSWindows2022ContainerdGen2 Distro = "aks-windows-2022-containerd-gen2"
// AKSWindows23H2 stands for distro for windows 23H2 SIG image.
AKSWindows23H2 Distro = "aks-windows-23H2"
// AKSWindows23H2Gen2 stands for distro for windows 23H2 Gen 2 SIG image.
AKSWindows23H2Gen2 Distro = "aks-windows-23H2-gen2"
// AKSWindows2019PIR stands for distro of windows server 2019 PIR image with docker.
AKSWindows2019PIR Distro = "aks-windows-2019-pir"
CustomizedImage Distro = "CustomizedImage"
CustomizedImageKata Distro = "CustomizedImageKata"
CustomizedWindowsOSImage Distro = "CustomizedWindowsOSImage"
// USNatCloud is a const string reference identifier for USNat.
USNatCloud = "USNatCloud"
// USSecCloud is a const string reference identifier for USSec.
USSecCloud = "USSecCloud"
)
//nolint:gochecknoglobals
var AKSDistrosAvailableOnVHD = []Distro{
AKSUbuntu1604,
AKSUbuntu1804,
AKSUbuntu1804Gen2,
AKSUbuntuGPU1804,
AKSUbuntuGPU1804Gen2,
AKSUbuntuContainerd1804,
AKSUbuntuContainerd1804Gen2,
AKSUbuntuGPUContainerd1804,
AKSUbuntuGPUContainerd1804Gen2,
AKSCBLMarinerV1,
AKSCBLMarinerV2,
AKSAzureLinuxV2,
AKSCBLMarinerV2Gen2,
AKSAzureLinuxV2Gen2,
AKSCBLMarinerV2FIPS,
AKSAzureLinuxV2FIPS,
AKSCBLMarinerV2Gen2FIPS,
AKSAzureLinuxV2Gen2FIPS,
AKSCBLMarinerV2Gen2Kata,
AKSAzureLinuxV2Gen2Kata,
AKSCBLMarinerV2Gen2TL,
AKSAzureLinuxV2Gen2TL,
AKSCBLMarinerV2KataGen2TL,
AKSUbuntuFipsContainerd1804,
AKSUbuntuFipsContainerd1804Gen2,
AKSUbuntuFipsContainerd2004,
AKSUbuntuFipsContainerd2004Gen2,
AKSUbuntuEdgeZoneContainerd1804,
AKSUbuntuEdgeZoneContainerd1804Gen2,
AKSUbuntuEdgeZoneContainerd2204,
AKSUbuntuEdgeZoneContainerd2204Gen2,
AKSUbuntuContainerd2204,
AKSUbuntuContainerd2204Gen2,
AKSUbuntuContainerd2004CVMGen2,
AKSUbuntuArm64Containerd2204Gen2,
AKSCBLMarinerV2Arm64Gen2,
AKSAzureLinuxV2Arm64Gen2,
AKSUbuntuContainerd2204TLGen2,
AKSUbuntuMinimalContainerd2204,
AKSUbuntuMinimalContainerd2204Gen2,
}
type CustomConfigurationComponent string
const (
ComponentkubeProxy CustomConfigurationComponent = "kube-proxy"
Componentkubelet CustomConfigurationComponent = "kubelet"
)
func (d Distro) IsVHDDistro() bool {
for _, distro := range AKSDistrosAvailableOnVHD {
if d == distro {
return true
}
}
return false
}
func (d Distro) Is2204VHDDistro() bool {
for _, distro := range AvailableUbuntu2204Distros {
if d == distro {
return true
}
}
return false
}
func (d Distro) IsAzureLinuxCgroupV2VHDDistro() bool {
for _, distro := range AvailableAzureLinuxCgroupV2Distros {
if d == distro {
return true
}
}
return false
}
func (d Distro) IsKataDistro() bool {
return d == AKSCBLMarinerV2Gen2Kata || d == AKSAzureLinuxV2Gen2Kata || d == AKSCBLMarinerV2KataGen2TL || d == CustomizedImageKata
}
/*
KeyvaultSecretRef specifies path to the Azure keyvault along with secret name and (optionaly) version
for Service Principal's secret.
*/
type KeyvaultSecretRef struct {
VaultID string `json:"vaultID"`
SecretName string `json:"secretName"`
SecretVersion string `json:"version,omitempty"`
}
// AuthenticatorType represents the authenticator type the cluster was.
// set up with.
type AuthenticatorType string
const (
// OIDC represent cluster setup in OIDC auth mode.
OIDC AuthenticatorType = "oidc"
// Webhook represent cluster setup in wehhook auth mode.
Webhook AuthenticatorType = "webhook"
)
// UserAssignedIdentity contains information that uniquely identifies an identity.
type UserAssignedIdentity struct {
ResourceID string `json:"resourceId,omitempty"`
ClientID string `json:"clientId,omitempty"`
ObjectID string `json:"objectId,omitempty"`
}
// ResourceIdentifiers represents resource ids.
type ResourceIdentifiers struct {
Graph string `json:"graph,omitempty"`
KeyVault string `json:"keyVault,omitempty"`
Datalake string `json:"datalake,omitempty"`
Batch string `json:"batch,omitempty"`
OperationalInsights string `json:"operationalInsights,omitempty"`
Storage string `json:"storage,omitempty"`
}
// CustomCloudEnv represents the custom cloud env info of the AKS cluster.
type CustomCloudEnv struct {
// TODO(ace): why is Name uppercase?
// in Linux, this was historically specified as "name" when serialized.
// However Windows relies on the json tag as "Name".
// TODO(ace): can we align on one casing?
SnakeCaseName string `json:"name,omitempty"`
Name string `json:"Name,omitempty"`
McrURL string `json:"mcrURL,omitempty"`
RepoDepotEndpoint string `json:"repoDepotEndpoint,omitempty"`
ManagementPortalURL string `json:"managementPortalURL,omitempty"`
PublishSettingsURL string `json:"publishSettingsURL,omitempty"`
ServiceManagementEndpoint string `json:"serviceManagementEndpoint,omitempty"`
ResourceManagerEndpoint string `json:"resourceManagerEndpoint,omitempty"`
ActiveDirectoryEndpoint string `json:"activeDirectoryEndpoint,omitempty"`
GalleryEndpoint string `json:"galleryEndpoint,omitempty"`
KeyVaultEndpoint string `json:"keyVaultEndpoint,omitempty"`
GraphEndpoint string `json:"graphEndpoint,omitempty"`
ServiceBusEndpoint string `json:"serviceBusEndpoint,omitempty"`
BatchManagementEndpoint string `json:"batchManagementEndpoint,omitempty"`
StorageEndpointSuffix string `json:"storageEndpointSuffix,omitempty"`
SQLDatabaseDNSSuffix string `json:"sqlDatabaseDNSSuffix,omitempty"`
TrafficManagerDNSSuffix string `json:"trafficManagerDNSSuffix,omitempty"`
KeyVaultDNSSuffix string `json:"keyVaultDNSSuffix,omitempty"`
ServiceBusEndpointSuffix string `json:"serviceBusEndpointSuffix,omitempty"`
ServiceManagementVMDNSSuffix string `json:"serviceManagementVMDNSSuffix,omitempty"`
ResourceManagerVMDNSSuffix string `json:"resourceManagerVMDNSSuffix,omitempty"`
ContainerRegistryDNSSuffix string `json:"containerRegistryDNSSuffix,omitempty"`
CosmosDBDNSSuffix string `json:"cosmosDBDNSSuffix,omitempty"`
TokenAudience string `json:"tokenAudience,omitempty"`
ResourceIdentifiers ResourceIdentifiers `json:"resourceIdentifiers,omitempty"`
}
// FeatureFlags defines feature-flag restricted functionality.
type FeatureFlags struct {
EnableCSERunInBackground bool `json:"enableCSERunInBackground,omitempty"`
BlockOutboundInternet bool `json:"blockOutboundInternet,omitempty"`
EnableIPv6DualStack bool `json:"enableIPv6DualStack,omitempty"`
EnableIPv6Only bool `json:"enableIPv6Only,omitempty"`
EnableWinDSR bool `json:"enableWinDSR,omitempty"`
}
// AddonProfile represents an addon for managed cluster.
type AddonProfile struct {
Enabled bool `json:"enabled"`
Config map[string]string `json:"config"`
// Identity contains information of the identity associated with this addon.
// This property will only appear in an MSI-enabled cluster.
Identity *UserAssignedIdentity `json:"identity,omitempty"`
}
// HostedMasterProfile defines properties for a hosted master.
type HostedMasterProfile struct {
// Master public endpoint/FQDN with port.
// The format will be FQDN:2376.
// Not used during PUT, returned as part of GETFQDN.
FQDN string `json:"fqdn,omitempty"`
// IPAddress.
// if both FQDN and IPAddress are specified, we should use IPAddress.
IPAddress string `json:"ipAddress,omitempty"`
DNSPrefix string `json:"dnsPrefix"`
// FQDNSubdomain is used by private cluster without dnsPrefix so they have fixed FQDN.
FQDNSubdomain string `json:"fqdnSubdomain"`
/* Subnet holds the CIDR which defines the Azure Subnet in which
Agents will be provisioned. This is stored on the HostedMasterProfile
and will become `masterSubnet` in the compiled template. */
Subnet string `json:"subnet"`
// ApiServerWhiteListRange is a comma delimited CIDR which is whitelisted to AKS.
APIServerWhiteListRange *string `json:"apiServerWhiteListRange"`
IPMasqAgent bool `json:"ipMasqAgent"`
}
// CustomProfile specifies custom properties that are used for cluster instantiation.
// Should not be used by most users.
type CustomProfile struct {
Orchestrator string `json:"orchestrator,omitempty"`
}
// AADProfile specifies attributes for AAD integration.
type AADProfile struct {
// The client AAD application ID.
ClientAppID string `json:"clientAppID,omitempty"`
// The server AAD application ID.
ServerAppID string `json:"serverAppID,omitempty"`
// The server AAD application secret.
ServerAppSecret string `json:"serverAppSecret,omitempty" conform:"redact"`
// The AAD tenant ID to use for authentication.
// If not specified, will use the tenant of the deployment subscription.
// Optional.
TenantID string `json:"tenantID,omitempty"`
// The Azure Active Directory Group Object ID that will be assigned the cluster-admin RBAC role.
// Optional.
AdminGroupID string `json:"adminGroupID,omitempty"`
// The authenticator to use, either "oidc" or "webhook".
Authenticator AuthenticatorType `json:"authenticator"`
}
// CertificateProfile represents the definition of the master cluster.
type CertificateProfile struct {
// CaCertificate is the certificate authority certificate.
CaCertificate string `json:"caCertificate,omitempty" conform:"redact"`
// ApiServerCertificate is the rest api server certificate, and signed by the CA.
APIServerCertificate string `json:"apiServerCertificate,omitempty" conform:"redact"`
// ClientCertificate is the certificate used by the client kubelet services and signed by the CA.
ClientCertificate string `json:"clientCertificate,omitempty" conform:"redact"`
// ClientPrivateKey is the private key used by the client kubelet services and signed by the CA.
ClientPrivateKey string `json:"clientPrivateKey,omitempty" conform:"redact"`
// KubeConfigCertificate is the client certificate used for kubectl cli and signed by the CA.
KubeConfigCertificate string `json:"kubeConfigCertificate,omitempty" conform:"redact"`
// KubeConfigPrivateKey is the client private key used for kubectl cli and signed by the CA.
KubeConfigPrivateKey string `json:"kubeConfigPrivateKey,omitempty" conform:"redact"`
}
// ServicePrincipalProfile contains the client and secret used by the cluster for Azure Resource CRUD.
type ServicePrincipalProfile struct {
ClientID string `json:"clientId"`
Secret string `json:"secret,omitempty" conform:"redact"`
ObjectID string `json:"objectId,omitempty"`
KeyvaultSecretRef *KeyvaultSecretRef `json:"keyvaultSecretRef,omitempty"`
}
// DiagnosticsProfile setting to enable/disable capturing.
// diagnostics for VMs hosting container cluster.
type DiagnosticsProfile struct {
VMDiagnostics *VMDiagnostics `json:"vmDiagnostics"`
}
// ExtensionProfile represents an extension definition.
type ExtensionProfile struct {
Name string `json:"name"`
Version string `json:"version"`
ExtensionParameters string `json:"extensionParameters,omitempty"`
ExtensionParametersKeyVaultRef *KeyvaultSecretRef `json:"parametersKeyvaultSecretRef,omitempty"`
RootURL string `json:"rootURL,omitempty"`
// This is only needed for preprovision extensions and it needs to be a bash script.
Script string `json:"script,omitempty"`
URLQuery string `json:"urlQuery,omitempty"`
}
// ResourcePurchasePlan defines resource plan as required by ARM for billing purposes.
type ResourcePurchasePlan struct {
Name string `json:"name"`
Product string `json:"product"`
PromotionCode string `json:"promotionCode"`
Publisher string `json:"publisher"`
}
// WindowsProfile represents the windows parameters passed to the cluster.
type WindowsProfile struct {
AdminUsername string `json:"adminUsername"`
AdminPassword string `json:"adminPassword" conform:"redact"`
CSIProxyURL string `json:"csiProxyURL,omitempty"`
EnableCSIProxy *bool `json:"enableCSIProxy,omitempty"`
ImageRef *ImageReference `json:"imageReference,omitempty"`
ImageVersion string `json:"imageVersion"`
ProvisioningScriptsPackageURL string `json:"provisioningScriptsPackageURL,omitempty"`
WindowsImageSourceURL string `json:"windowsImageSourceURL"`
WindowsPublisher string `json:"windowsPublisher"`
WindowsOffer string `json:"windowsOffer"`
WindowsSku string `json:"windowsSku"`
WindowsDockerVersion string `json:"windowsDockerVersion"`
Secrets []KeyVaultSecrets `json:"secrets,omitempty"`
SSHEnabled *bool `json:"sshEnabled,omitempty"`
EnableAutomaticUpdates *bool `json:"enableAutomaticUpdates,omitempty"`
IsCredentialAutoGenerated *bool `json:"isCredentialAutoGenerated,omitempty"`
EnableAHUB *bool `json:"enableAHUB,omitempty"`
WindowsPauseImageURL string `json:"windowsPauseImageURL"`
AlwaysPullWindowsPauseImage *bool `json:"alwaysPullWindowsPauseImage,omitempty"`
ContainerdWindowsRuntimes *ContainerdWindowsRuntimes `json:"containerdWindowsRuntimes,omitempty"`
WindowsCalicoPackageURL string `json:"windowsCalicoPackageURL,omitempty"`
//nolint:revive, stylecheck // keep field names the same as RP
WindowsSecureTlsEnabled *bool `json:"windowsSecureTlsEnabled,omitempty"`
//nolint:revive, stylecheck // keep field names the same as RP
WindowsGmsaPackageUrl string `json:"windowsGmsaPackageUrl,omitempty"`
CseScriptsPackageURL string `json:"cseScriptsPackageURL,omitempty"`
GpuDriverURL string `json:"gpuDriverUrl,omitempty"`
HnsRemediatorIntervalInMinutes *uint32 `json:"hnsRemediatorIntervalInMinutes,omitempty"`
LogGeneratorIntervalInMinutes *uint32 `json:"logGeneratorIntervalInMinutes,omitempty"`
}
// ContainerdWindowsRuntimes configures containerd runtimes that are available on the windows nodes.
type ContainerdWindowsRuntimes struct {
DefaultSandboxIsolation string `json:"defaultSandboxIsolation,omitempty"`
RuntimeHandlers []RuntimeHandlers `json:"runtimesHandlers,omitempty"`
}
// RuntimeHandlers configures the runtime settings in containerd.
type RuntimeHandlers struct {
BuildNumber string `json:"buildNumber,omitempty"`
}
// LinuxProfile represents the linux parameters passed to the cluster.
type LinuxProfile struct {
AdminUsername string `json:"adminUsername"`
SSH struct {
PublicKeys []PublicKey `json:"publicKeys"`
} `json:"ssh"`
Secrets []KeyVaultSecrets `json:"secrets,omitempty"`
Distro Distro `json:"distro,omitempty"`
CustomSearchDomain *CustomSearchDomain `json:"customSearchDomain,omitempty"`
}
// Extension represents an extension definition in the master or agentPoolProfile.
type Extension struct {
Name string `json:"name"`
SingleOrAll string `json:"singleOrAll"`
Template string `json:"template"`
}
// PrivateJumpboxProfile represents a jumpbox definition.
type PrivateJumpboxProfile struct {
Name string `json:"name" validate:"required"`
VMSize string `json:"vmSize" validate:"required"`
OSDiskSizeGB int `json:"osDiskSizeGB,omitempty" validate:"min=0,max=2048"`
Username string `json:"username,omitempty"`
PublicKey string `json:"publicKey" validate:"required"`
StorageProfile string `json:"storageProfile,omitempty"`
}
// PrivateCluster defines the configuration for a private cluster.
type PrivateCluster struct {
Enabled *bool `json:"enabled,omitempty"`
EnableHostsConfigAgent *bool `json:"enableHostsConfigAgent,omitempty"`
JumpboxProfile *PrivateJumpboxProfile `json:"jumpboxProfile,omitempty"`
}
// KubernetesContainerSpec defines configuration for a container spec.
type KubernetesContainerSpec struct {
Name string `json:"name,omitempty"`
Image string `json:"image,omitempty"`
CPURequests string `json:"cpuRequests,omitempty"`
MemoryRequests string `json:"memoryRequests,omitempty"`
CPULimits string `json:"cpuLimits,omitempty"`
MemoryLimits string `json:"memoryLimits,omitempty"`
}
// AddonNodePoolsConfig defines configuration for pool-specific cluster-autoscaler configuration.
type AddonNodePoolsConfig struct {
Name string `json:"name,omitempty"`
Config map[string]string `json:"config,omitempty"`
}
// KubernetesAddon defines a list of addons w/ configuration to include with the cluster deployment.
type KubernetesAddon struct {
Name string `json:"name,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Mode string `json:"mode,omitempty"`
Containers []KubernetesContainerSpec `json:"containers,omitempty"`
Config map[string]string `json:"config,omitempty"`
Pools []AddonNodePoolsConfig `json:"pools,omitempty"`
Data string `json:"data,omitempty"`
}
// KubernetesConfig contains the Kubernetes config structure, containing Kubernetes specific configuration.
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
MCRKubernetesImageBase string `json:"mcrKubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
NetworkPlugin string `json:"networkPlugin,omitempty"`
NetworkMode string `json:"networkMode,omitempty"`
ContainerRuntime string `json:"containerRuntime,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
UserAssignedID string `json:"userAssignedID,omitempty"`
UserAssignedClientID string `json:"userAssignedClientID,omitempty"` //nolint: lll // Note: cannot be provided in config. Used *only* for transferring this to azure.json.
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
CustomKubeProxyImage string `json:"customKubeProxyImage,omitempty"`
CustomKubeBinaryURL string `json:"customKubeBinaryURL,omitempty"`
MobyVersion string `json:"mobyVersion,omitempty"`
ContainerdVersion string `json:"containerdVersion,omitempty"`
WindowsNodeBinariesURL string `json:"windowsNodeBinariesURL,omitempty"`
WindowsContainerdURL string `json:"windowsContainerdURL,omitempty"`
WindowsSdnPluginURL string `json:"windowsSdnPluginURL,omitempty"`
UseInstanceMetadata *bool `json:"useInstanceMetadata,omitempty"`
EnableRbac *bool `json:"enableRbac,omitempty"`
EnableSecureKubelet *bool `json:"enableSecureKubelet,omitempty"`
PrivateCluster *PrivateCluster `json:"privateCluster,omitempty"`
GCHighThreshold int `json:"gchighthreshold,omitempty"`
GCLowThreshold int `json:"gclowthreshold,omitempty"`
EnableEncryptionWithExternalKms *bool `json:"enableEncryptionWithExternalKms,omitempty"`
Addons []KubernetesAddon `json:"addons,omitempty"`
ContainerRuntimeConfig map[string]string `json:"containerRuntimeConfig,omitempty"`
ControllerManagerConfig map[string]string `json:"controllerManagerConfig,omitempty"`
SchedulerConfig map[string]string `json:"schedulerConfig,omitempty"`
CloudProviderBackoffMode string `json:"cloudProviderBackoffMode"`
CloudProviderBackoff *bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty"`
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty"`
CloudProviderRateLimit *bool `json:"cloudProviderRateLimit,omitempty"`
CloudProviderRateLimitQPS float64 `json:"cloudProviderRateLimitQPS,omitempty"`
CloudProviderRateLimitQPSWrite float64 `json:"cloudProviderRateLimitQPSWrite,omitempty"`
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
CloudProviderRateLimitBucketWrite int `json:"cloudProviderRateLimitBucketWrite,omitempty"`
CloudProviderDisableOutboundSNAT *bool `json:"cloudProviderDisableOutboundSNAT,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
LoadBalancerSku string `json:"loadBalancerSku,omitempty"`
ExcludeMasterFromStandardLB *bool `json:"excludeMasterFromStandardLB,omitempty"`
AzureCNIURLLinux string `json:"azureCNIURLLinux,omitempty"`
AzureCNIURLARM64Linux string `json:"azureCNIURLARM64Linux,omitempty"`
AzureCNIURLWindows string `json:"azureCNIURLWindows,omitempty"`
MaximumLoadBalancerRuleCount int `json:"maximumLoadBalancerRuleCount,omitempty"`
PrivateAzureRegistryServer string `json:"privateAzureRegistryServer,omitempty"`
NetworkPluginMode string `json:"networkPluginMode,omitempty"`
}
/*
CustomFile has source as the full absolute source path to a file and dest
is the full absolute desired destination path to put the file on a master node.
*/
type CustomFile struct {
Source string `json:"source,omitempty"`
Dest string `json:"dest,omitempty"`
}
// OrchestratorProfile contains Orchestrator properties.
type OrchestratorProfile struct {
OrchestratorType string `json:"orchestratorType"`
OrchestratorVersion string `json:"orchestratorVersion"`
KubernetesConfig *KubernetesConfig `json:"kubernetesConfig,omitempty"`
}
// ProvisioningState represents the current state of container service resource.
type ProvisioningState string
// CustomKubeletConfig represents custom kubelet configurations for agent pool nodes.
type CustomKubeletConfig struct {
CPUManagerPolicy string `json:"cpuManagerPolicy,omitempty"`
CPUCfsQuota *bool `json:"cpuCfsQuota,omitempty"`
CPUCfsQuotaPeriod string `json:"cpuCfsQuotaPeriod,omitempty"`
ImageGcHighThreshold *int32 `json:"imageGcHighThreshold,omitempty"`
ImageGcLowThreshold *int32 `json:"imageGcLowThreshold,omitempty"`
TopologyManagerPolicy string `json:"topologyManagerPolicy,omitempty"`
AllowedUnsafeSysctls *[]string `json:"allowedUnsafeSysctls,omitempty"`
FailSwapOn *bool `json:"failSwapOn,omitempty"`
ContainerLogMaxSizeMB *int32 `json:"containerLogMaxSizeMB,omitempty"`
ContainerLogMaxFiles *int32 `json:"containerLogMaxFiles,omitempty"`
PodMaxPids *int32 `json:"podMaxPids,omitempty"`
}
// CustomLinuxOSConfig represents custom os configurations for agent pool nodes.
type CustomLinuxOSConfig struct {
Sysctls *SysctlConfig `json:"sysctls,omitempty"`
TransparentHugePageEnabled string `json:"transparentHugePageEnabled,omitempty"`
TransparentHugePageDefrag string `json:"transparentHugePageDefrag,omitempty"`
SwapFileSizeMB *int32 `json:"swapFileSizeMB,omitempty"`
UlimitConfig *UlimitConfig `json:"ulimitConfig,omitempty"`
}
func (c *CustomLinuxOSConfig) GetUlimitConfig() *UlimitConfig {
if c == nil {
return nil
}
return c.UlimitConfig
}
// SysctlConfig represents sysctl configs in customLinuxOsConfig.
type SysctlConfig struct {
NetCoreSomaxconn *int32 `json:"netCoreSomaxconn,omitempty"`
NetCoreNetdevMaxBacklog *int32 `json:"netCoreNetdevMaxBacklog,omitempty"`
NetCoreRmemDefault *int32 `json:"netCoreRmemDefault,omitempty"`
NetCoreRmemMax *int32 `json:"netCoreRmemMax,omitempty"`
NetCoreWmemDefault *int32 `json:"netCoreWmemDefault,omitempty"`
NetCoreWmemMax *int32 `json:"netCoreWmemMax,omitempty"`
NetCoreOptmemMax *int32 `json:"netCoreOptmemMax,omitempty"`
NetIpv4TcpMaxSynBacklog *int32 `json:"netIpv4TcpMaxSynBacklog,omitempty"`
NetIpv4TcpMaxTwBuckets *int32 `json:"netIpv4TcpMaxTwBuckets,omitempty"`
NetIpv4TcpFinTimeout *int32 `json:"netIpv4TcpFinTimeout,omitempty"`
NetIpv4TcpKeepaliveTime *int32 `json:"netIpv4TcpKeepaliveTime,omitempty"`
NetIpv4TcpKeepaliveProbes *int32 `json:"netIpv4TcpKeepaliveProbes,omitempty"`
NetIpv4TcpkeepaliveIntvl *int32 `json:"netIpv4TcpkeepaliveIntvl,omitempty"`
NetIpv4TcpTwReuse *bool `json:"netIpv4TcpTwReuse,omitempty"`
NetIpv4IpLocalPortRange string `json:"netIpv4IpLocalPortRange,omitempty"`
NetIpv4NeighDefaultGcThresh1 *int32 `json:"netIpv4NeighDefaultGcThresh1,omitempty"`
NetIpv4NeighDefaultGcThresh2 *int32 `json:"netIpv4NeighDefaultGcThresh2,omitempty"`
NetIpv4NeighDefaultGcThresh3 *int32 `json:"netIpv4NeighDefaultGcThresh3,omitempty"`
NetNetfilterNfConntrackMax *int32 `json:"netNetfilterNfConntrackMax,omitempty"`
NetNetfilterNfConntrackBuckets *int32 `json:"netNetfilterNfConntrackBuckets,omitempty"`
FsInotifyMaxUserWatches *int32 `json:"fsInotifyMaxUserWatches,omitempty"`
FsFileMax *int32 `json:"fsFileMax,omitempty"`
FsAioMaxNr *int32 `json:"fsAioMaxNr,omitempty"`
FsNrOpen *int32 `json:"fsNrOpen,omitempty"`
KernelThreadsMax *int32 `json:"kernelThreadsMax,omitempty"`
VMMaxMapCount *int32 `json:"vmMaxMapCount,omitempty"`
VMSwappiness *int32 `json:"vmSwappiness,omitempty"`
VMVfsCachePressure *int32 `json:"vmVfsCachePressure,omitempty"`
}
type UlimitConfig struct {
MaxLockedMemory string `json:"maxLockedMemory ,omitempty"`
NoFile string `json:"noFile,omitempty"`
}
type CustomConfiguration struct {
KubernetesConfigurations map[string]*ComponentConfiguration
WindowsKubernetesConfigurations map[string]*ComponentConfiguration
}
type ComponentConfiguration struct {
Image *string
Config map[string]string
DownloadURL *string
}
// AgentPoolProfile represents an agent pool definition.
type AgentPoolProfile struct {
Name string `json:"name"`
VMSize string `json:"vmSize"`
KubeletDiskType KubeletDiskType `json:"kubeletDiskType,omitempty"`
WorkloadRuntime WorkloadRuntime `json:"workloadRuntime,omitempty"`
DNSPrefix string `json:"dnsPrefix,omitempty"`
OSType OSType `json:"osType,omitempty"`
Ports []int `json:"ports,omitempty"`
AvailabilityProfile string `json:"availabilityProfile"`
StorageProfile string `json:"storageProfile,omitempty"`
VnetSubnetID string `json:"vnetSubnetID,omitempty"`
Distro Distro `json:"distro,omitempty"`
CustomNodeLabels map[string]string `json:"customNodeLabels,omitempty"`
PreprovisionExtension *Extension `json:"preProvisionExtension"`
KubernetesConfig *KubernetesConfig `json:"kubernetesConfig,omitempty"`
VnetCidrs []string `json:"vnetCidrs,omitempty"`
WindowsNameVersion string `json:"windowsNameVersion,omitempty"`
CustomKubeletConfig *CustomKubeletConfig `json:"customKubeletConfig,omitempty"`
CustomLinuxOSConfig *CustomLinuxOSConfig `json:"customLinuxOSConfig,omitempty"`
MessageOfTheDay string `json:"messageOfTheDay,omitempty"`
/* This is a new property and all old agent pools do no have this field. We need to keep the default
behavior to reboot Windows node when it is nil. */
NotRebootWindowsNode *bool `json:"notRebootWindowsNode,omitempty"`
AgentPoolWindowsProfile *AgentPoolWindowsProfile `json:"agentPoolWindowsProfile,omitempty"`
}
func (a *AgentPoolProfile) GetCustomLinuxOSConfig() *CustomLinuxOSConfig {
if a == nil {
return nil
}
return a.CustomLinuxOSConfig
}
// Properties represents the AKS cluster definition.
type Properties struct {
ClusterID string
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
OrchestratorProfile *OrchestratorProfile `json:"orchestratorProfile,omitempty"`
AgentPoolProfiles []*AgentPoolProfile `json:"agentPoolProfiles,omitempty"`
LinuxProfile *LinuxProfile `json:"linuxProfile,omitempty"`
WindowsProfile *WindowsProfile `json:"windowsProfile,omitempty"`
ExtensionProfiles []*ExtensionProfile `json:"extensionProfiles"`
DiagnosticsProfile *DiagnosticsProfile `json:"diagnosticsProfile,omitempty"`
ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"`
CertificateProfile *CertificateProfile `json:"certificateProfile,omitempty"`
AADProfile *AADProfile `json:"aadProfile,omitempty"`
CustomProfile *CustomProfile `json:"customProfile,omitempty"`
HostedMasterProfile *HostedMasterProfile `json:"hostedMasterProfile,omitempty"`
AddonProfiles map[string]AddonProfile `json:"addonProfiles,omitempty"`
FeatureFlags *FeatureFlags `json:"featureFlags,omitempty"`
CustomCloudEnv *CustomCloudEnv `json:"customCloudEnv,omitempty"`
CustomConfiguration *CustomConfiguration `json:"customConfiguration,omitempty"`
SecurityProfile *SecurityProfile `json:"securityProfile,omitempty"`
}
// ContainerService complies with the ARM model of resource definition in a JSON template.
type ContainerService struct {
ID string `json:"id"`
Location string `json:"location"`
Name string `json:"name"`
Plan *ResourcePurchasePlan `json:"plan,omitempty"`
Tags map[string]string `json:"tags"`
Type string `json:"type"`
Properties *Properties `json:"properties,omitempty"`
}
// IsAKSCustomCloud checks if it's in AKS custom cloud.
func (cs *ContainerService) IsAKSCustomCloud() bool {
return cs.Properties.CustomCloudEnv != nil &&
strings.EqualFold(cs.Properties.CustomCloudEnv.Name, "akscustom")
}
// HasAadProfile returns true if the has aad profile.
func (p *Properties) HasAadProfile() bool {
return p.AADProfile != nil
}
/*
GetCustomCloudName returns name of environment if customCloudProfile is provided, returns empty string if
customCloudProfile is empty.Because customCloudProfile is empty for deployment is AzurePublicCloud,
AzureChinaCloud, AzureGermanCloud, AzureUSGovernmentCloud, the return value will be empty string for those
clouds.
*/
func (p *Properties) GetCustomCloudName() string {
var cloudProfileName string
if p.IsAKSCustomCloud() {
cloudProfileName = p.CustomCloudEnv.Name
}
return cloudProfileName
}
// IsIPMasqAgentDisabled returns true if the ip-masq-agent functionality is disabled.
func (p *Properties) IsIPMasqAgentDisabled() bool {
if p.HostedMasterProfile != nil {
return !p.HostedMasterProfile.IPMasqAgent
}
if p.OrchestratorProfile != nil && p.OrchestratorProfile.KubernetesConfig != nil {
return p.OrchestratorProfile.KubernetesConfig.IsIPMasqAgentDisabled()
}
return false
}
// HasWindows returns true if the cluster contains windows.
func (p *Properties) HasWindows() bool {
for _, agentPoolProfile := range p.AgentPoolProfiles {
if strings.EqualFold(string(agentPoolProfile.OSType), string(Windows)) {
return true
}
}
return false
}
// IsAKSCustomCloud checks if it's in AKS custom cloud.
func (p *Properties) IsAKSCustomCloud() bool {
return p.CustomCloudEnv != nil &&
strings.EqualFold(p.CustomCloudEnv.Name, "akscustom")
}
// IsIPMasqAgentEnabled returns true if the cluster has a hosted master and IpMasqAgent is disabled.
func (p *Properties) IsIPMasqAgentEnabled() bool {
if p.HostedMasterProfile != nil {
return p.HostedMasterProfile.IPMasqAgent
}
return p.OrchestratorProfile.KubernetesConfig.IsIPMasqAgentEnabled()
}
// GetClusterID creates a unique 8 string cluster ID.
func (p *Properties) GetClusterID() string {
mutex := &sync.Mutex{}
if p.ClusterID == "" {
uniqueNameSuffixSize := 8
/* the name suffix uniquely identifies the cluster and is generated off a hash from the
master dns name. */
h := fnv.New64a()
if p.HostedMasterProfile != nil {
h.Write([]byte(p.HostedMasterProfile.DNSPrefix))
} else if len(p.AgentPoolProfiles) > 0 {
h.Write([]byte(p.AgentPoolProfiles[0].Name))
}
//nolint:gosec // I think we want rand not crypto/rand here
r := rand.New(rand.NewSource(int64(h.Sum64())))
mutex.Lock()
p.ClusterID = fmt.Sprintf("%08d", r.Uint32())[:uniqueNameSuffixSize]
mutex.Unlock()
}
return p.ClusterID
}
/*
AreAgentProfilesCustomVNET returns true if all of the agent profiles in the clusters are
configured with VNET.
*/
func (p *Properties) AreAgentProfilesCustomVNET() bool {
if p.AgentPoolProfiles != nil {
for _, agentPoolProfile := range p.AgentPoolProfiles {
if !agentPoolProfile.IsCustomVNET() {
return false
}
}
return true
}
return false
}
// GetCustomEnvironmentJSON return the JSON format string for custom environment.
func (p *Properties) GetCustomEnvironmentJSON(escape bool) (string, error) {
var environmentJSON string
if p.IsAKSCustomCloud() {
// Workaround to set correct name in AzureStackCloud.json.
oldName := p.CustomCloudEnv.Name
p.CustomCloudEnv.Name = AzureStackCloud
p.CustomCloudEnv.SnakeCaseName = AzureStackCloud
defer func() {
// Restore p.CustomCloudEnv to old value.
p.CustomCloudEnv.Name = oldName
}()
bytes, err := json.Marshal(p.CustomCloudEnv)
if err != nil {
return "", fmt.Errorf("could not serialize CustomCloudEnv object - %w", err)
}
environmentJSON = string(bytes)
if escape {
environmentJSON = strings.ReplaceAll(environmentJSON, "\"", "\\\"")
}
}
return environmentJSON, nil
}
// HasDCSeriesSKU returns whether or not there is an DC series SKU agent pool.
func (p *Properties) HasDCSeriesSKU() bool {
for _, profile := range p.AgentPoolProfiles {
if strings.Contains(profile.VMSize, "Standard_DC") {
return true
}
}
return false
}
// K8sOrchestratorName returns the 3 character orchestrator code for kubernetes-based clusters.
func (p *Properties) K8sOrchestratorName() string {
if p.OrchestratorProfile.IsKubernetes() {
if p.HostedMasterProfile != nil {
return DefaultHostedProfileMasterName
}
return DefaultOrchestratorName
}
return ""
}
// IsVHDDistroForAllNodes returns true if all of the agent pools plus masters are running the VHD image.
func (p *Properties) IsVHDDistroForAllNodes() bool {
if len(p.AgentPoolProfiles) > 0 {
for _, ap := range p.AgentPoolProfiles {
if !ap.IsVHDDistro() {
return false
}
}
}
return true
}
// GetVMType returns the type of VM "vmss" or "standard" to be passed to the cloud provider.
func (p *Properties) GetVMType() string {
if p.HasVMSSAgentPool() {
return VMSSVMType
}
return StandardVMType
}
// HasVMSSAgentPool returns true if the cluster contains Virtual Machine Scale Sets agent pools.
func (p *Properties) HasVMSSAgentPool() bool {
for _, agentPoolProfile := range p.AgentPoolProfiles {
if strings.EqualFold(agentPoolProfile.AvailabilityProfile, VirtualMachineScaleSets) {
return true
}
}
return false
}
// GetSubnetName returns the subnet name of the cluster based on its current configuration.
func (p *Properties) GetSubnetName() string {
var subnetName string
if p.AreAgentProfilesCustomVNET() {
subnetName = strings.Split(p.AgentPoolProfiles[0].VnetSubnetID, "/")[DefaultSubnetNameResourceSegmentIndex]
} else {
subnetName = p.K8sOrchestratorName() + "-subnet"
}
return subnetName
}
// GetNSGName returns the name of the network security group of the cluster.
func (p *Properties) GetNSGName() string {
return p.GetResourcePrefix() + "nsg"
}