github.com/openshift/installer@v1.4.17/pkg/types/azure/machinepool.go (about)

     1  package azure
     2  
     3  // SecurityTypes represents the SecurityType of the virtual machine.
     4  type SecurityTypes string
     5  
     6  const (
     7  	// SecurityTypesConfidentialVM defines the SecurityType of the virtual machine as a Confidential VM.
     8  	SecurityTypesConfidentialVM SecurityTypes = "ConfidentialVM"
     9  	// SecurityTypesTrustedLaunch defines the SecurityType of the virtual machine as a Trusted Launch VM.
    10  	SecurityTypesTrustedLaunch SecurityTypes = "TrustedLaunch"
    11  )
    12  
    13  // MachinePool stores the configuration for a machine pool installed
    14  // on Azure.
    15  type MachinePool struct {
    16  	// Zones is list of availability zones that can be used.
    17  	// eg. ["1", "2", "3"]
    18  	//
    19  	// +optional
    20  	Zones []string `json:"zones,omitempty"`
    21  
    22  	// InstanceType defines the azure instance type.
    23  	// eg. Standard_DS_V2
    24  	//
    25  	// +optional
    26  	InstanceType string `json:"type"`
    27  
    28  	// EncryptionAtHost enables encryption at the VM host.
    29  	//
    30  	// +optional
    31  	EncryptionAtHost bool `json:"encryptionAtHost,omitempty"`
    32  
    33  	// OSDisk defines the storage for instance.
    34  	//
    35  	// +optional
    36  	OSDisk `json:"osDisk"`
    37  
    38  	// ultraSSDCapability defines if the instance should use Ultra SSD disks.
    39  	//
    40  	// +optional
    41  	// +kubebuilder:validation:Enum=Enabled;Disabled
    42  	UltraSSDCapability string `json:"ultraSSDCapability,omitempty"`
    43  
    44  	// VMNetworkingType specifies whether to enable accelerated networking.
    45  	// Accelerated networking enables single root I/O virtualization (SR-IOV) to a VM, greatly improving its
    46  	// networking performance.
    47  	// eg. values: "Accelerated", "Basic"
    48  	//
    49  	// +kubebuilder:validation:Enum="Accelerated"; "Basic"
    50  	// +optional
    51  	VMNetworkingType string `json:"vmNetworkingType,omitempty"`
    52  
    53  	// OSImage defines the image to use for the OS.
    54  	// +optional
    55  	OSImage OSImage `json:"osImage,omitempty"`
    56  
    57  	// Settings specify the security type and the UEFI settings of the virtual machine. This field can
    58  	// be set for Confidential VMs and Trusted Launch for VMs.
    59  	// +optional
    60  	Settings *SecuritySettings `json:"settings,omitempty"`
    61  }
    62  
    63  // SecuritySettings define the security type and the UEFI settings of the virtual machine.
    64  type SecuritySettings struct {
    65  	// SecurityType specifies the SecurityType of the virtual machine. It has to be set to any specified value to
    66  	// enable secure boot and vTPM. The default behavior is: secure boot and vTPM will not be enabled unless this property is set.
    67  	// +kubebuilder:validation:Enum=ConfidentialVM;TrustedLaunch
    68  	// +kubebuilder:validation:Required
    69  	SecurityType SecurityTypes `json:"securityType,omitempty"`
    70  
    71  	// ConfidentialVM specifies the security configuration of the virtual machine.
    72  	// For more information regarding Confidential VMs, please refer to:
    73  	// https://learn.microsoft.com/azure/confidential-computing/confidential-vm-overview
    74  	// +optional
    75  	ConfidentialVM *ConfidentialVM `json:"confidentialVM,omitempty"`
    76  
    77  	// TrustedLaunch specifies the security configuration of the virtual machine.
    78  	// For more information regarding TrustedLaunch for VMs, please refer to:
    79  	// https://learn.microsoft.com/azure/virtual-machines/trusted-launch
    80  	// +optional
    81  	TrustedLaunch *TrustedLaunch `json:"trustedLaunch,omitempty"`
    82  }
    83  
    84  // ConfidentialVM defines the UEFI settings for the virtual machine.
    85  type ConfidentialVM struct {
    86  	// UEFISettings specifies the security settings like secure boot and vTPM used while creating the virtual machine.
    87  	// +kubebuilder:validation:Required
    88  	UEFISettings *UEFISettings `json:"uefiSettings,omitempty"`
    89  }
    90  
    91  // TrustedLaunch defines the UEFI settings for the virtual machine.
    92  type TrustedLaunch struct {
    93  	// UEFISettings specifies the security settings like secure boot and vTPM used while creating the virtual machine.
    94  	// +kubebuilder:validation:Required
    95  	UEFISettings *UEFISettings `json:"uefiSettings,omitempty"`
    96  }
    97  
    98  // UEFISettings specifies the security settings like secure boot and vTPM used while creating the
    99  // virtual machine.
   100  type UEFISettings struct {
   101  	// SecureBoot specifies whether secure boot should be enabled on the virtual machine.
   102  	// Secure Boot verifies the digital signature of all boot components and halts the boot process if
   103  	// signature verification fails.
   104  	// If omitted, the platform chooses a default, which is subject to change over time, currently that default is disabled.
   105  	// +kubebuilder:validation:Enum=Enabled;Disabled
   106  	// +optional
   107  	SecureBoot *string `json:"secureBoot,omitempty"`
   108  
   109  	// VirtualizedTrustedPlatformModule specifies whether vTPM should be enabled on the virtual machine.
   110  	// When enabled the virtualized trusted platform module measurements are used to create a known good boot integrity policy baseline.
   111  	// The integrity policy baseline is used for comparison with measurements from subsequent VM boots to determine if anything has changed.
   112  	// This is required to be set to enabled if the SecurityEncryptionType is defined.
   113  	// If omitted, the platform chooses a default, which is subject to change over time, currently that default is disabled.
   114  	// +kubebuilder:validation:Enum=Enabled;Disabled
   115  	// +optional
   116  	VirtualizedTrustedPlatformModule *string `json:"virtualizedTrustedPlatformModule,omitempty"`
   117  }
   118  
   119  // VMNetworkingCapability defines the states for accelerated networking feature
   120  type VMNetworkingCapability string
   121  
   122  const (
   123  	// AcceleratedNetworkingEnabled is string representation of the VMNetworkingType / AcceleratedNetworking Capability
   124  	// provided by the Azure API
   125  	AcceleratedNetworkingEnabled = "AcceleratedNetworkingEnabled"
   126  
   127  	// VMNetworkingTypeBasic enum attribute that is the default setting which means AcceleratedNetworking is disabled.
   128  	VMNetworkingTypeBasic VMNetworkingCapability = "Basic"
   129  
   130  	// VMnetworkingTypeAccelerated enum attribute that enables AcceleratedNetworking on a VM NIC.
   131  	VMnetworkingTypeAccelerated VMNetworkingCapability = "Accelerated"
   132  )
   133  
   134  // Set sets the values from `required` to `a`.
   135  func (a *MachinePool) Set(required *MachinePool) {
   136  	if required == nil || a == nil {
   137  		return
   138  	}
   139  
   140  	if len(required.Zones) > 0 {
   141  		a.Zones = required.Zones
   142  	}
   143  
   144  	if required.InstanceType != "" {
   145  		a.InstanceType = required.InstanceType
   146  	}
   147  
   148  	if required.EncryptionAtHost {
   149  		a.EncryptionAtHost = required.EncryptionAtHost
   150  	}
   151  
   152  	if required.OSDisk.DiskSizeGB != 0 {
   153  		a.OSDisk.DiskSizeGB = required.OSDisk.DiskSizeGB
   154  	}
   155  
   156  	if required.OSDisk.DiskType != "" {
   157  		a.OSDisk.DiskType = required.OSDisk.DiskType
   158  	}
   159  
   160  	if required.DiskEncryptionSet != nil {
   161  		a.DiskEncryptionSet = required.DiskEncryptionSet
   162  	}
   163  
   164  	if required.UltraSSDCapability != "" {
   165  		a.UltraSSDCapability = required.UltraSSDCapability
   166  	}
   167  
   168  	if required.VMNetworkingType != "" {
   169  		a.VMNetworkingType = required.VMNetworkingType
   170  	}
   171  
   172  	var emptyOSImage OSImage
   173  	if required.OSImage != emptyOSImage {
   174  		a.OSImage = required.OSImage
   175  	}
   176  
   177  	if required.OSDisk.SecurityProfile != nil {
   178  		a.OSDisk.SecurityProfile = required.OSDisk.SecurityProfile
   179  	}
   180  
   181  	if required.Settings != nil {
   182  		a.Settings = required.Settings
   183  	}
   184  }
   185  
   186  // ImagePurchasePlan defines the purchase plan of a Marketplace image.
   187  // +kubebuilder:validation:Enum=WithPurchasePlan;NoPurchasePlan
   188  type ImagePurchasePlan string
   189  
   190  const (
   191  	// ImageWithPurchasePlan enum attribute which is the default setting.
   192  	ImageWithPurchasePlan ImagePurchasePlan = "WithPurchasePlan"
   193  	// ImageNoPurchasePlan  enum attribute which speficies the image does not need a purchase plan.
   194  	ImageNoPurchasePlan ImagePurchasePlan = "NoPurchasePlan"
   195  )
   196  
   197  // OSImage is the image to use for the OS of a machine.
   198  type OSImage struct {
   199  	// Plan is the purchase plan of the image.
   200  	// If omitted, it defaults to "WithPurchasePlan".
   201  	// +optional
   202  	Plan ImagePurchasePlan `json:"plan"`
   203  	// Publisher is the publisher of the image.
   204  	Publisher string `json:"publisher"`
   205  	// Offer is the offer of the image.
   206  	Offer string `json:"offer"`
   207  	// SKU is the SKU of the image.
   208  	SKU string `json:"sku"`
   209  	// Version is the version of the image.
   210  	Version string `json:"version"`
   211  }