1 package v1beta1 2 3 import ( 4 corev1 "k8s.io/api/core/v1" 5 "k8s.io/apimachinery/pkg/api/resource" 6 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 7 ) 8 9 // AzureMachineProviderSpec is the type that will be embedded in a Machine.Spec.ProviderSpec field 10 // for an Azure virtual machine. It is used by the Azure machine actuator to create a single Machine. 11 // Required parameters such as location that are not specified by this configuration, will be defaulted 12 // by the actuator. 13 // Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer). 14 // +openshift:compatibility-gen:level=2 15 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 16 type AzureMachineProviderSpec struct { 17 metav1.TypeMeta `json:",inline"` 18 // +optional 19 metav1.ObjectMeta `json:"metadata,omitempty"` 20 // UserDataSecret contains a local reference to a secret that contains the 21 // UserData to apply to the instance 22 // +optional 23 UserDataSecret *corev1.SecretReference `json:"userDataSecret,omitempty"` 24 // CredentialsSecret is a reference to the secret with Azure credentials. 25 // +optional 26 CredentialsSecret *corev1.SecretReference `json:"credentialsSecret,omitempty"` 27 // Location is the region to use to create the instance 28 // +optional 29 Location string `json:"location,omitempty"` 30 // VMSize is the size of the VM to create. 31 // +optional 32 VMSize string `json:"vmSize,omitempty"` 33 // Image is the OS image to use to create the instance. 34 Image Image `json:"image"` 35 // OSDisk represents the parameters for creating the OS disk. 36 OSDisk OSDisk `json:"osDisk"` 37 // DataDisk specifies the parameters that are used to add one or more data disks to the machine. 38 // +optional 39 DataDisks []DataDisk `json:"dataDisks,omitempty"` 40 // SSHPublicKey is the public key to use to SSH to the virtual machine. 41 // +optional 42 SSHPublicKey string `json:"sshPublicKey,omitempty"` 43 // PublicIP if true a public IP will be used 44 PublicIP bool `json:"publicIP"` 45 // Tags is a list of tags to apply to the machine. 46 // +optional 47 Tags map[string]string `json:"tags,omitempty"` 48 // Network Security Group that needs to be attached to the machine's interface. 49 // No security group will be attached if empty. 50 // +optional 51 SecurityGroup string `json:"securityGroup,omitempty"` 52 // Application Security Groups that need to be attached to the machine's interface. 53 // No application security groups will be attached if zero-length. 54 // +optional 55 ApplicationSecurityGroups []string `json:"applicationSecurityGroups,omitempty"` 56 // Subnet to use for this instance 57 Subnet string `json:"subnet"` 58 // PublicLoadBalancer to use for this instance 59 // +optional 60 PublicLoadBalancer string `json:"publicLoadBalancer,omitempty"` 61 // InternalLoadBalancerName to use for this instance 62 // +optional 63 InternalLoadBalancer string `json:"internalLoadBalancer,omitempty"` 64 // NatRule to set inbound NAT rule of the load balancer 65 // +optional 66 NatRule *int64 `json:"natRule,omitempty"` 67 // ManagedIdentity to set managed identity name 68 // +optional 69 ManagedIdentity string `json:"managedIdentity,omitempty"` 70 // Vnet to set virtual network name 71 // +optional 72 Vnet string `json:"vnet,omitempty"` 73 // Availability Zone for the virtual machine. 74 // If nil, the virtual machine should be deployed to no zone 75 // +optional 76 Zone *string `json:"zone,omitempty"` 77 // NetworkResourceGroup is the resource group for the virtual machine's network 78 // +optional 79 NetworkResourceGroup string `json:"networkResourceGroup,omitempty"` 80 // ResourceGroup is the resource group for the virtual machine 81 // +optional 82 ResourceGroup string `json:"resourceGroup,omitempty"` 83 // SpotVMOptions allows the ability to specify the Machine should use a Spot VM 84 // +optional 85 SpotVMOptions *SpotVMOptions `json:"spotVMOptions,omitempty"` 86 // SecurityProfile specifies the Security profile settings for a virtual machine. 87 // +optional 88 SecurityProfile *SecurityProfile `json:"securityProfile,omitempty"` 89 // UltraSSDCapability enables or disables Azure UltraSSD capability for a virtual machine. 90 // This can be used to allow/disallow binding of Azure UltraSSD to the Machine both as Data Disks or via Persistent Volumes. 91 // This Azure feature is subject to a specific scope and certain limitations. 92 // More informations on this can be found in the official Azure documentation for Ultra Disks: 93 // (https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd?tabs=azure-portal#ga-scope-and-limitations). 94 // 95 // When omitted, if at least one Data Disk of type UltraSSD is specified, the platform will automatically enable the capability. 96 // If a Perisistent Volume backed by an UltraSSD is bound to a Pod on the Machine, when this field is ommitted, the platform will *not* automatically enable the capability (unless already enabled by the presence of an UltraSSD as Data Disk). 97 // This may manifest in the Pod being stuck in `ContainerCreating` phase. 98 // This defaulting behaviour may be subject to change in future. 99 // 100 // When set to "Enabled", if the capability is available for the Machine based on the scope and limitations described above, the capability will be set on the Machine. 101 // This will thus allow UltraSSD both as Data Disks and Persistent Volumes. 102 // If set to "Enabled" when the capability can't be available due to scope and limitations, the Machine will go into "Failed" state. 103 // 104 // When set to "Disabled", UltraSSDs will not be allowed either as Data Disks nor as Persistent Volumes. 105 // In this case if any UltraSSDs are specified as Data Disks on a Machine, the Machine will go into a "Failed" state. 106 // If instead any UltraSSDs are backing the volumes (via Persistent Volumes) of any Pods scheduled on a Node which is backed by the Machine, the Pod may get stuck in `ContainerCreating` phase. 107 // 108 // +kubebuilder:validation:Enum:="Enabled";"Disabled" 109 // +optional 110 UltraSSDCapability AzureUltraSSDCapabilityState `json:"ultraSSDCapability,omitempty"` 111 // AcceleratedNetworking enables or disables Azure accelerated networking feature. 112 // Set to false by default. If true, then this will depend on whether the requested 113 // VMSize is supported. If set to true with an unsupported VMSize, Azure will return an error. 114 // +optional 115 AcceleratedNetworking bool `json:"acceleratedNetworking,omitempty"` 116 // AvailabilitySet specifies the availability set to use for this instance. 117 // Availability set should be precreated, before using this field. 118 // +optional 119 AvailabilitySet string `json:"availabilitySet,omitempty"` 120 // Diagnostics configures the diagnostics settings for the virtual machine. 121 // This allows you to configure boot diagnostics such as capturing serial output from 122 // the virtual machine on boot. 123 // This is useful for debugging software based launch issues. 124 // +optional 125 Diagnostics AzureDiagnostics `json:"diagnostics,omitempty"` 126 } 127 128 // SpotVMOptions defines the options relevant to running the Machine on Spot VMs 129 type SpotVMOptions struct { 130 // MaxPrice defines the maximum price the user is willing to pay for Spot VM instances 131 // +optional 132 MaxPrice *resource.Quantity `json:"maxPrice,omitempty"` 133 } 134 135 // AzureDiagnostics is used to configure the diagnostic settings of the virtual machine. 136 type AzureDiagnostics struct { 137 // AzureBootDiagnostics configures the boot diagnostics settings for the virtual machine. 138 // This allows you to configure capturing serial output from the virtual machine on boot. 139 // This is useful for debugging software based launch issues. 140 // + This is a pointer so that we can validate required fields only when the structure is 141 // + configured by the user. 142 // +optional 143 Boot *AzureBootDiagnostics `json:"boot,omitempty"` 144 } 145 146 // AzureBootDiagnostics configures the boot diagnostics settings for the virtual machine. 147 // This allows you to configure capturing serial output from the virtual machine on boot. 148 // This is useful for debugging software based launch issues. 149 // +union 150 type AzureBootDiagnostics struct { 151 // StorageAccountType determines if the storage account for storing the diagnostics data 152 // should be provisioned by Azure (AzureManaged) or by the customer (CustomerManaged). 153 // +kubebuilder:validation:Required 154 // +unionDiscriminator 155 StorageAccountType AzureBootDiagnosticsStorageAccountType `json:"storageAccountType"` 156 157 // CustomerManaged provides reference to the customer manager storage account. 158 // +optional 159 CustomerManaged *AzureCustomerManagedBootDiagnostics `json:"customerManaged,omitempty"` 160 } 161 162 // AzureCustomerManagedBootDiagnostics provides reference to a customer managed 163 // storage account. 164 type AzureCustomerManagedBootDiagnostics struct { 165 // StorageAccountURI is the URI of the customer managed storage account. 166 // The URI typically will be `https://<mystorageaccountname>.blob.core.windows.net/` 167 // but may differ if you are using Azure DNS zone endpoints. 168 // You can find the correct endpoint by looking for the Blob Primary Endpoint in the 169 // endpoints tab in the Azure console. 170 // +kubebuilder:validation:Required 171 // +kubebuilder:validation:Pattern=`^https://` 172 // +kubebuilder:validation:MaxLength=1024 173 StorageAccountURI string `json:"storageAccountURI"` 174 } 175 176 // AzureBootDiagnosticsStorageAccountType defines the list of valid storage account types 177 // for the boot diagnostics. 178 // +kubebuilder:validation:Enum:="AzureManaged";"CustomerManaged" 179 type AzureBootDiagnosticsStorageAccountType string 180 181 const ( 182 // AzureManagedAzureDiagnosticsStorage is used to determine that the diagnostics storage account 183 // should be provisioned by Azure. 184 AzureManagedAzureDiagnosticsStorage AzureBootDiagnosticsStorageAccountType = "AzureManaged" 185 186 // CustomerManagedAzureDiagnosticsStorage is used to determine that the diagnostics storage account 187 // should be provisioned by the Customer. 188 CustomerManagedAzureDiagnosticsStorage AzureBootDiagnosticsStorageAccountType = "CustomerManaged" 189 ) 190 191 // AzureMachineProviderStatus is the type that will be embedded in a Machine.Status.ProviderStatus field. 192 // It contains Azure-specific status information. 193 // Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer). 194 // +openshift:compatibility-gen:level=2 195 type AzureMachineProviderStatus struct { 196 metav1.TypeMeta `json:",inline"` 197 // +optional 198 metav1.ObjectMeta `json:"metadata,omitempty"` 199 // VMID is the ID of the virtual machine created in Azure. 200 // +optional 201 VMID *string `json:"vmId,omitempty"` 202 // VMState is the provisioning state of the Azure virtual machine. 203 // +optional 204 VMState *AzureVMState `json:"vmState,omitempty"` 205 // Conditions is a set of conditions associated with the Machine to indicate 206 // errors or other status. 207 // +optional 208 Conditions []metav1.Condition `json:"conditions,omitempty"` 209 } 210 211 // VMState describes the state of an Azure virtual machine. 212 type AzureVMState string 213 214 const ( 215 // ProvisioningState related values 216 // VMStateCreating ... 217 VMStateCreating = AzureVMState("Creating") 218 // VMStateDeleting ... 219 VMStateDeleting = AzureVMState("Deleting") 220 // VMStateFailed ... 221 VMStateFailed = AzureVMState("Failed") 222 // VMStateMigrating ... 223 VMStateMigrating = AzureVMState("Migrating") 224 // VMStateSucceeded ... 225 VMStateSucceeded = AzureVMState("Succeeded") 226 // VMStateUpdating ... 227 VMStateUpdating = AzureVMState("Updating") 228 229 // PowerState related values 230 // VMStateStarting ... 231 VMStateStarting = AzureVMState("Starting") 232 // VMStateRunning ... 233 VMStateRunning = AzureVMState("Running") 234 // VMStateStopping ... 235 VMStateStopping = AzureVMState("Stopping") 236 // VMStateStopped ... 237 VMStateStopped = AzureVMState("Stopped") 238 // VMStateDeallocating ... 239 VMStateDeallocating = AzureVMState("Deallocating") 240 // VMStateDeallocated ... 241 VMStateDeallocated = AzureVMState("Deallocated") 242 // VMStateUnknown ... 243 VMStateUnknown = AzureVMState("Unknown") 244 ) 245 246 // Image is a mirror of azure sdk compute.ImageReference 247 type Image struct { 248 // Publisher is the name of the organization that created the image 249 Publisher string `json:"publisher"` 250 // Offer specifies the name of a group of related images created by the publisher. 251 // For example, UbuntuServer, WindowsServer 252 Offer string `json:"offer"` 253 // SKU specifies an instance of an offer, such as a major release of a distribution. 254 // For example, 18.04-LTS, 2019-Datacenter 255 SKU string `json:"sku"` 256 // Version specifies the version of an image sku. The allowed formats 257 // are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. 258 // Specify 'latest' to use the latest version of an image available at deploy time. 259 // Even if you use 'latest', the VM image will not automatically update after deploy 260 // time even if a new version becomes available. 261 Version string `json:"version"` 262 // ResourceID specifies an image to use by ID 263 ResourceID string `json:"resourceID"` 264 // Type identifies the source of the image and related information, such as purchase plans. 265 // Valid values are "ID", "MarketplaceWithPlan", "MarketplaceNoPlan", and omitted, which 266 // means no opinion and the platform chooses a good default which may change over time. 267 // Currently that default is "MarketplaceNoPlan" if publisher data is supplied, or "ID" if not. 268 // For more information about purchase plans, see: 269 // https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage#check-the-purchase-plan-information 270 // +optional 271 Type AzureImageType `json:"type,omitempty"` 272 } 273 274 // AzureImageType provides an enumeration for the valid image types. 275 type AzureImageType string 276 277 const ( 278 // AzureImageTypeID specifies that the image should be referenced by its resource ID. 279 AzureImageTypeID AzureImageType = "ID" 280 // AzureImageTypeMarketplaceNoPlan are images available from the marketplace that do not require a purchase plan. 281 AzureImageTypeMarketplaceNoPlan AzureImageType = "MarketplaceNoPlan" 282 // AzureImageTypeMarketplaceWithPlan require a purchase plan. Upstream these images are referred to as "ThirdParty." 283 AzureImageTypeMarketplaceWithPlan AzureImageType = "MarketplaceWithPlan" 284 ) 285 286 type OSDisk struct { 287 // OSType is the operating system type of the OS disk. Possible values include "Linux" and "Windows". 288 OSType string `json:"osType"` 289 // ManagedDisk specifies the Managed Disk parameters for the OS disk. 290 ManagedDisk OSDiskManagedDiskParameters `json:"managedDisk"` 291 // DiskSizeGB is the size in GB to assign to the data disk. 292 DiskSizeGB int32 `json:"diskSizeGB"` 293 // DiskSettings describe ephemeral disk settings for the os disk. 294 // +optional 295 DiskSettings DiskSettings `json:"diskSettings,omitempty"` 296 // CachingType specifies the caching requirements. 297 // Possible values include: 'None', 'ReadOnly', 'ReadWrite'. 298 // Empty value means no opinion and the platform chooses a default, which is subject to change over 299 // time. Currently the default is `None`. 300 // +optional 301 // +kubebuilder:validation:Enum=None;ReadOnly;ReadWrite 302 CachingType string `json:"cachingType,omitempty"` 303 } 304 305 // DataDisk specifies the parameters that are used to add one or more data disks to the machine. 306 // A Data Disk is a managed disk that's attached to a virtual machine to store application data. 307 // It differs from an OS Disk as it doesn't come with a pre-installed OS, and it cannot contain the boot volume. 308 // It is registered as SCSI drive and labeled with the chosen `lun`. e.g. for `lun: 0` the raw disk device will be available at `/dev/disk/azure/scsi1/lun0`. 309 // 310 // As the Data Disk disk device is attached raw to the virtual machine, it will need to be partitioned, formatted with a filesystem and mounted, in order for it to be usable. 311 // This can be done by creating a custom userdata Secret with custom Ignition configuration to achieve the desired initialization. 312 // At this stage the previously defined `lun` is to be used as the "device" key for referencing the raw disk device to be initialized. 313 // Once the custom userdata Secret has been created, it can be referenced in the Machine's `.providerSpec.userDataSecret`. 314 // For further guidance and examples, please refer to the official OpenShift docs. 315 type DataDisk struct { 316 // NameSuffix is the suffix to be appended to the machine name to generate the disk name. 317 // Each disk name will be in format <machineName>_<nameSuffix>. 318 // NameSuffix name must start and finish with an alphanumeric character and can only contain letters, numbers, underscores, periods or hyphens. 319 // The overall disk name must not exceed 80 chars in length. 320 // +kubebuilder:validation:Pattern:=`^[a-zA-Z0-9](?:[\w\.-]*[a-zA-Z0-9])?$` 321 // +kubebuilder:validation:MaxLength:=78 322 // +kubebuilder:validation:Required 323 NameSuffix string `json:"nameSuffix"` 324 // DiskSizeGB is the size in GB to assign to the data disk. 325 // +kubebuilder:validation:Minimum=4 326 // +kubebuilder:validation:Required 327 DiskSizeGB int32 `json:"diskSizeGB"` 328 // ManagedDisk specifies the Managed Disk parameters for the data disk. 329 // Empty value means no opinion and the platform chooses a default, which is subject to change over time. 330 // Currently the default is a ManagedDisk with with storageAccountType: "Premium_LRS" and diskEncryptionSet.id: "Default". 331 // +optional 332 ManagedDisk DataDiskManagedDiskParameters `json:"managedDisk,omitempty"` 333 // Lun Specifies the logical unit number of the data disk. 334 // This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM. 335 // This value is also needed for referencing the data disks devices within userdata to perform disk initialization through Ignition (e.g. partition/format/mount). 336 // The value must be between 0 and 63. 337 // +kubebuilder:validation:Minimum=0 338 // +kubebuilder:validation:Maximum=63 339 // +kubebuilder:validation:Required 340 Lun int32 `json:"lun,omitempty"` 341 // CachingType specifies the caching requirements. 342 // Empty value means no opinion and the platform chooses a default, which is subject to change over time. 343 // Currently the default is CachingTypeNone. 344 // +optional 345 // +kubebuilder:validation:Enum=None;ReadOnly;ReadWrite 346 CachingType CachingTypeOption `json:"cachingType,omitempty"` 347 // DeletionPolicy specifies the data disk deletion policy upon Machine deletion. 348 // Possible values are "Delete","Detach". 349 // When "Delete" is used the data disk is deleted when the Machine is deleted. 350 // When "Detach" is used the data disk is detached from the Machine and retained when the Machine is deleted. 351 // +kubebuilder:validation:Enum=Delete;Detach 352 // +kubebuilder:validation:Required 353 DeletionPolicy DiskDeletionPolicyType `json:"deletionPolicy"` 354 } 355 356 // DiskDeletionPolicyType defines the possible values for DeletionPolicy. 357 type DiskDeletionPolicyType string 358 359 // These are the valid DiskDeletionPolicyType values. 360 const ( 361 // DiskDeletionPolicyTypeDelete means the DiskDeletionPolicyType is "Delete". 362 DiskDeletionPolicyTypeDelete DiskDeletionPolicyType = "Delete" 363 // DiskDeletionPolicyTypeDetach means the DiskDeletionPolicyType is "Detach". 364 DiskDeletionPolicyTypeDetach DiskDeletionPolicyType = "Detach" 365 ) 366 367 // CachingTypeOption defines the different values for a CachingType. 368 type CachingTypeOption string 369 370 // These are the valid CachingTypeOption values. 371 const ( 372 // CachingTypeReadOnly means the CachingType is "ReadOnly". 373 CachingTypeReadOnly CachingTypeOption = "ReadOnly" 374 // CachingTypeReadWrite means the CachingType is "ReadWrite". 375 CachingTypeReadWrite CachingTypeOption = "ReadWrite" 376 // CachingTypeNone means the CachingType is "None". 377 CachingTypeNone CachingTypeOption = "None" 378 ) 379 380 // DiskSettings describe ephemeral disk settings for the os disk. 381 type DiskSettings struct { 382 // EphemeralStorageLocation enables ephemeral OS when set to 'Local'. 383 // Possible values include: 'Local'. 384 // See https://docs.microsoft.com/en-us/azure/virtual-machines/ephemeral-os-disks for full details. 385 // Empty value means no opinion and the platform chooses a default, which is subject to change over 386 // time. Currently the default is that disks are saved to remote Azure storage. 387 // +optional 388 // +kubebuilder:validation:Enum=Local 389 EphemeralStorageLocation string `json:"ephemeralStorageLocation,omitempty"` 390 } 391 392 // OSDiskManagedDiskParameters is the parameters of a OSDisk managed disk. 393 type OSDiskManagedDiskParameters struct { 394 // StorageAccountType is the storage account type to use. 395 // Possible values include "Standard_LRS", "Premium_LRS". 396 StorageAccountType string `json:"storageAccountType"` 397 // DiskEncryptionSet is the disk encryption set properties 398 // +optional 399 DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"` 400 } 401 402 // DataDiskManagedDiskParameters is the parameters of a DataDisk managed disk. 403 type DataDiskManagedDiskParameters struct { 404 // StorageAccountType is the storage account type to use. 405 // Possible values include "Standard_LRS", "Premium_LRS" and "UltraSSD_LRS". 406 // +kubebuilder:validation:Enum=Standard_LRS;Premium_LRS;UltraSSD_LRS 407 StorageAccountType StorageAccountType `json:"storageAccountType"` 408 // DiskEncryptionSet is the disk encryption set properties. 409 // Empty value means no opinion and the platform chooses a default, which is subject to change over time. 410 // Currently the default is a DiskEncryptionSet with id: "Default". 411 // +optional 412 DiskEncryptionSet *DiskEncryptionSetParameters `json:"diskEncryptionSet,omitempty"` 413 } 414 415 // StorageAccountType defines the different storage types to use for a ManagedDisk. 416 type StorageAccountType string 417 418 // These are the valid StorageAccountType types. 419 const ( 420 // "StorageAccountStandardLRS" means the Standard_LRS storage type. 421 StorageAccountStandardLRS StorageAccountType = "Standard_LRS" 422 // "StorageAccountPremiumLRS" means the Premium_LRS storage type. 423 StorageAccountPremiumLRS StorageAccountType = "Premium_LRS" 424 // "StorageAccountUltraSSDLRS" means the UltraSSD_LRS storage type. 425 StorageAccountUltraSSDLRS StorageAccountType = "UltraSSD_LRS" 426 ) 427 428 // DiskEncryptionSetParameters is the disk encryption set properties 429 type DiskEncryptionSetParameters struct { 430 // ID is the disk encryption set ID 431 // Empty value means no opinion and the platform chooses a default, which is subject to change over time. 432 // Currently the default is: "Default". 433 // +optional 434 ID string `json:"id,omitempty"` 435 } 436 437 // SecurityProfile specifies the Security profile settings for a 438 // virtual machine or virtual machine scale set. 439 type SecurityProfile struct { 440 // This field indicates whether Host Encryption should be enabled 441 // or disabled for a virtual machine or virtual machine scale 442 // set. Default is disabled. 443 // +optional 444 EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"` 445 } 446 447 // AzureUltraSSDCapabilityState defines the different states of an UltraSSDCapability 448 type AzureUltraSSDCapabilityState string 449 450 // These are the valid AzureUltraSSDCapabilityState states. 451 const ( 452 // "AzureUltraSSDCapabilityEnabled" means the Azure UltraSSDCapability is Enabled 453 AzureUltraSSDCapabilityEnabled AzureUltraSSDCapabilityState = "Enabled" 454 // "AzureUltraSSDCapabilityDisabled" means the Azure UltraSSDCapability is Disabled 455 AzureUltraSSDCapabilityDisabled AzureUltraSSDCapabilityState = "Disabled" 456 ) 457