sigs.k8s.io/cluster-api-provider-azure@v1.14.3/api/v1beta1/types.go (about)

     1  /*
     2  Copyright 2021 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1beta1
    18  
    19  import (
    20  	"github.com/pkg/errors"
    21  	"k8s.io/apimachinery/pkg/api/resource"
    22  	"k8s.io/utils/net"
    23  )
    24  
    25  const (
    26  	// ControlPlane machine label.
    27  	ControlPlane string = "control-plane"
    28  	// Node machine label.
    29  	Node string = "node"
    30  	// Bastion subnet label.
    31  	Bastion string = "bastion"
    32  	// Cluster subnet label.
    33  	Cluster string = "cluster"
    34  )
    35  
    36  // SecurityEncryptionType represents the Encryption Type when the virtual machine is a
    37  // Confidential VM.
    38  type SecurityEncryptionType string
    39  
    40  const (
    41  	// SecurityEncryptionTypeVMGuestStateOnly disables OS disk confidential encryption.
    42  	SecurityEncryptionTypeVMGuestStateOnly SecurityEncryptionType = "VMGuestStateOnly"
    43  	// SecurityEncryptionTypeDiskWithVMGuestState OS disk confidential encryption with a
    44  	// platform-managed key (PMK) or a customer-managed key (CMK).
    45  	SecurityEncryptionTypeDiskWithVMGuestState SecurityEncryptionType = "DiskWithVMGuestState"
    46  )
    47  
    48  // SecurityTypes represents the SecurityType of the virtual machine.
    49  type SecurityTypes string
    50  
    51  const (
    52  	// SecurityTypesConfidentialVM defines the SecurityType of the virtual machine as a Confidential VM.
    53  	SecurityTypesConfidentialVM SecurityTypes = "ConfidentialVM"
    54  	// SecurityTypesTrustedLaunch defines the SecurityType of the virtual machine as a Trusted Launch VM.
    55  	SecurityTypesTrustedLaunch SecurityTypes = "TrustedLaunch"
    56  )
    57  
    58  // Futures is a slice of Future.
    59  type Futures []Future
    60  
    61  const (
    62  	// PatchFuture is a future that was derived from a PATCH request.
    63  	PatchFuture string = "PATCH"
    64  	// PutFuture is a future that was derived from a PUT request.
    65  	PutFuture string = "PUT"
    66  	// DeleteFuture is a future that was derived from a DELETE request.
    67  	DeleteFuture string = "DELETE"
    68  )
    69  
    70  // Future contains the data needed for an Azure long-running operation to continue across reconcile loops.
    71  type Future struct {
    72  	// Type describes the type of future, such as update, create, delete, etc.
    73  	Type string `json:"type"`
    74  
    75  	// ResourceGroup is the Azure resource group for the resource.
    76  	// +optional
    77  	ResourceGroup string `json:"resourceGroup,omitempty"`
    78  
    79  	// ServiceName is the name of the Azure service.
    80  	// Together with the name of the resource, this forms the unique identifier for the future.
    81  	ServiceName string `json:"serviceName"`
    82  
    83  	// Name is the name of the Azure resource.
    84  	// Together with the service name, this forms the unique identifier for the future.
    85  	Name string `json:"name"`
    86  
    87  	// Data is the base64 url encoded json Azure AutoRest Future.
    88  	Data string `json:"data"`
    89  }
    90  
    91  // NetworkSpec specifies what the Azure networking resources should look like.
    92  type NetworkSpec struct {
    93  	// Vnet is the configuration for the Azure virtual network.
    94  	// +optional
    95  	Vnet VnetSpec `json:"vnet,omitempty"`
    96  
    97  	// Subnets is the configuration for the control-plane subnet and the node subnet.
    98  	// +optional
    99  	Subnets Subnets `json:"subnets,omitempty"`
   100  
   101  	// APIServerLB is the configuration for the control-plane load balancer.
   102  	// +optional
   103  	APIServerLB LoadBalancerSpec `json:"apiServerLB,omitempty"`
   104  
   105  	// NodeOutboundLB is the configuration for the node outbound load balancer.
   106  	// +optional
   107  	NodeOutboundLB *LoadBalancerSpec `json:"nodeOutboundLB,omitempty"`
   108  
   109  	// ControlPlaneOutboundLB is the configuration for the control-plane outbound load balancer.
   110  	// This is different from APIServerLB, and is used only in private clusters (optionally) for enabling outbound traffic.
   111  	// +optional
   112  	ControlPlaneOutboundLB *LoadBalancerSpec `json:"controlPlaneOutboundLB,omitempty"`
   113  
   114  	NetworkClassSpec `json:",inline"`
   115  }
   116  
   117  // VnetSpec configures an Azure virtual network.
   118  type VnetSpec struct {
   119  	// ResourceGroup is the name of the resource group of the existing virtual network
   120  	// or the resource group where a managed virtual network should be created.
   121  	// +optional
   122  	ResourceGroup string `json:"resourceGroup,omitempty"`
   123  
   124  	// ID is the Azure resource ID of the virtual network.
   125  	// READ-ONLY
   126  	// +optional
   127  	ID string `json:"id,omitempty"`
   128  
   129  	// Name defines a name for the virtual network resource.
   130  	Name string `json:"name"`
   131  
   132  	// Peerings defines a list of peerings of the newly created virtual network with existing virtual networks.
   133  	// +optional
   134  	Peerings VnetPeerings `json:"peerings,omitempty"`
   135  
   136  	VnetClassSpec `json:",inline"`
   137  }
   138  
   139  // VnetPeeringSpec specifies an existing remote virtual network to peer with the AzureCluster's virtual network.
   140  type VnetPeeringSpec struct {
   141  	VnetPeeringClassSpec `json:",inline"`
   142  }
   143  
   144  // VnetPeeringClassSpec specifies a virtual network peering class.
   145  type VnetPeeringClassSpec struct {
   146  	// ResourceGroup is the resource group name of the remote virtual network.
   147  	// +optional
   148  	ResourceGroup string `json:"resourceGroup,omitempty"`
   149  
   150  	// RemoteVnetName defines name of the remote virtual network.
   151  	RemoteVnetName string `json:"remoteVnetName"`
   152  
   153  	// ForwardPeeringProperties specifies VnetPeeringProperties for peering from the cluster's virtual network to the
   154  	// remote virtual network.
   155  	// +optional
   156  	ForwardPeeringProperties VnetPeeringProperties `json:"forwardPeeringProperties,omitempty"`
   157  
   158  	// ReversePeeringProperties specifies VnetPeeringProperties for peering from the remote virtual network to the
   159  	// cluster's virtual network.
   160  	// +optional
   161  	ReversePeeringProperties VnetPeeringProperties `json:"reversePeeringProperties,omitempty"`
   162  }
   163  
   164  // VnetPeeringProperties specifies virtual network peering properties.
   165  type VnetPeeringProperties struct {
   166  	// AllowForwardedTraffic specifies whether the forwarded traffic from the VMs in the local virtual network will be
   167  	// allowed/disallowed in remote virtual network.
   168  	// +optional
   169  	AllowForwardedTraffic *bool `json:"allowForwardedTraffic,omitempty"`
   170  
   171  	// AllowGatewayTransit specifies if gateway links can be used in remote virtual networking to link to this virtual
   172  	// network.
   173  	// +optional
   174  	AllowGatewayTransit *bool `json:"allowGatewayTransit,omitempty"`
   175  
   176  	// AllowVirtualNetworkAccess specifies whether the VMs in the local virtual network space would be able to access
   177  	// the VMs in remote virtual network space.
   178  	// +optional
   179  	AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,omitempty"`
   180  
   181  	// UseRemoteGateways specifies if remote gateways can be used on this virtual network.
   182  	// If the flag is set to true, and allowGatewayTransit on remote peering is also set to true, the virtual network
   183  	// will use the gateways of the remote virtual network for transit. Only one peering can have this flag set to true.
   184  	// This flag cannot be set if virtual network already has a gateway.
   185  	// +optional
   186  	UseRemoteGateways *bool `json:"useRemoteGateways,omitempty"`
   187  }
   188  
   189  // VnetPeerings is a slice of VnetPeering.
   190  type VnetPeerings []VnetPeeringSpec
   191  
   192  // IsManaged returns true if the vnet is managed.
   193  func (v *VnetSpec) IsManaged(clusterName string) bool {
   194  	return v.ID == "" || v.Tags.HasOwned(clusterName)
   195  }
   196  
   197  // Subnets is a slice of Subnet.
   198  // +listType=map
   199  // +listMapKey=name
   200  type Subnets []SubnetSpec
   201  
   202  // ServiceEndpoints is a slice of string.
   203  // +listType=map
   204  // +listMapKey=service
   205  type ServiceEndpoints []ServiceEndpointSpec
   206  
   207  // PrivateEndpoints is a slice of PrivateEndpointSpec.
   208  // +listType=map
   209  // +listMapKey=name
   210  type PrivateEndpoints []PrivateEndpointSpec
   211  
   212  // SecurityGroup defines an Azure security group.
   213  type SecurityGroup struct {
   214  	// ID is the Azure resource ID of the security group.
   215  	// READ-ONLY
   216  	// +optional
   217  	ID   string `json:"id,omitempty"`
   218  	Name string `json:"name"`
   219  
   220  	SecurityGroupClass `json:",inline"`
   221  }
   222  
   223  // RouteTable defines an Azure route table.
   224  type RouteTable struct {
   225  	// ID is the Azure resource ID of the route table.
   226  	// READ-ONLY
   227  	// +optional
   228  	ID   string `json:"id,omitempty"`
   229  	Name string `json:"name"`
   230  }
   231  
   232  // NatGateway defines an Azure NAT gateway.
   233  // NAT gateway resources are part of Vnet NAT and provide outbound Internet connectivity for subnets of a virtual network.
   234  type NatGateway struct {
   235  	// ID is the Azure resource ID of the NAT gateway.
   236  	// READ-ONLY
   237  	// +optional
   238  	ID string `json:"id,omitempty"`
   239  	// +optional
   240  	NatGatewayIP PublicIPSpec `json:"ip,omitempty"`
   241  
   242  	NatGatewayClassSpec `json:",inline"`
   243  }
   244  
   245  // NatGatewayClassSpec defines a NAT gateway class specification.
   246  type NatGatewayClassSpec struct {
   247  	Name string `json:"name"`
   248  }
   249  
   250  // SecurityGroupProtocol defines the protocol type for a security group rule.
   251  type SecurityGroupProtocol string
   252  
   253  const (
   254  	// SecurityGroupProtocolAll is a wildcard for all IP protocols.
   255  	SecurityGroupProtocolAll = SecurityGroupProtocol("*")
   256  	// SecurityGroupProtocolTCP represents the TCP protocol.
   257  	SecurityGroupProtocolTCP = SecurityGroupProtocol("Tcp")
   258  	// SecurityGroupProtocolUDP represents the UDP protocol.
   259  	SecurityGroupProtocolUDP = SecurityGroupProtocol("Udp")
   260  	// SecurityGroupProtocolICMP represents the ICMP protocol.
   261  	SecurityGroupProtocolICMP = SecurityGroupProtocol("Icmp")
   262  )
   263  
   264  // SecurityRuleDirection defines the direction type for a security group rule.
   265  type SecurityRuleDirection string
   266  
   267  const (
   268  	// SecurityRuleDirectionInbound defines an ingress security rule.
   269  	SecurityRuleDirectionInbound = SecurityRuleDirection("Inbound")
   270  
   271  	// SecurityRuleDirectionOutbound defines an egress security rule.
   272  	SecurityRuleDirectionOutbound = SecurityRuleDirection("Outbound")
   273  )
   274  
   275  // SecurityRuleAccess defines the action type for a security group rule.
   276  type SecurityRuleAccess string
   277  
   278  const (
   279  	// SecurityRuleActionAllow allows traffic defined in the rule.
   280  	SecurityRuleActionAllow SecurityRuleAccess = "Allow"
   281  
   282  	// SecurityRuleActionDeny denies traffic defined in the rule.
   283  	SecurityRuleActionDeny SecurityRuleAccess = "Deny"
   284  )
   285  
   286  // SecurityRule defines an Azure security rule for security groups.
   287  type SecurityRule struct {
   288  	// Name is a unique name within the network security group.
   289  	Name string `json:"name"`
   290  	// A description for this rule. Restricted to 140 chars.
   291  	Description string `json:"description"`
   292  	// Protocol specifies the protocol type. "Tcp", "Udp", "Icmp", or "*".
   293  	// +kubebuilder:validation:Enum=Tcp;Udp;Icmp;*
   294  	Protocol SecurityGroupProtocol `json:"protocol"`
   295  	// Direction indicates whether the rule applies to inbound, or outbound traffic. "Inbound" or "Outbound".
   296  	// +kubebuilder:validation:Enum=Inbound;Outbound
   297  	Direction SecurityRuleDirection `json:"direction"`
   298  	// 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.
   299  	// +optional
   300  	Priority int32 `json:"priority,omitempty"`
   301  	// SourcePorts specifies source port or range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports.
   302  	// +optional
   303  	SourcePorts *string `json:"sourcePorts,omitempty"`
   304  	// DestinationPorts specifies the destination port or range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports.
   305  	// +optional
   306  	DestinationPorts *string `json:"destinationPorts,omitempty"`
   307  	// 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.
   308  	// +optional
   309  	Source *string `json:"source,omitempty"`
   310  	// Sources specifies The CIDR or source IP ranges.
   311  	Sources []*string `json:"sources,omitempty"`
   312  	// 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.
   313  	// +optional
   314  	Destination *string `json:"destination,omitempty"`
   315  	// Action specifies whether network traffic is allowed or denied. Can either be "Allow" or "Deny". Defaults to "Allow".
   316  	// +kubebuilder:default=Allow
   317  	// +kubebuilder:validation:Enum=Allow;Deny
   318  	//+optional
   319  	Action SecurityRuleAccess `json:"action"`
   320  }
   321  
   322  // SecurityRules is a slice of Azure security rules for security groups.
   323  // +listType=map
   324  // +listMapKey=name
   325  type SecurityRules []SecurityRule
   326  
   327  // LoadBalancerSpec defines an Azure load balancer.
   328  type LoadBalancerSpec struct {
   329  	// ID is the Azure resource ID of the load balancer.
   330  	// READ-ONLY
   331  	// +optional
   332  	ID string `json:"id,omitempty"`
   333  	// +optional
   334  	Name string `json:"name,omitempty"`
   335  	// +optional
   336  	FrontendIPs []FrontendIP `json:"frontendIPs,omitempty"`
   337  	// FrontendIPsCount specifies the number of frontend IP addresses for the load balancer.
   338  	// +optional
   339  	FrontendIPsCount *int32 `json:"frontendIPsCount,omitempty"`
   340  	// BackendPool describes the backend pool of the load balancer.
   341  	// +optional
   342  	BackendPool BackendPool `json:"backendPool,omitempty"`
   343  
   344  	LoadBalancerClassSpec `json:",inline"`
   345  }
   346  
   347  // SKU defines an Azure load balancer SKU.
   348  type SKU string
   349  
   350  const (
   351  	// SKUStandard is the value for the Azure load balancer Standard SKU.
   352  	SKUStandard = SKU("Standard")
   353  )
   354  
   355  // LBType defines an Azure load balancer Type.
   356  type LBType string
   357  
   358  const (
   359  	// Internal is the value for the Azure load balancer internal type.
   360  	Internal = LBType("Internal")
   361  	// Public is the value for the Azure load balancer public type.
   362  	Public = LBType("Public")
   363  )
   364  
   365  // FrontendIP defines a load balancer frontend IP configuration.
   366  type FrontendIP struct {
   367  	// +kubebuilder:validation:MinLength=1
   368  	Name string `json:"name"`
   369  	// +optional
   370  	PublicIP *PublicIPSpec `json:"publicIP,omitempty"`
   371  
   372  	FrontendIPClass `json:",inline"`
   373  }
   374  
   375  // PublicIPSpec defines the inputs to create an Azure public IP address.
   376  type PublicIPSpec struct {
   377  	Name string `json:"name"`
   378  	// +optional
   379  	DNSName string `json:"dnsName,omitempty"`
   380  	// +optional
   381  	IPTags []IPTag `json:"ipTags,omitempty"`
   382  }
   383  
   384  // IPTag contains the IpTag associated with the object.
   385  type IPTag struct {
   386  	// Type specifies the IP tag type. Example: FirstPartyUsage.
   387  	Type string `json:"type"`
   388  	// Tag specifies the value of the IP tag associated with the public IP. Example: SQL.
   389  	Tag string `json:"tag"`
   390  }
   391  
   392  // VMState describes the state of an Azure virtual machine.
   393  // Deprecated: use ProvisioningState.
   394  type VMState string
   395  
   396  // ProvisioningState describes the provisioning state of an Azure resource.
   397  type ProvisioningState string
   398  
   399  const (
   400  	// Creating ...
   401  	Creating ProvisioningState = "Creating"
   402  	// Deleting ...
   403  	Deleting ProvisioningState = "Deleting"
   404  	// Failed ...
   405  	Failed ProvisioningState = "Failed"
   406  	// Migrating ...
   407  	Migrating ProvisioningState = "Migrating"
   408  	// Succeeded ...
   409  	Succeeded ProvisioningState = "Succeeded"
   410  	// Updating ...
   411  	Updating ProvisioningState = "Updating"
   412  	// Canceled represents an action which was initiated but terminated by the user before completion.
   413  	Canceled ProvisioningState = "Canceled"
   414  	// Deleted represents a deleted VM
   415  	// 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)
   416  	Deleted ProvisioningState = "Deleted"
   417  )
   418  
   419  // Image defines information about the image to use for VM creation.
   420  // There are three ways to specify an image: by ID, Marketplace Image or SharedImageGallery
   421  // One of ID, SharedImage or Marketplace should be set.
   422  type Image struct {
   423  	// ID specifies an image to use by ID
   424  	// +optional
   425  	ID *string `json:"id,omitempty"`
   426  
   427  	// SharedGallery specifies an image to use from an Azure Shared Image Gallery
   428  	// Deprecated: use ComputeGallery instead.
   429  	// +optional
   430  	SharedGallery *AzureSharedGalleryImage `json:"sharedGallery,omitempty"`
   431  
   432  	// Marketplace specifies an image to use from the Azure Marketplace
   433  	// +optional
   434  	Marketplace *AzureMarketplaceImage `json:"marketplace,omitempty"`
   435  
   436  	// ComputeGallery specifies an image to use from the Azure Compute Gallery
   437  	// +optional
   438  	ComputeGallery *AzureComputeGalleryImage `json:"computeGallery,omitempty"`
   439  }
   440  
   441  // AzureComputeGalleryImage defines an image in the Azure Compute Gallery to use for VM creation.
   442  type AzureComputeGalleryImage struct {
   443  	// Gallery specifies the name of the compute image gallery that contains the image
   444  	// +kubebuilder:validation:MinLength=1
   445  	Gallery string `json:"gallery"`
   446  	// Name is the name of the image
   447  	// +kubebuilder:validation:MinLength=1
   448  	Name string `json:"name"`
   449  	// Version specifies the version of the marketplace image. The allowed formats
   450  	// are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers.
   451  	// Specify 'latest' to use the latest version of an image available at deploy time.
   452  	// Even if you use 'latest', the VM image will not automatically update after deploy
   453  	// time even if a new version becomes available.
   454  	// +kubebuilder:validation:MinLength=1
   455  	Version string `json:"version"`
   456  	// SubscriptionID is the identifier of the subscription that contains the private compute gallery.
   457  	// +optional
   458  	SubscriptionID *string `json:"subscriptionID,omitempty"`
   459  	// ResourceGroup specifies the resource group containing the private compute gallery.
   460  	// +optional
   461  	ResourceGroup *string `json:"resourceGroup,omitempty"`
   462  	// Plan contains plan information.
   463  	// +optional
   464  	Plan *ImagePlan `json:"plan,omitempty"`
   465  }
   466  
   467  // ImagePlan contains plan information for marketplace images.
   468  type ImagePlan struct {
   469  	// Publisher is the name of the organization that created the image
   470  	// +kubebuilder:validation:MinLength=1
   471  	Publisher string `json:"publisher"`
   472  	// Offer specifies the name of a group of related images created by the publisher.
   473  	// For example, UbuntuServer, WindowsServer
   474  	// +kubebuilder:validation:MinLength=1
   475  	Offer string `json:"offer"`
   476  	// SKU specifies an instance of an offer, such as a major release of a distribution.
   477  	// For example, 18.04-LTS, 2019-Datacenter
   478  	// +kubebuilder:validation:MinLength=1
   479  	SKU string `json:"sku"`
   480  }
   481  
   482  // AzureMarketplaceImage defines an image in the Azure Marketplace to use for VM creation.
   483  type AzureMarketplaceImage struct {
   484  	ImagePlan `json:",inline"`
   485  
   486  	// Version specifies the version of an image sku. The allowed formats
   487  	// are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers.
   488  	// Specify 'latest' to use the latest version of an image available at deploy time.
   489  	// Even if you use 'latest', the VM image will not automatically update after deploy
   490  	// time even if a new version becomes available.
   491  	// +kubebuilder:validation:MinLength=1
   492  	Version string `json:"version"`
   493  	// ThirdPartyImage indicates the image is published by a third party publisher and a Plan
   494  	// will be generated for it.
   495  	// +kubebuilder:default=false
   496  	// +optional
   497  	ThirdPartyImage bool `json:"thirdPartyImage"`
   498  }
   499  
   500  // AzureSharedGalleryImage defines an image in a Shared Image Gallery to use for VM creation.
   501  type AzureSharedGalleryImage struct {
   502  	// SubscriptionID is the identifier of the subscription that contains the shared image gallery
   503  	// +kubebuilder:validation:MinLength=1
   504  	SubscriptionID string `json:"subscriptionID"`
   505  	// ResourceGroup specifies the resource group containing the shared image gallery
   506  	// +kubebuilder:validation:MinLength=1
   507  	ResourceGroup string `json:"resourceGroup"`
   508  	// Gallery specifies the name of the shared image gallery that contains the image
   509  	// +kubebuilder:validation:MinLength=1
   510  	Gallery string `json:"gallery"`
   511  	// Name is the name of the image
   512  	// +kubebuilder:validation:MinLength=1
   513  	Name string `json:"name"`
   514  	// Version specifies the version of the marketplace image. The allowed formats
   515  	// are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers.
   516  	// Specify 'latest' to use the latest version of an image available at deploy time.
   517  	// Even if you use 'latest', the VM image will not automatically update after deploy
   518  	// time even if a new version becomes available.
   519  	// +kubebuilder:validation:MinLength=1
   520  	Version string `json:"version"`
   521  	// Publisher is the name of the organization that created the image.
   522  	// This value will be used to add a `Plan` in the API request when creating the VM/VMSS resource.
   523  	// This is needed when the source image from which this SIG image was built requires the `Plan` to be used.
   524  	// +optional
   525  	Publisher *string `json:"publisher,omitempty"`
   526  	// Offer specifies the name of a group of related images created by the publisher.
   527  	// For example, UbuntuServer, WindowsServer
   528  	// This value will be used to add a `Plan` in the API request when creating the VM/VMSS resource.
   529  	// This is needed when the source image from which this SIG image was built requires the `Plan` to be used.
   530  	// +optional
   531  	Offer *string `json:"offer,omitempty"`
   532  	// SKU specifies an instance of an offer, such as a major release of a distribution.
   533  	// For example, 18.04-LTS, 2019-Datacenter
   534  	// This value will be used to add a `Plan` in the API request when creating the VM/VMSS resource.
   535  	// This is needed when the source image from which this SIG image was built requires the `Plan` to be used.
   536  	// +optional
   537  	SKU *string `json:"sku,omitempty"`
   538  }
   539  
   540  // VMIdentity defines the identity of the virtual machine, if configured.
   541  // +kubebuilder:validation:Enum=None;SystemAssigned;UserAssigned
   542  type VMIdentity string
   543  
   544  const (
   545  	// VMIdentityNone ...
   546  	VMIdentityNone VMIdentity = "None"
   547  	// VMIdentitySystemAssigned ...
   548  	VMIdentitySystemAssigned VMIdentity = "SystemAssigned"
   549  	// VMIdentityUserAssigned ...
   550  	VMIdentityUserAssigned VMIdentity = "UserAssigned"
   551  )
   552  
   553  // SpotEvictionPolicy defines the eviction policy for spot VMs, if configured.
   554  // +kubebuilder:validation:Enum=Deallocate;Delete
   555  type SpotEvictionPolicy string
   556  
   557  const (
   558  	// SpotEvictionPolicyDeallocate is the default eviction policy and will deallocate the VM when the node is marked for eviction.
   559  	SpotEvictionPolicyDeallocate SpotEvictionPolicy = "Deallocate"
   560  	// SpotEvictionPolicyDelete will delete the VM when the node is marked for eviction.
   561  	SpotEvictionPolicyDelete SpotEvictionPolicy = "Delete"
   562  )
   563  
   564  // UserAssignedIdentity defines the user-assigned identities provided
   565  // by the user to be assigned to Azure resources.
   566  type UserAssignedIdentity struct {
   567  	// ProviderID is the identification ID of the user-assigned Identity, the format of an identity is:
   568  	// 'azure:///subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'
   569  	ProviderID string `json:"providerID"`
   570  }
   571  
   572  // IdentityType represents different types of identities.
   573  // +kubebuilder:validation:Enum=ServicePrincipal;UserAssignedMSI;ManualServicePrincipal;ServicePrincipalCertificate;WorkloadIdentity
   574  type IdentityType string
   575  
   576  const (
   577  	// UserAssignedMSI represents a user-assigned managed identity.
   578  	UserAssignedMSI IdentityType = "UserAssignedMSI"
   579  
   580  	// ServicePrincipal represents a service principal using a client password as secret.
   581  	ServicePrincipal IdentityType = "ServicePrincipal"
   582  
   583  	// ManualServicePrincipal represents a manual service principal.
   584  	ManualServicePrincipal IdentityType = "ManualServicePrincipal"
   585  
   586  	// ServicePrincipalCertificate represents a service principal using a certificate as secret.
   587  	ServicePrincipalCertificate IdentityType = "ServicePrincipalCertificate"
   588  
   589  	// WorkloadIdentity represents a WorkloadIdentity.
   590  	WorkloadIdentity IdentityType = "WorkloadIdentity"
   591  )
   592  
   593  // OSDisk defines the operating system disk for a VM.
   594  //
   595  // WARNING: this requires any updates to ManagedDisk to be manually converted. This is due to the odd issue with
   596  // conversion-gen where the warning message generated uses a relative directory import rather than the fully
   597  // qualified import when generating outside of the GOPATH.
   598  type OSDisk struct {
   599  	OSType string `json:"osType"`
   600  	// DiskSizeGB is the size in GB to assign to the OS disk.
   601  	// Will have a default of 30GB if not provided
   602  	// +optional
   603  	DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
   604  	// ManagedDisk specifies the Managed Disk parameters for the OS disk.
   605  	// +optional
   606  	ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
   607  	// +optional
   608  	DiffDiskSettings *DiffDiskSettings `json:"diffDiskSettings,omitempty"`
   609  	// CachingType specifies the caching requirements.
   610  	// +optional
   611  	// +kubebuilder:validation:Enum=None;ReadOnly;ReadWrite
   612  	CachingType string `json:"cachingType,omitempty"`
   613  }
   614  
   615  // DataDisk specifies the parameters that are used to add one or more data disks to the machine.
   616  type DataDisk struct {
   617  	// NameSuffix is the suffix to be appended to the machine name to generate the disk name.
   618  	// Each disk name will be in format <machineName>_<nameSuffix>.
   619  	NameSuffix string `json:"nameSuffix"`
   620  	// DiskSizeGB is the size in GB to assign to the data disk.
   621  	DiskSizeGB int32 `json:"diskSizeGB"`
   622  	// ManagedDisk specifies the Managed Disk parameters for the data disk.
   623  	// +optional
   624  	ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
   625  	// 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.
   626  	// The value must be between 0 and 63.
   627  	// +optional
   628  	Lun *int32 `json:"lun,omitempty"`
   629  	// CachingType specifies the caching requirements.
   630  	// +optional
   631  	// +kubebuilder:validation:Enum=None;ReadOnly;ReadWrite
   632  	CachingType string `json:"cachingType,omitempty"`
   633  }
   634  
   635  // VMExtension specifies the parameters for a custom VM extension.
   636  type VMExtension struct {
   637  	// Name is the name of the extension.
   638  	Name string `json:"name"`
   639  	// Publisher is the name of the extension handler publisher.
   640  	Publisher string `json:"publisher"`
   641  	// Version specifies the version of the script handler.
   642  	Version string `json:"version"`
   643  	// Settings is a JSON formatted public settings for the extension.
   644  	// +optional
   645  	Settings Tags `json:"settings,omitempty"`
   646  	// ProtectedSettings is a JSON formatted protected settings for the extension.
   647  	// +optional
   648  	ProtectedSettings Tags `json:"protectedSettings,omitempty"`
   649  }
   650  
   651  // ManagedDiskParameters defines the parameters of a managed disk.
   652  type ManagedDiskParameters struct {
   653  	// +optional
   654  	StorageAccountType string `json:"storageAccountType,omitempty"`
   655  	// DiskEncryptionSet specifies the customer-managed disk encryption set resource id for the managed disk.
   656  	// +optional
   657  	DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"`
   658  	// SecurityProfile specifies the security profile for the managed disk.
   659  	// +optional
   660  	SecurityProfile *VMDiskSecurityProfile `json:"securityProfile,omitempty"`
   661  }
   662  
   663  // VMDiskSecurityProfile specifies the security profile settings for the managed disk.
   664  // It can be set only for Confidential VMs.
   665  type VMDiskSecurityProfile struct {
   666  	// DiskEncryptionSet specifies the customer-managed disk encryption set resource id for the
   667  	// managed disk that is used for Customer Managed Key encrypted ConfidentialVM OS Disk and
   668  	// VMGuest blob.
   669  	// +optional
   670  	DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"`
   671  	// SecurityEncryptionType specifies the encryption type of the managed disk.
   672  	// It is set to DiskWithVMGuestState to encrypt the managed disk along with the VMGuestState
   673  	// blob, and to VMGuestStateOnly to encrypt the VMGuestState blob only.
   674  	// When set to VMGuestStateOnly, VirtualizedTrustedPlatformModule should be set to Enabled.
   675  	// When set to DiskWithVMGuestState, EncryptionAtHost should be disabled, SecureBoot and
   676  	// VirtualizedTrustedPlatformModule should be set to Enabled.
   677  	// It can be set only for Confidential VMs.
   678  	// +kubebuilder:validation:Enum=VMGuestStateOnly;DiskWithVMGuestState
   679  	// +optional
   680  	SecurityEncryptionType SecurityEncryptionType `json:"securityEncryptionType,omitempty"`
   681  }
   682  
   683  // DiskEncryptionSetParameters defines disk encryption options.
   684  type DiskEncryptionSetParameters struct {
   685  	// ID defines resourceID for diskEncryptionSet resource. It must be in the same subscription
   686  	// +optional
   687  	ID string `json:"id,omitempty"`
   688  }
   689  
   690  // DiffDiskSettings describe ephemeral disk settings for the os disk.
   691  type DiffDiskSettings struct {
   692  	// Option enables ephemeral OS when set to "Local"
   693  	// See https://learn.microsoft.com/azure/virtual-machines/ephemeral-os-disks for full details
   694  	// +kubebuilder:validation:Enum=Local
   695  	Option string `json:"option"`
   696  }
   697  
   698  // SubnetRole defines the unique role of a subnet.
   699  type SubnetRole string
   700  
   701  const (
   702  	// SubnetNode defines a Kubernetes workload node role.
   703  	SubnetNode = SubnetRole(Node)
   704  
   705  	// SubnetControlPlane defines a Kubernetes control plane node role.
   706  	SubnetControlPlane = SubnetRole(ControlPlane)
   707  
   708  	// SubnetBastion defines a Bastion subnet role.
   709  	SubnetBastion = SubnetRole(Bastion)
   710  
   711  	// SubnetCluster defines a role that can be used for both Kubernetes control plane node and Kubernetes workload node.
   712  	SubnetCluster = SubnetRole(Cluster)
   713  )
   714  
   715  // SubnetSpec configures an Azure subnet.
   716  type SubnetSpec struct {
   717  	// ID is the Azure resource ID of the subnet.
   718  	// READ-ONLY
   719  	// +optional
   720  	ID string `json:"id,omitempty"`
   721  
   722  	// SecurityGroup defines the NSG (network security group) that should be attached to this subnet.
   723  	// +optional
   724  	SecurityGroup SecurityGroup `json:"securityGroup,omitempty"`
   725  
   726  	// RouteTable defines the route table that should be attached to this subnet.
   727  	// +optional
   728  	RouteTable RouteTable `json:"routeTable,omitempty"`
   729  
   730  	// NatGateway associated with this subnet.
   731  	// +optional
   732  	NatGateway NatGateway `json:"natGateway,omitempty"`
   733  
   734  	SubnetClassSpec `json:",inline"`
   735  }
   736  
   737  // ServiceEndpointSpec configures an Azure Service Endpoint.
   738  type ServiceEndpointSpec struct {
   739  	Service string `json:"service"`
   740  
   741  	Locations []string `json:"locations"`
   742  }
   743  
   744  // PrivateLinkServiceConnection defines the specification for a private link service connection associated with a private endpoint.
   745  type PrivateLinkServiceConnection struct {
   746  	// Name specifies the name of the private link service.
   747  	// +optional
   748  	Name string `json:"name,omitempty"`
   749  	// PrivateLinkServiceID specifies the resource ID of the private link service.
   750  	PrivateLinkServiceID string `json:"privateLinkServiceID,omitempty"`
   751  	// GroupIDs specifies the ID(s) of the group(s) obtained from the remote resource that this private endpoint should connect to.
   752  	// +optional
   753  	GroupIDs []string `json:"groupIDs,omitempty"`
   754  	// RequestMessage specifies a message passed to the owner of the remote resource with the private endpoint connection request.
   755  	// +kubebuilder:validation:MaxLength=140
   756  	// +optional
   757  	RequestMessage string `json:"requestMessage,omitempty"`
   758  }
   759  
   760  // PrivateEndpointSpec configures an Azure Private Endpoint.
   761  type PrivateEndpointSpec struct {
   762  	// Name specifies the name of the private endpoint.
   763  	Name string `json:"name"`
   764  	// Location specifies the region to create the private endpoint.
   765  	// +optional
   766  	Location string `json:"location,omitempty"`
   767  	// PrivateLinkServiceConnections specifies Private Link Service Connections of the private endpoint.
   768  	PrivateLinkServiceConnections []PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"`
   769  	// CustomNetworkInterfaceName specifies the network interface name associated with the private endpoint.
   770  	// +optional
   771  	CustomNetworkInterfaceName string `json:"customNetworkInterfaceName,omitempty"`
   772  	// PrivateIPAddresses specifies the IP addresses for the network interface associated with the private endpoint.
   773  	// They have to be part of the subnet where the private endpoint is linked.
   774  	// +optional
   775  	PrivateIPAddresses []string `json:"privateIPAddresses,omitempty"`
   776  	// ApplicationSecurityGroups specifies the Application security group in which the private endpoint IP configuration is included.
   777  	// +optional
   778  	ApplicationSecurityGroups []string `json:"applicationSecurityGroups,omitempty"`
   779  	// ManualApproval specifies if the connection approval needs to be done manually or not.
   780  	// Set it true when the network admin does not have access to approve connections to the remote resource.
   781  	// Defaults to false.
   782  	// +optional
   783  	ManualApproval bool `json:"manualApproval,omitempty"`
   784  }
   785  
   786  // NetworkInterface defines a network interface.
   787  type NetworkInterface struct {
   788  	// SubnetName specifies the subnet in which the new network interface will be placed.
   789  	SubnetName string `json:"subnetName,omitempty"`
   790  
   791  	// PrivateIPConfigs specifies the number of private IP addresses to attach to the interface.
   792  	// Defaults to 1 if not specified.
   793  	// +optional
   794  	PrivateIPConfigs int `json:"privateIPConfigs,omitempty"`
   795  
   796  	// AcceleratedNetworking enables or disables Azure accelerated networking. If omitted, it will be set based on
   797  	// whether the requested VMSize supports accelerated networking.
   798  	// If AcceleratedNetworking is set to true with a VMSize that does not support it, Azure will return an error.
   799  	// +kubebuilder:validation:nullable
   800  	// +optional
   801  	AcceleratedNetworking *bool `json:"acceleratedNetworking,omitempty"`
   802  }
   803  
   804  // GetControlPlaneSubnet returns a subnet that has a role assigned to controlplane or all. Subnets with role controlplane are given higher priority.
   805  func (n *NetworkSpec) GetControlPlaneSubnet() (SubnetSpec, error) {
   806  	// Priority is given for subnet that have role assigned as controlplane
   807  	if subnet, err := n.GetSubnet(SubnetControlPlane); err == nil {
   808  		return subnet, nil
   809  	}
   810  
   811  	if subnet, err := n.GetSubnet(SubnetCluster); err == nil {
   812  		return subnet, nil
   813  	}
   814  
   815  	return SubnetSpec{}, errors.Errorf("no subnet found with role %s", SubnetControlPlane)
   816  }
   817  
   818  // GetSubnet returns a subnet based on the subnet role.
   819  func (n *NetworkSpec) GetSubnet(role SubnetRole) (SubnetSpec, error) {
   820  	for _, sn := range n.Subnets {
   821  		if sn.Role == role {
   822  			return sn, nil
   823  		}
   824  	}
   825  	return SubnetSpec{}, errors.Errorf("no subnet found with role %s", role)
   826  }
   827  
   828  // UpdateControlPlaneSubnet updates the cluster control plane subnets.
   829  func (n *NetworkSpec) UpdateControlPlaneSubnet(subnet SubnetSpec) {
   830  	n.UpdateSubnet(subnet, SubnetControlPlane)
   831  	n.UpdateSubnet(subnet, SubnetCluster)
   832  }
   833  
   834  // UpdateSubnet updates the subnet based on the subnet role.
   835  func (n *NetworkSpec) UpdateSubnet(subnet SubnetSpec, role SubnetRole) {
   836  	for i, sn := range n.Subnets {
   837  		if sn.Role == role {
   838  			n.Subnets[i] = subnet
   839  		}
   840  	}
   841  }
   842  
   843  // IsNatGatewayEnabled returns whether or not a NAT gateway is enabled on the subnet.
   844  func (s SubnetSpec) IsNatGatewayEnabled() bool {
   845  	return s.NatGateway.Name != ""
   846  }
   847  
   848  // IsIPv6Enabled returns whether or not IPv6 is enabled on the subnet.
   849  func (s SubnetSpec) IsIPv6Enabled() bool {
   850  	for _, cidr := range s.CIDRBlocks {
   851  		if net.IsIPv6CIDRString(cidr) {
   852  			return true
   853  		}
   854  	}
   855  	return false
   856  }
   857  
   858  // SecurityProfile specifies the Security profile settings for a
   859  // virtual machine or virtual machine scale set.
   860  type SecurityProfile struct {
   861  	// This field indicates whether Host Encryption should be enabled
   862  	// or disabled for a virtual machine or virtual machine scale set.
   863  	// This should be disabled when SecurityEncryptionType is set to DiskWithVMGuestState.
   864  	// Default is disabled.
   865  	// +optional
   866  	EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"`
   867  	// SecurityType specifies the SecurityType of the virtual machine. It has to be set to any specified value to
   868  	// enable UefiSettings. The default behavior is: UefiSettings will not be enabled unless this property is set.
   869  	// +kubebuilder:validation:Enum=ConfidentialVM;TrustedLaunch
   870  	// +optional
   871  	SecurityType SecurityTypes `json:"securityType,omitempty"`
   872  	// UefiSettings specifies the security settings like secure boot and vTPM used while creating the virtual machine.
   873  	// +optional
   874  	UefiSettings *UefiSettings `json:"uefiSettings,omitempty"`
   875  }
   876  
   877  // UefiSettings specifies the security settings like secure boot and vTPM used while creating the virtual
   878  // machine.
   879  // +optional
   880  type UefiSettings struct {
   881  	// SecureBootEnabled specifies whether secure boot should be enabled on the virtual machine.
   882  	// Secure Boot verifies the digital signature of all boot components and halts the boot process if signature verification fails.
   883  	// If omitted, the platform chooses a default, which is subject to change over time, currently that default is false.
   884  	//+optional
   885  	SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"`
   886  	// VTpmEnabled specifies whether vTPM should be enabled on the virtual machine.
   887  	// When true it enables the virtualized trusted platform module measurements to create a known good boot integrity policy baseline.
   888  	// The integrity policy baseline is used for comparison with measurements from subsequent VM boots to determine if anything has changed.
   889  	// This is required to be set to Enabled if SecurityEncryptionType is defined.
   890  	// If omitted, the platform chooses a default, which is subject to change over time, currently that default is false.
   891  	// +optional
   892  	VTpmEnabled *bool `json:"vTpmEnabled,omitempty"`
   893  }
   894  
   895  // AddressRecord specifies a DNS record mapping a hostname to an IPV4 or IPv6 address.
   896  type AddressRecord struct {
   897  	Hostname string
   898  	IP       string
   899  }
   900  
   901  // CloudProviderConfigOverrides represents the fields that can be overridden in azure cloud provider config.
   902  type CloudProviderConfigOverrides struct {
   903  	// +optional
   904  	RateLimits []RateLimitSpec `json:"rateLimits,omitempty"`
   905  	// +optional
   906  	BackOffs BackOffConfig `json:"backOffs,omitempty"`
   907  }
   908  
   909  // BackOffConfig indicates the back-off config options.
   910  type BackOffConfig struct {
   911  	// +optional
   912  	CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
   913  	// +optional
   914  	CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
   915  	// +optional
   916  	CloudProviderBackoffExponent *resource.Quantity `json:"cloudProviderBackoffExponent,omitempty"`
   917  	// +optional
   918  	CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
   919  	// +optional
   920  	CloudProviderBackoffJitter *resource.Quantity `json:"cloudProviderBackoffJitter,omitempty"`
   921  }
   922  
   923  // RateLimitSpec represents the rate limit configuration for a particular kind of resource.
   924  // Eg. loadBalancerRateLimit is used to configure rate limits for load balancers.
   925  // This eventually gets converted to CloudProviderRateLimitConfig that cloud-provider-azure expects.
   926  // See: https://github.com/kubernetes-sigs/cloud-provider-azure/blob/d585c2031925b39c925624302f22f8856e29e352/pkg/provider/azure_ratelimit.go#L25
   927  // We cannot use CloudProviderRateLimitConfig directly because floating point values are not supported in controller-tools.
   928  // See: https://github.com/kubernetes-sigs/controller-tools/issues/245
   929  type RateLimitSpec struct {
   930  	// Name is the name of the rate limit spec.
   931  	// +kubebuilder:validation:Enum=defaultRateLimit;routeRateLimit;subnetsRateLimit;interfaceRateLimit;routeTableRateLimit;loadBalancerRateLimit;publicIPAddressRateLimit;securityGroupRateLimit;virtualMachineRateLimit;storageAccountRateLimit;diskRateLimit;snapshotRateLimit;virtualMachineScaleSetRateLimit;virtualMachineSizesRateLimit;availabilitySetRateLimit
   932  	Name string `json:"name"`
   933  	// +optional
   934  	Config RateLimitConfig `json:"config,omitempty"`
   935  }
   936  
   937  // RateLimitConfig indicates the rate limit config options.
   938  type RateLimitConfig struct {
   939  	// +optional
   940  	CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
   941  	// +optional
   942  	CloudProviderRateLimitQPS *resource.Quantity `json:"cloudProviderRateLimitQPS,omitempty"`
   943  	// +optional
   944  	CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
   945  	// +optional
   946  	CloudProviderRateLimitQPSWrite *resource.Quantity `json:"cloudProviderRateLimitQPSWrite,omitempty"`
   947  	// +optional
   948  	CloudProviderRateLimitBucketWrite int `json:"cloudProviderRateLimitBucketWrite,omitempty"`
   949  }
   950  
   951  const (
   952  	// DefaultRateLimit ...
   953  	DefaultRateLimit = "defaultRateLimit"
   954  	// RouteRateLimit ...
   955  	RouteRateLimit = "routeRateLimit"
   956  	// SubnetsRateLimit ...
   957  	SubnetsRateLimit = "subnetsRateLimit"
   958  	// InterfaceRateLimit ...
   959  	InterfaceRateLimit = "interfaceRateLimit"
   960  	// RouteTableRateLimit ...
   961  	RouteTableRateLimit = "routeTableRateLimit"
   962  	// LoadBalancerRateLimit ...
   963  	LoadBalancerRateLimit = "loadBalancerRateLimit"
   964  	// PublicIPAddressRateLimit ...
   965  	PublicIPAddressRateLimit = "publicIPAddressRateLimit"
   966  	// SecurityGroupRateLimit ...
   967  	SecurityGroupRateLimit = "securityGroupRateLimit"
   968  	// VirtualMachineRateLimit ...
   969  	VirtualMachineRateLimit = "virtualMachineRateLimit"
   970  	// StorageAccountRateLimit ...
   971  	StorageAccountRateLimit = "storageAccountRateLimit"
   972  	// DiskRateLimit ...
   973  	DiskRateLimit = "diskRateLimit"
   974  	// SnapshotRateLimit ...
   975  	SnapshotRateLimit = "snapshotRateLimit"
   976  	// VirtualMachineScaleSetRateLimit ...
   977  	VirtualMachineScaleSetRateLimit = "virtualMachineScaleSetRateLimit"
   978  	// VirtualMachineSizesRateLimit ...
   979  	VirtualMachineSizesRateLimit = "virtualMachineSizesRateLimit"
   980  	// AvailabilitySetRateLimit ...
   981  	AvailabilitySetRateLimit = "availabilitySetRateLimit"
   982  )
   983  
   984  // BastionHostSkuName is the name of the SKU used to specify the tier of Azure Bastion Host.
   985  type BastionHostSkuName string
   986  
   987  const (
   988  	// BasicBastionHostSku SKU for the Azure Bastion Host.
   989  	BasicBastionHostSku BastionHostSkuName = "Basic"
   990  	// StandardBastionHostSku SKU for the Azure Bastion Host.
   991  	StandardBastionHostSku BastionHostSkuName = "Standard"
   992  )
   993  
   994  // BastionSpec specifies how the Bastion feature should be set up for the cluster.
   995  type BastionSpec struct {
   996  	// +optional
   997  	AzureBastion *AzureBastion `json:"azureBastion,omitempty"`
   998  }
   999  
  1000  // AzureBastion specifies how the Azure Bastion cloud component should be configured.
  1001  type AzureBastion struct {
  1002  	// +optional
  1003  	Name string `json:"name,omitempty"`
  1004  	// +optional
  1005  	Subnet SubnetSpec `json:"subnet,omitempty"`
  1006  	// +optional
  1007  	PublicIP PublicIPSpec `json:"publicIP,omitempty"`
  1008  	// BastionHostSkuName configures the tier of the Azure Bastion Host. Can be either Basic or Standard. Defaults to Basic.
  1009  	// +kubebuilder:default=Basic
  1010  	// +kubebuilder:validation:Enum=Basic;Standard
  1011  	// +optional
  1012  	Sku BastionHostSkuName `json:"sku,omitempty"`
  1013  	// EnableTunneling enables the native client support feature for the Azure Bastion Host. Defaults to false.
  1014  	// +kubebuilder:default=false
  1015  	// +optional
  1016  	EnableTunneling bool `json:"enableTunneling,omitempty"`
  1017  }
  1018  
  1019  // FleetsMember defines the fleets member configuration.
  1020  // See also [AKS doc].
  1021  //
  1022  // [AKS doc]: https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/2023-03-15-preview/fleets/members
  1023  type FleetsMember struct {
  1024  	// Name is the name of the member.
  1025  	// +optional
  1026  	Name string `json:"name,omitempty"`
  1027  
  1028  	FleetsMemberClassSpec `json:",inline"`
  1029  }
  1030  
  1031  // BackendPool describes the backend pool of the load balancer.
  1032  type BackendPool struct {
  1033  	// Name specifies the name of backend pool for the load balancer. If not specified, the default name will
  1034  	// be set, depending on the load balancer role.
  1035  	// +optional
  1036  	Name string `json:"name,omitempty"`
  1037  }
  1038  
  1039  // IsTerminalProvisioningState returns true if the ProvisioningState is a terminal state for an Azure resource.
  1040  func IsTerminalProvisioningState(state ProvisioningState) bool {
  1041  	return state == Failed || state == Succeeded
  1042  }
  1043  
  1044  // Diagnostics is used to configure the diagnostic settings of the virtual machine.
  1045  type Diagnostics struct {
  1046  	// Boot configures the boot diagnostics settings for the virtual machine.
  1047  	// This allows to configure capturing serial output from the virtual machine on boot.
  1048  	// This is useful for debugging software based launch issues.
  1049  	// If not specified then Boot diagnostics (Managed) will be enabled.
  1050  	// +optional
  1051  	Boot *BootDiagnostics `json:"boot,omitempty"`
  1052  }
  1053  
  1054  // BootDiagnostics configures the boot diagnostics settings for the virtual machine.
  1055  // This allows you to configure capturing serial output from the virtual machine on boot.
  1056  // This is useful for debugging software based launch issues.
  1057  // +union
  1058  type BootDiagnostics struct {
  1059  	// StorageAccountType determines if the storage account for storing the diagnostics data
  1060  	// should be disabled (Disabled), provisioned by Azure (Managed) or by the user (UserManaged).
  1061  	// +kubebuilder:validation:Required
  1062  	// +unionDiscriminator
  1063  	StorageAccountType BootDiagnosticsStorageAccountType `json:"storageAccountType"`
  1064  
  1065  	// UserManaged provides a reference to the user-managed storage account.
  1066  	// +optional
  1067  	UserManaged *UserManagedBootDiagnostics `json:"userManaged,omitempty"`
  1068  }
  1069  
  1070  // BootDiagnosticsStorageAccountType defines the list of valid storage account types
  1071  // for the boot diagnostics.
  1072  // +kubebuilder:validation:Enum:="Managed";"UserManaged";"Disabled"
  1073  type BootDiagnosticsStorageAccountType string
  1074  
  1075  const (
  1076  	// DisabledDiagnosticsStorage is used to determine that the diagnostics storage account
  1077  	// should be disabled.
  1078  	DisabledDiagnosticsStorage BootDiagnosticsStorageAccountType = "Disabled"
  1079  
  1080  	// ManagedDiagnosticsStorage is used to determine that the diagnostics storage account
  1081  	// should be provisioned by Azure.
  1082  	ManagedDiagnosticsStorage BootDiagnosticsStorageAccountType = "Managed"
  1083  
  1084  	// UserManagedDiagnosticsStorage is used to determine that the diagnostics storage account
  1085  	// should be provisioned by the User.
  1086  	UserManagedDiagnosticsStorage BootDiagnosticsStorageAccountType = "UserManaged"
  1087  )
  1088  
  1089  // UserManagedBootDiagnostics provides a reference to a user-managed
  1090  // storage account.
  1091  type UserManagedBootDiagnostics struct {
  1092  	// StorageAccountURI is the URI of the user-managed storage account.
  1093  	// The URI typically will be `https://<mystorageaccountname>.blob.core.windows.net/`
  1094  	// but may differ if you are using Azure DNS zone endpoints.
  1095  	// You can find the correct endpoint by looking for the Blob Primary Endpoint in the
  1096  	// endpoints tab in the Azure console or with the CLI by issuing
  1097  	// `az storage account list --query='[].{name: name, "resource group": resourceGroup, "blob endpoint": primaryEndpoints.blob}'`.
  1098  	// +kubebuilder:validation:Required
  1099  	// +kubebuilder:validation:Pattern=`^https://`
  1100  	// +kubebuilder:validation:MaxLength=1024
  1101  	StorageAccountURI string `json:"storageAccountURI"`
  1102  }
  1103  
  1104  // OrchestrationModeType represents the orchestration mode for a Virtual Machine Scale Set backing an AzureMachinePool.
  1105  // +kubebuilder:validation:Enum=Flexible;Uniform
  1106  type OrchestrationModeType string
  1107  
  1108  const (
  1109  	// FlexibleOrchestrationMode treats VMs as individual resources accessible by standard VM APIs.
  1110  	FlexibleOrchestrationMode OrchestrationModeType = "Flexible"
  1111  	// UniformOrchestrationMode treats VMs as identical instances accessible by the VMSS VM API.
  1112  	UniformOrchestrationMode OrchestrationModeType = "Uniform"
  1113  )
  1114  
  1115  // ExtensionPlan represents the plan for an AKS marketplace extension.
  1116  type ExtensionPlan struct {
  1117  	// Name is the user-defined name of the 3rd Party Artifact that is being procured.
  1118  	// +optional
  1119  	Name string `json:"name,omitempty"`
  1120  
  1121  	// Product is the name of the 3rd Party artifact that is being procured.
  1122  	// +optional
  1123  	Product string `json:"product,omitempty"`
  1124  
  1125  	// PromotionCode is a publisher-provided promotion code as provisioned in Data Market for the said product/artifact.
  1126  	// +optional
  1127  	PromotionCode string `json:"promotionCode,omitempty"`
  1128  
  1129  	// Publisher is the name of the publisher of the 3rd Party Artifact that is being bought.
  1130  	// +optional
  1131  	Publisher string `json:"publisher,omitempty"`
  1132  
  1133  	// Version is the version of the plan.
  1134  	// +optional
  1135  	Version string `json:"version,omitempty"`
  1136  }
  1137  
  1138  // ExtensionScope defines the scope of the AKS marketplace extension, if configured.
  1139  type ExtensionScope struct {
  1140  	// ScopeType is the scope of the extension. It can be either Cluster or Namespace, but not both.
  1141  	ScopeType ExtensionScopeType `json:"scopeType"`
  1142  
  1143  	// ReleaseNamespace is the namespace where the extension Release must be placed, for a Cluster-scoped extension.
  1144  	// Required for Cluster-scoped extensions.
  1145  	// +optional
  1146  	ReleaseNamespace string `json:"releaseNamespace,omitempty"`
  1147  
  1148  	// TargetNamespace is the namespace where the extension will be created for a Namespace-scoped extension.
  1149  	// Required for Namespace-scoped extensions.
  1150  	// +optional
  1151  	TargetNamespace string `json:"targetNamespace,omitempty"`
  1152  }
  1153  
  1154  // ExtensionScopeType defines the scope type of the AKS marketplace extension, if configured.
  1155  // +kubebuilder:validation:Enum=Cluster;Namespace
  1156  type ExtensionScopeType string
  1157  
  1158  const (
  1159  	// ExtensionScopeCluster ...
  1160  	ExtensionScopeCluster ExtensionScopeType = "Cluster"
  1161  	// ExtensionScopeNamespace ...
  1162  	ExtensionScopeNamespace ExtensionScopeType = "Namespace"
  1163  )
  1164  
  1165  // ExtensionIdentity defines the identity of the AKS marketplace extension, if configured.
  1166  // +kubebuilder:validation:Enum=SystemAssigned
  1167  type ExtensionIdentity string
  1168  
  1169  const (
  1170  	// ExtensionIdentitySystemAssigned ...
  1171  	ExtensionIdentitySystemAssigned ExtensionIdentity = "SystemAssigned"
  1172  )
  1173  
  1174  // AKSAssignedIdentity defines the AKS assigned-identity of the aks marketplace extension, if configured.
  1175  // +kubebuilder:validation:Enum=SystemAssigned;UserAssigned
  1176  type AKSAssignedIdentity string
  1177  
  1178  const (
  1179  	// AKSAssignedIdentitySystemAssigned ...
  1180  	AKSAssignedIdentitySystemAssigned AKSAssignedIdentity = "SystemAssigned"
  1181  
  1182  	// AKSAssignedIdentityUserAssigned ...
  1183  	AKSAssignedIdentityUserAssigned AKSAssignedIdentity = "UserAssigned"
  1184  )