-
Notifications
You must be signed in to change notification settings - Fork 427
/
types.go
1217 lines (1047 loc) · 49.6 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 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/net"
)
const (
// ControlPlane machine label.
ControlPlane string = "control-plane"
// Node machine label.
Node string = "node"
// Bastion subnet label.
Bastion string = "bastion"
// Cluster subnet label.
Cluster string = "cluster"
)
// SecurityEncryptionType represents the Encryption Type when the virtual machine is a
// Confidential VM.
type SecurityEncryptionType string
const (
// SecurityEncryptionTypeVMGuestStateOnly disables OS disk confidential encryption.
SecurityEncryptionTypeVMGuestStateOnly SecurityEncryptionType = "VMGuestStateOnly"
// SecurityEncryptionTypeDiskWithVMGuestState OS disk confidential encryption with a
// platform-managed key (PMK) or a customer-managed key (CMK).
SecurityEncryptionTypeDiskWithVMGuestState SecurityEncryptionType = "DiskWithVMGuestState"
)
// SecurityTypes represents the SecurityType of the virtual machine.
type SecurityTypes string
const (
// SecurityTypesConfidentialVM defines the SecurityType of the virtual machine as a Confidential VM.
SecurityTypesConfidentialVM SecurityTypes = "ConfidentialVM"
// SecurityTypesTrustedLaunch defines the SecurityType of the virtual machine as a Trusted Launch VM.
SecurityTypesTrustedLaunch SecurityTypes = "TrustedLaunch"
)
// Futures is a slice of Future.
type Futures []Future
const (
// PatchFuture is a future that was derived from a PATCH request.
PatchFuture string = "PATCH"
// PutFuture is a future that was derived from a PUT request.
PutFuture string = "PUT"
// DeleteFuture is a future that was derived from a DELETE request.
DeleteFuture string = "DELETE"
)
// Future contains the data needed for an Azure long-running operation to continue across reconcile loops.
type Future struct {
// Type describes the type of future, such as update, create, delete, etc.
Type string `json:"type"`
// ResourceGroup is the Azure resource group for the resource.
// +optional
ResourceGroup string `json:"resourceGroup,omitempty"`
// ServiceName is the name of the Azure service.
// Together with the name of the resource, this forms the unique identifier for the future.
ServiceName string `json:"serviceName"`
// Name is the name of the Azure resource.
// Together with the service name, this forms the unique identifier for the future.
Name string `json:"name"`
// Data is the base64 url encoded json Azure AutoRest Future.
Data string `json:"data"`
}
// NetworkSpec specifies what the Azure networking resources should look like.
type NetworkSpec struct {
// Vnet is the configuration for the Azure virtual network.
// +optional
Vnet VnetSpec `json:"vnet,omitempty"`
// Subnets is the configuration for the control-plane subnet and the node subnet.
// +optional
Subnets Subnets `json:"subnets,omitempty"`
// APIServerLB is the configuration for the control-plane load balancer.
// +optional
APIServerLB LoadBalancerSpec `json:"apiServerLB,omitempty"`
// NodeOutboundLB is the configuration for the node outbound load balancer.
// +optional
NodeOutboundLB *LoadBalancerSpec `json:"nodeOutboundLB,omitempty"`
// ControlPlaneOutboundLB is the configuration for the control-plane outbound load balancer.
// This is different from APIServerLB, and is used only in private clusters (optionally) for enabling outbound traffic.
// +optional
ControlPlaneOutboundLB *LoadBalancerSpec `json:"controlPlaneOutboundLB,omitempty"`
NetworkClassSpec `json:",inline"`
}
// VnetSpec configures an Azure virtual network.
type VnetSpec struct {
// ResourceGroup is the name of the resource group of the existing virtual network
// or the resource group where a managed virtual network should be created.
// +optional
ResourceGroup string `json:"resourceGroup,omitempty"`
// ID is the Azure resource ID of the virtual network.
// READ-ONLY
// +optional
ID string `json:"id,omitempty"`
// Name defines a name for the virtual network resource.
Name string `json:"name"`
// Peerings defines a list of peerings of the newly created virtual network with existing virtual networks.
// +optional
Peerings VnetPeerings `json:"peerings,omitempty"`
VnetClassSpec `json:",inline"`
}
// VnetPeeringSpec specifies an existing remote virtual network to peer with the AzureCluster's virtual network.
type VnetPeeringSpec struct {
VnetPeeringClassSpec `json:",inline"`
}
// VnetPeeringClassSpec specifies a virtual network peering class.
type VnetPeeringClassSpec struct {
// ResourceGroup is the resource group name of the remote virtual network.
// +optional
ResourceGroup string `json:"resourceGroup,omitempty"`
// RemoteVnetName defines name of the remote virtual network.
RemoteVnetName string `json:"remoteVnetName"`
// ForwardPeeringProperties specifies VnetPeeringProperties for peering from the cluster's virtual network to the
// remote virtual network.
// +optional
ForwardPeeringProperties VnetPeeringProperties `json:"forwardPeeringProperties,omitempty"`
// ReversePeeringProperties specifies VnetPeeringProperties for peering from the remote virtual network to the
// cluster's virtual network.
// +optional
ReversePeeringProperties VnetPeeringProperties `json:"reversePeeringProperties,omitempty"`
}
// VnetPeeringProperties specifies virtual network peering properties.
type VnetPeeringProperties struct {
// AllowForwardedTraffic specifies whether the forwarded traffic from the VMs in the local virtual network will be
// allowed/disallowed in remote virtual network.
// +optional
AllowForwardedTraffic *bool `json:"allowForwardedTraffic,omitempty"`
// AllowGatewayTransit specifies if gateway links can be used in remote virtual networking to link to this virtual
// network.
// +optional
AllowGatewayTransit *bool `json:"allowGatewayTransit,omitempty"`
// AllowVirtualNetworkAccess specifies whether the VMs in the local virtual network space would be able to access
// the VMs in remote virtual network space.
// +optional
AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,omitempty"`
// UseRemoteGateways specifies if remote gateways can be used on this virtual network.
// If the flag is set to true, and allowGatewayTransit on remote peering is also set to true, the virtual network
// will use the gateways of the remote virtual network for transit. Only one peering can have this flag set to true.
// This flag cannot be set if virtual network already has a gateway.
// +optional
UseRemoteGateways *bool `json:"useRemoteGateways,omitempty"`
}
// VnetPeerings is a slice of VnetPeering.
type VnetPeerings []VnetPeeringSpec
// IsManaged returns true if the vnet is managed.
func (v *VnetSpec) IsManaged(clusterName string) bool {
return v.ID == "" || v.Tags.HasOwned(clusterName)
}
// Subnets is a slice of Subnet.
// +listType=map
// +listMapKey=name
type Subnets []SubnetSpec
// ServiceEndpoints is a slice of string.
// +listType=map
// +listMapKey=service
type ServiceEndpoints []ServiceEndpointSpec
// PrivateEndpoints is a slice of PrivateEndpointSpec.
// +listType=map
// +listMapKey=name
type PrivateEndpoints []PrivateEndpointSpec
// SecurityGroup defines an Azure security group.
type SecurityGroup struct {
// ID is the Azure resource ID of the security group.
// READ-ONLY
// +optional
ID string `json:"id,omitempty"`
Name string `json:"name"`
SecurityGroupClass `json:",inline"`
}
// RouteTable defines an Azure route table.
type RouteTable struct {
// ID is the Azure resource ID of the route table.
// READ-ONLY
// +optional
ID string `json:"id,omitempty"`
Name string `json:"name"`
}
// NatGateway defines an Azure NAT gateway.
// NAT gateway resources are part of Vnet NAT and provide outbound Internet connectivity for subnets of a virtual network.
type NatGateway struct {
// ID is the Azure resource ID of the NAT gateway.
// READ-ONLY
// +optional
ID string `json:"id,omitempty"`
// +optional
NatGatewayIP PublicIPSpec `json:"ip,omitempty"`
NatGatewayClassSpec `json:",inline"`
}
// NatGatewayClassSpec defines a NAT gateway class specification.
type NatGatewayClassSpec struct {
Name string `json:"name"`
}
// SecurityGroupProtocol defines the protocol type for a security group rule.
type SecurityGroupProtocol string
const (
// SecurityGroupProtocolAll is a wildcard for all IP protocols.
SecurityGroupProtocolAll = SecurityGroupProtocol("*")
// SecurityGroupProtocolTCP represents the TCP protocol.
SecurityGroupProtocolTCP = SecurityGroupProtocol("Tcp")
// SecurityGroupProtocolUDP represents the UDP protocol.
SecurityGroupProtocolUDP = SecurityGroupProtocol("Udp")
// SecurityGroupProtocolICMP represents the ICMP protocol.
SecurityGroupProtocolICMP = SecurityGroupProtocol("Icmp")
)
// SecurityRuleDirection defines the direction type for a security group rule.
type SecurityRuleDirection string
const (
// SecurityRuleDirectionInbound defines an ingress security rule.
SecurityRuleDirectionInbound = SecurityRuleDirection("Inbound")
// SecurityRuleDirectionOutbound defines an egress security rule.
SecurityRuleDirectionOutbound = SecurityRuleDirection("Outbound")
)
// SecurityRuleAccess defines the action type for a security group rule.
type SecurityRuleAccess string
const (
// SecurityRuleActionAllow allows traffic defined in the rule.
SecurityRuleActionAllow SecurityRuleAccess = "Allow"
// SecurityRuleActionDeny denies traffic defined in the rule.
SecurityRuleActionDeny SecurityRuleAccess = "Deny"
)
// SecurityRule defines an Azure security rule for security groups.
type SecurityRule struct {
// Name is a unique name within the network security group.
Name string `json:"name"`
// A description for this rule. Restricted to 140 chars.
Description string `json:"description"`
// Protocol specifies the protocol type. "Tcp", "Udp", "Icmp", or "*".
// +kubebuilder:validation:Enum=Tcp;Udp;Icmp;*
Protocol SecurityGroupProtocol `json:"protocol"`
// Direction indicates whether the rule applies to inbound, or outbound traffic. "Inbound" or "Outbound".
// +kubebuilder:validation:Enum=Inbound;Outbound
Direction SecurityRuleDirection `json:"direction"`
// Priority is a number between 100 and 4096. Each rule should have a unique value for priority. Rules are processed in priority order, with lower numbers processed before higher numbers. Once traffic matches a rule, processing stops.
// +optional
Priority int32 `json:"priority,omitempty"`
// SourcePorts specifies source port or range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports.
// +optional
SourcePorts *string `json:"sourcePorts,omitempty"`
// DestinationPorts specifies the destination port or range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports.
// +optional
DestinationPorts *string `json:"destinationPorts,omitempty"`
// Source specifies the CIDR or source IP range. Asterix '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. If this is an ingress rule, specifies where network traffic originates from.
// +optional
Source *string `json:"source,omitempty"`
// Sources specifies The CIDR or source IP ranges.
Sources []*string `json:"sources,omitempty"`
// Destination is the destination address prefix. CIDR or destination IP range. Asterix '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used.
// +optional
Destination *string `json:"destination,omitempty"`
// Action specifies whether network traffic is allowed or denied. Can either be "Allow" or "Deny". Defaults to "Allow".
// +kubebuilder:default=Allow
// +kubebuilder:validation:Enum=Allow;Deny
//+optional
Action SecurityRuleAccess `json:"action"`
}
// SecurityRules is a slice of Azure security rules for security groups.
// +listType=map
// +listMapKey=name
type SecurityRules []SecurityRule
// LoadBalancerSpec defines an Azure load balancer.
type LoadBalancerSpec struct {
// ID is the Azure resource ID of the load balancer.
// READ-ONLY
// +optional
ID string `json:"id,omitempty"`
// +optional
Name string `json:"name,omitempty"`
// +optional
FrontendIPs []FrontendIP `json:"frontendIPs,omitempty"`
// FrontendIPsCount specifies the number of frontend IP addresses for the load balancer.
// +optional
FrontendIPsCount *int32 `json:"frontendIPsCount,omitempty"`
// BackendPool describes the backend pool of the load balancer.
// +optional
BackendPool BackendPool `json:"backendPool,omitempty"`
LoadBalancerClassSpec `json:",inline"`
}
// SKU defines an Azure load balancer SKU.
type SKU string
const (
// SKUStandard is the value for the Azure load balancer Standard SKU.
SKUStandard = SKU("Standard")
)
// LBType defines an Azure load balancer Type.
type LBType string
const (
// Internal is the value for the Azure load balancer internal type.
Internal = LBType("Internal")
// Public is the value for the Azure load balancer public type.
Public = LBType("Public")
)
// FrontendIP defines a load balancer frontend IP configuration.
type FrontendIP struct {
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// +optional
PublicIP *PublicIPSpec `json:"publicIP,omitempty"`
FrontendIPClass `json:",inline"`
}
// PublicIPSpec defines the inputs to create an Azure public IP address.
type PublicIPSpec struct {
Name string `json:"name"`
// +optional
DNSName string `json:"dnsName,omitempty"`
// +optional
IPTags []IPTag `json:"ipTags,omitempty"`
}
// IPTag contains the IpTag associated with the object.
type IPTag struct {
// Type specifies the IP tag type. Example: FirstPartyUsage.
Type string `json:"type"`
// Tag specifies the value of the IP tag associated with the public IP. Example: SQL.
Tag string `json:"tag"`
}
// VMState describes the state of an Azure virtual machine.
// Deprecated: use ProvisioningState.
type VMState string
// ProvisioningState describes the provisioning state of an Azure resource.
type ProvisioningState string
const (
// Creating ...
Creating ProvisioningState = "Creating"
// Deleting ...
Deleting ProvisioningState = "Deleting"
// Failed ...
Failed ProvisioningState = "Failed"
// Migrating ...
Migrating ProvisioningState = "Migrating"
// Succeeded ...
Succeeded ProvisioningState = "Succeeded"
// Updating ...
Updating ProvisioningState = "Updating"
// Canceled represents an action which was initiated but terminated by the user before completion.
Canceled ProvisioningState = "Canceled"
// Deleted represents a deleted VM
// NOTE: This state is specific to capz, and does not have corresponding mapping in Azure API (https://learn.microsoft.com/azure/virtual-machines/states-billing#provisioning-states)
Deleted ProvisioningState = "Deleted"
)
// Image defines information about the image to use for VM creation.
// There are three ways to specify an image: by ID, Marketplace Image or SharedImageGallery
// One of ID, SharedImage or Marketplace should be set.
type Image struct {
// ID specifies an image to use by ID
// +optional
ID *string `json:"id,omitempty"`
// SharedGallery specifies an image to use from an Azure Shared Image Gallery
// Deprecated: use ComputeGallery instead.
// +optional
SharedGallery *AzureSharedGalleryImage `json:"sharedGallery,omitempty"`
// Marketplace specifies an image to use from the Azure Marketplace
// +optional
Marketplace *AzureMarketplaceImage `json:"marketplace,omitempty"`
// ComputeGallery specifies an image to use from the Azure Compute Gallery
// +optional
ComputeGallery *AzureComputeGalleryImage `json:"computeGallery,omitempty"`
}
// AzureComputeGalleryImage defines an image in the Azure Compute Gallery to use for VM creation.
type AzureComputeGalleryImage struct {
// Gallery specifies the name of the compute image gallery that contains the image
// +kubebuilder:validation:MinLength=1
Gallery string `json:"gallery"`
// Name is the name of the image
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// Version specifies the version of the marketplace image. The allowed formats
// are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers.
// Specify 'latest' to use the latest version of an image available at deploy time.
// Even if you use 'latest', the VM image will not automatically update after deploy
// time even if a new version becomes available.
// +kubebuilder:validation:MinLength=1
Version string `json:"version"`
// SubscriptionID is the identifier of the subscription that contains the private compute gallery.
// +optional
SubscriptionID *string `json:"subscriptionID,omitempty"`
// ResourceGroup specifies the resource group containing the private compute gallery.
// +optional
ResourceGroup *string `json:"resourceGroup,omitempty"`
// Plan contains plan information.
// +optional
Plan *ImagePlan `json:"plan,omitempty"`
}
// ImagePlan contains plan information for marketplace images.
type ImagePlan struct {
// Publisher is the name of the organization that created the image
// +kubebuilder:validation:MinLength=1
Publisher string `json:"publisher"`
// Offer specifies the name of a group of related images created by the publisher.
// For example, UbuntuServer, WindowsServer
// +kubebuilder:validation:MinLength=1
Offer string `json:"offer"`
// SKU specifies an instance of an offer, such as a major release of a distribution.
// For example, 18.04-LTS, 2019-Datacenter
// +kubebuilder:validation:MinLength=1
SKU string `json:"sku"`
}
// AzureMarketplaceImage defines an image in the Azure Marketplace to use for VM creation.
type AzureMarketplaceImage struct {
ImagePlan `json:",inline"`
// Version specifies the version of an image sku. The allowed formats
// are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers.
// Specify 'latest' to use the latest version of an image available at deploy time.
// Even if you use 'latest', the VM image will not automatically update after deploy
// time even if a new version becomes available.
// +kubebuilder:validation:MinLength=1
Version string `json:"version"`
// ThirdPartyImage indicates the image is published by a third party publisher and a Plan
// will be generated for it.
// +kubebuilder:default=false
// +optional
ThirdPartyImage bool `json:"thirdPartyImage"`
}
// AzureSharedGalleryImage defines an image in a Shared Image Gallery to use for VM creation.
type AzureSharedGalleryImage struct {
// SubscriptionID is the identifier of the subscription that contains the shared image gallery
// +kubebuilder:validation:MinLength=1
SubscriptionID string `json:"subscriptionID"`
// ResourceGroup specifies the resource group containing the shared image gallery
// +kubebuilder:validation:MinLength=1
ResourceGroup string `json:"resourceGroup"`
// Gallery specifies the name of the shared image gallery that contains the image
// +kubebuilder:validation:MinLength=1
Gallery string `json:"gallery"`
// Name is the name of the image
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// Version specifies the version of the marketplace image. The allowed formats
// are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers.
// Specify 'latest' to use the latest version of an image available at deploy time.
// Even if you use 'latest', the VM image will not automatically update after deploy
// time even if a new version becomes available.
// +kubebuilder:validation:MinLength=1
Version string `json:"version"`
// Publisher is the name of the organization that created the image.
// This value will be used to add a `Plan` in the API request when creating the VM/VMSS resource.
// This is needed when the source image from which this SIG image was built requires the `Plan` to be used.
// +optional
Publisher *string `json:"publisher,omitempty"`
// Offer specifies the name of a group of related images created by the publisher.
// For example, UbuntuServer, WindowsServer
// This value will be used to add a `Plan` in the API request when creating the VM/VMSS resource.
// This is needed when the source image from which this SIG image was built requires the `Plan` to be used.
// +optional
Offer *string `json:"offer,omitempty"`
// SKU specifies an instance of an offer, such as a major release of a distribution.
// For example, 18.04-LTS, 2019-Datacenter
// This value will be used to add a `Plan` in the API request when creating the VM/VMSS resource.
// This is needed when the source image from which this SIG image was built requires the `Plan` to be used.
// +optional
SKU *string `json:"sku,omitempty"`
}
// VMIdentity defines the identity of the virtual machine, if configured.
// +kubebuilder:validation:Enum=None;SystemAssigned;UserAssigned
type VMIdentity string
const (
// VMIdentityNone ...
VMIdentityNone VMIdentity = "None"
// VMIdentitySystemAssigned ...
VMIdentitySystemAssigned VMIdentity = "SystemAssigned"
// VMIdentityUserAssigned ...
VMIdentityUserAssigned VMIdentity = "UserAssigned"
)
// SpotEvictionPolicy defines the eviction policy for spot VMs, if configured.
// +kubebuilder:validation:Enum=Deallocate;Delete
type SpotEvictionPolicy string
const (
// SpotEvictionPolicyDeallocate is the default eviction policy and will deallocate the VM when the node is marked for eviction.
SpotEvictionPolicyDeallocate SpotEvictionPolicy = "Deallocate"
// SpotEvictionPolicyDelete will delete the VM when the node is marked for eviction.
SpotEvictionPolicyDelete SpotEvictionPolicy = "Delete"
)
// UserAssignedIdentity defines the user-assigned identities provided
// by the user to be assigned to Azure resources.
type UserAssignedIdentity struct {
// ProviderID is the identification ID of the user-assigned Identity, the format of an identity is:
// 'azure:///subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'
ProviderID string `json:"providerID"`
}
// IdentityType represents different types of identities.
// +kubebuilder:validation:Enum=ServicePrincipal;UserAssignedMSI;ManualServicePrincipal;ServicePrincipalCertificate;WorkloadIdentity
type IdentityType string
const (
// UserAssignedMSI represents a user-assigned managed identity.
UserAssignedMSI IdentityType = "UserAssignedMSI"
// ServicePrincipal represents a service principal using a client password as secret.
ServicePrincipal IdentityType = "ServicePrincipal"
// ManualServicePrincipal represents a manual service principal.
ManualServicePrincipal IdentityType = "ManualServicePrincipal"
// ServicePrincipalCertificate represents a service principal using a certificate as secret.
ServicePrincipalCertificate IdentityType = "ServicePrincipalCertificate"
// WorkloadIdentity represents a WorkloadIdentity.
WorkloadIdentity IdentityType = "WorkloadIdentity"
)
// OSDisk defines the operating system disk for a VM.
//
// WARNING: this requires any updates to ManagedDisk to be manually converted. This is due to the odd issue with
// conversion-gen where the warning message generated uses a relative directory import rather than the fully
// qualified import when generating outside of the GOPATH.
type OSDisk struct {
OSType string `json:"osType"`
// DiskSizeGB is the size in GB to assign to the OS disk.
// Will have a default of 30GB if not provided
// +optional
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk specifies the Managed Disk parameters for the OS disk.
// +optional
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
// +optional
DiffDiskSettings *DiffDiskSettings `json:"diffDiskSettings,omitempty"`
// CachingType specifies the caching requirements.
// +optional
// +kubebuilder:validation:Enum=None;ReadOnly;ReadWrite
CachingType string `json:"cachingType,omitempty"`
}
// DataDisk specifies the parameters that are used to add one or more data disks to the machine.
type DataDisk struct {
// NameSuffix is the suffix to be appended to the machine name to generate the disk name.
// Each disk name will be in format <machineName>_<nameSuffix>.
NameSuffix string `json:"nameSuffix"`
// DiskSizeGB is the size in GB to assign to the data disk.
DiskSizeGB int32 `json:"diskSizeGB"`
// ManagedDisk specifies the Managed Disk parameters for the data disk.
// +optional
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
// Lun Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM.
// The value must be between 0 and 63.
// +optional
Lun *int32 `json:"lun,omitempty"`
// CachingType specifies the caching requirements.
// +optional
// +kubebuilder:validation:Enum=None;ReadOnly;ReadWrite
CachingType string `json:"cachingType,omitempty"`
}
// VMExtension specifies the parameters for a custom VM extension.
type VMExtension struct {
// Name is the name of the extension.
Name string `json:"name"`
// Publisher is the name of the extension handler publisher.
Publisher string `json:"publisher"`
// Version specifies the version of the script handler.
Version string `json:"version"`
// Settings is a JSON formatted public settings for the extension.
// +optional
Settings Tags `json:"settings,omitempty"`
// ProtectedSettings is a JSON formatted protected settings for the extension.
// +optional
ProtectedSettings Tags `json:"protectedSettings,omitempty"`
}
// ManagedDiskParameters defines the parameters of a managed disk.
type ManagedDiskParameters struct {
// +optional
StorageAccountType string `json:"storageAccountType,omitempty"`
// DiskEncryptionSet specifies the customer-managed disk encryption set resource id for the managed disk.
// +optional
DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"`
// SecurityProfile specifies the security profile for the managed disk.
// +optional
SecurityProfile *VMDiskSecurityProfile `json:"securityProfile,omitempty"`
}
// VMDiskSecurityProfile specifies the security profile settings for the managed disk.
// It can be set only for Confidential VMs.
type VMDiskSecurityProfile struct {
// DiskEncryptionSet specifies the customer-managed disk encryption set resource id for the
// managed disk that is used for Customer Managed Key encrypted ConfidentialVM OS Disk and
// VMGuest blob.
// +optional
DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"`
// SecurityEncryptionType specifies the encryption type of the managed disk.
// It is set to DiskWithVMGuestState to encrypt the managed disk along with the VMGuestState
// blob, and to VMGuestStateOnly to encrypt the VMGuestState blob only.
// When set to VMGuestStateOnly, VirtualizedTrustedPlatformModule should be set to Enabled.
// When set to DiskWithVMGuestState, EncryptionAtHost should be disabled, SecureBoot and
// VirtualizedTrustedPlatformModule should be set to Enabled.
// It can be set only for Confidential VMs.
// +kubebuilder:validation:Enum=VMGuestStateOnly;DiskWithVMGuestState
// +optional
SecurityEncryptionType SecurityEncryptionType `json:"securityEncryptionType,omitempty"`
}
// DiskEncryptionSetParameters defines disk encryption options.
type DiskEncryptionSetParameters struct {
// ID defines resourceID for diskEncryptionSet resource. It must be in the same subscription
// +optional
ID string `json:"id,omitempty"`
}
// DiffDiskPlacement - Specifies the ephemeral disk placement for operating system disk. This property can be used by user
// in the request to choose the location i.e, cache disk, resource disk or nvme disk space for
// Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer Ephemeral OS
// disk size requirements for Windows VM at
// https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements and Linux VM at
// https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements.
type DiffDiskPlacement string
const (
// DiffDiskPlacementCacheDisk places the OsDisk on cache disk.
DiffDiskPlacementCacheDisk DiffDiskPlacement = "CacheDisk"
// DiffDiskPlacementNvmeDisk places the OsDisk on NVMe disk.
DiffDiskPlacementNvmeDisk DiffDiskPlacement = "NvmeDisk"
// DiffDiskPlacementResourceDisk places the OsDisk on temp disk.
DiffDiskPlacementResourceDisk DiffDiskPlacement = "ResourceDisk"
)
// PossibleDiffDiskPlacementValues returns the possible values for the DiffDiskPlacement const type.
func PossibleDiffDiskPlacementValues() []DiffDiskPlacement {
return []DiffDiskPlacement{
DiffDiskPlacementCacheDisk,
DiffDiskPlacementNvmeDisk,
DiffDiskPlacementResourceDisk,
}
}
// DiffDiskSettings describe ephemeral disk settings for the os disk.
type DiffDiskSettings struct {
// Option enables ephemeral OS when set to "Local"
// See https://learn.microsoft.com/azure/virtual-machines/ephemeral-os-disks for full details
// +kubebuilder:validation:Enum=Local
Option string `json:"option"`
// Placement specifies the ephemeral disk placement for operating system disk. If placement is specified, Option must be set to "Local".
// +kubebuilder:validation:Enum=CacheDisk;NvmeDisk;ResourceDisk
// +optional
Placement *DiffDiskPlacement `json:"placement,omitempty"`
}
// SubnetRole defines the unique role of a subnet.
type SubnetRole string
const (
// SubnetNode defines a Kubernetes workload node role.
SubnetNode = SubnetRole(Node)
// SubnetControlPlane defines a Kubernetes control plane node role.
SubnetControlPlane = SubnetRole(ControlPlane)
// SubnetBastion defines a Bastion subnet role.
SubnetBastion = SubnetRole(Bastion)
// SubnetCluster defines a role that can be used for both Kubernetes control plane node and Kubernetes workload node.
SubnetCluster = SubnetRole(Cluster)
)
// SubnetSpec configures an Azure subnet.
type SubnetSpec struct {
// ID is the Azure resource ID of the subnet.
// READ-ONLY
// +optional
ID string `json:"id,omitempty"`
// SecurityGroup defines the NSG (network security group) that should be attached to this subnet.
// +optional
SecurityGroup SecurityGroup `json:"securityGroup,omitempty"`
// RouteTable defines the route table that should be attached to this subnet.
// +optional
RouteTable RouteTable `json:"routeTable,omitempty"`
// NatGateway associated with this subnet.
// +optional
NatGateway NatGateway `json:"natGateway,omitempty"`
SubnetClassSpec `json:",inline"`
}
// ServiceEndpointSpec configures an Azure Service Endpoint.
type ServiceEndpointSpec struct {
Service string `json:"service"`
Locations []string `json:"locations"`
}
// PrivateLinkServiceConnection defines the specification for a private link service connection associated with a private endpoint.
type PrivateLinkServiceConnection struct {
// Name specifies the name of the private link service.
// +optional
Name string `json:"name,omitempty"`
// PrivateLinkServiceID specifies the resource ID of the private link service.
PrivateLinkServiceID string `json:"privateLinkServiceID,omitempty"`
// GroupIDs specifies the ID(s) of the group(s) obtained from the remote resource that this private endpoint should connect to.
// +optional
GroupIDs []string `json:"groupIDs,omitempty"`
// RequestMessage specifies a message passed to the owner of the remote resource with the private endpoint connection request.
// +kubebuilder:validation:MaxLength=140
// +optional
RequestMessage string `json:"requestMessage,omitempty"`
}
// PrivateEndpointSpec configures an Azure Private Endpoint.
type PrivateEndpointSpec struct {
// Name specifies the name of the private endpoint.
Name string `json:"name"`
// Location specifies the region to create the private endpoint.
// +optional
Location string `json:"location,omitempty"`
// PrivateLinkServiceConnections specifies Private Link Service Connections of the private endpoint.
PrivateLinkServiceConnections []PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"`
// CustomNetworkInterfaceName specifies the network interface name associated with the private endpoint.
// +optional
CustomNetworkInterfaceName string `json:"customNetworkInterfaceName,omitempty"`
// PrivateIPAddresses specifies the IP addresses for the network interface associated with the private endpoint.
// They have to be part of the subnet where the private endpoint is linked.
// +optional
PrivateIPAddresses []string `json:"privateIPAddresses,omitempty"`
// ApplicationSecurityGroups specifies the Application security group in which the private endpoint IP configuration is included.
// +optional
ApplicationSecurityGroups []string `json:"applicationSecurityGroups,omitempty"`
// ManualApproval specifies if the connection approval needs to be done manually or not.
// Set it true when the network admin does not have access to approve connections to the remote resource.
// Defaults to false.
// +optional
ManualApproval bool `json:"manualApproval,omitempty"`
}
// NetworkInterface defines a network interface.
type NetworkInterface struct {
// SubnetName specifies the subnet in which the new network interface will be placed.
SubnetName string `json:"subnetName,omitempty"`
// PrivateIPConfigs specifies the number of private IP addresses to attach to the interface.
// Defaults to 1 if not specified.
// +optional
PrivateIPConfigs int `json:"privateIPConfigs,omitempty"`
// AcceleratedNetworking enables or disables Azure accelerated networking. If omitted, it will be set based on
// whether the requested VMSize supports accelerated networking.
// If AcceleratedNetworking is set to true with a VMSize that does not support it, Azure will return an error.
// +kubebuilder:validation:nullable
// +optional
AcceleratedNetworking *bool `json:"acceleratedNetworking,omitempty"`
}
// GetControlPlaneSubnet returns a subnet that has a role assigned to controlplane or all. Subnets with role controlplane are given higher priority.
func (n *NetworkSpec) GetControlPlaneSubnet() (SubnetSpec, error) {
// Priority is given for subnet that have role assigned as controlplane
if subnet, err := n.GetSubnet(SubnetControlPlane); err == nil {
return subnet, nil
}
if subnet, err := n.GetSubnet(SubnetCluster); err == nil {
return subnet, nil
}
return SubnetSpec{}, errors.Errorf("no subnet found with role %s", SubnetControlPlane)
}
// GetSubnet returns a subnet based on the subnet role.
func (n *NetworkSpec) GetSubnet(role SubnetRole) (SubnetSpec, error) {
for _, sn := range n.Subnets {
if sn.Role == role {
return sn, nil
}
}
return SubnetSpec{}, errors.Errorf("no subnet found with role %s", role)
}
// UpdateControlPlaneSubnet updates the cluster control plane subnets.
func (n *NetworkSpec) UpdateControlPlaneSubnet(subnet SubnetSpec) {
n.UpdateSubnet(subnet, SubnetControlPlane)
n.UpdateSubnet(subnet, SubnetCluster)
}
// UpdateSubnet updates the subnet based on the subnet role.
func (n *NetworkSpec) UpdateSubnet(subnet SubnetSpec, role SubnetRole) {
for i, sn := range n.Subnets {
if sn.Role == role {
n.Subnets[i] = subnet
}
}
}
// IsNatGatewayEnabled returns whether or not a NAT gateway is enabled on the subnet.
func (s SubnetSpec) IsNatGatewayEnabled() bool {
return s.NatGateway.Name != ""
}
// IsIPv6Enabled returns whether or not IPv6 is enabled on the subnet.
func (s SubnetSpec) IsIPv6Enabled() bool {
for _, cidr := range s.CIDRBlocks {
if net.IsIPv6CIDRString(cidr) {
return true
}
}
return false
}
// SecurityProfile specifies the Security profile settings for a
// virtual machine or virtual machine scale set.
type SecurityProfile struct {
// This field indicates whether Host Encryption should be enabled
// or disabled for a virtual machine or virtual machine scale set.
// This should be disabled when SecurityEncryptionType is set to DiskWithVMGuestState.
// Default is disabled.
// +optional
EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"`
// SecurityType specifies the SecurityType of the virtual machine. It has to be set to any specified value to
// enable UefiSettings. The default behavior is: UefiSettings will not be enabled unless this property is set.
// +kubebuilder:validation:Enum=ConfidentialVM;TrustedLaunch
// +optional
SecurityType SecurityTypes `json:"securityType,omitempty"`
// UefiSettings specifies the security settings like secure boot and vTPM used while creating the virtual machine.
// +optional
UefiSettings *UefiSettings `json:"uefiSettings,omitempty"`
}
// UefiSettings specifies the security settings like secure boot and vTPM used while creating the virtual
// machine.
// +optional
type UefiSettings struct {
// SecureBootEnabled specifies whether secure boot should be enabled on the virtual machine.
// Secure Boot verifies the digital signature of all boot components and halts the boot process if signature verification fails.
// If omitted, the platform chooses a default, which is subject to change over time, currently that default is false.
//+optional
SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"`
// VTpmEnabled specifies whether vTPM should be enabled on the virtual machine.
// When true it enables the virtualized trusted platform module measurements to create a known good boot integrity policy baseline.
// The integrity policy baseline is used for comparison with measurements from subsequent VM boots to determine if anything has changed.
// This is required to be set to Enabled if SecurityEncryptionType is defined.
// If omitted, the platform chooses a default, which is subject to change over time, currently that default is false.
// +optional
VTpmEnabled *bool `json:"vTpmEnabled,omitempty"`
}
// AddressRecord specifies a DNS record mapping a hostname to an IPV4 or IPv6 address.
type AddressRecord struct {
Hostname string
IP string
}
// CloudProviderConfigOverrides represents the fields that can be overridden in azure cloud provider config.
type CloudProviderConfigOverrides struct {
// +optional
RateLimits []RateLimitSpec `json:"rateLimits,omitempty"`
// +optional
BackOffs BackOffConfig `json:"backOffs,omitempty"`
}
// BackOffConfig indicates the back-off config options.
type BackOffConfig struct {
// +optional
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
// +optional
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
// +optional
CloudProviderBackoffExponent *resource.Quantity `json:"cloudProviderBackoffExponent,omitempty"`
// +optional
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
// +optional
CloudProviderBackoffJitter *resource.Quantity `json:"cloudProviderBackoffJitter,omitempty"`
}
// RateLimitSpec represents the rate limit configuration for a particular kind of resource.
// Eg. loadBalancerRateLimit is used to configure rate limits for load balancers.
// This eventually gets converted to CloudProviderRateLimitConfig that cloud-provider-azure expects.
// See: https://github.com/kubernetes-sigs/cloud-provider-azure/blob/d585c2031925b39c925624302f22f8856e29e352/pkg/provider/azure_ratelimit.go#L25
// We cannot use CloudProviderRateLimitConfig directly because floating point values are not supported in controller-tools.
// See: https://github.com/kubernetes-sigs/controller-tools/issues/245
type RateLimitSpec struct {
// Name is the name of the rate limit spec.
// +kubebuilder:validation:Enum=defaultRateLimit;routeRateLimit;subnetsRateLimit;interfaceRateLimit;routeTableRateLimit;loadBalancerRateLimit;publicIPAddressRateLimit;securityGroupRateLimit;virtualMachineRateLimit;storageAccountRateLimit;diskRateLimit;snapshotRateLimit;virtualMachineScaleSetRateLimit;virtualMachineSizesRateLimit;availabilitySetRateLimit
Name string `json:"name"`
// +optional
Config RateLimitConfig `json:"config,omitempty"`
}
// RateLimitConfig indicates the rate limit config options.
type RateLimitConfig struct {
// +optional
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
// +optional
CloudProviderRateLimitQPS *resource.Quantity `json:"cloudProviderRateLimitQPS,omitempty"`
// +optional
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
// +optional
CloudProviderRateLimitQPSWrite *resource.Quantity `json:"cloudProviderRateLimitQPSWrite,omitempty"`
// +optional
CloudProviderRateLimitBucketWrite int `json:"cloudProviderRateLimitBucketWrite,omitempty"`
}
const (
// DefaultRateLimit ...
DefaultRateLimit = "defaultRateLimit"
// RouteRateLimit ...
RouteRateLimit = "routeRateLimit"
// SubnetsRateLimit ...
SubnetsRateLimit = "subnetsRateLimit"
// InterfaceRateLimit ...
InterfaceRateLimit = "interfaceRateLimit"
// RouteTableRateLimit ...
RouteTableRateLimit = "routeTableRateLimit"
// LoadBalancerRateLimit ...
LoadBalancerRateLimit = "loadBalancerRateLimit"
// PublicIPAddressRateLimit ...
PublicIPAddressRateLimit = "publicIPAddressRateLimit"
// SecurityGroupRateLimit ...
SecurityGroupRateLimit = "securityGroupRateLimit"