sigs.k8s.io/cluster-api-provider-azure@v1.14.3/exp/api/v1beta1/azuremachinepool_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 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 "k8s.io/apimachinery/pkg/util/intstr" 22 infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" 23 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" 24 "sigs.k8s.io/cluster-api/errors" 25 ) 26 27 const ( 28 // MachinePoolNameLabel indicates the AzureMachinePool name the AzureMachinePoolMachine belongs. 29 MachinePoolNameLabel = "azuremachinepool.infrastructure.cluster.x-k8s.io/machine-pool" 30 31 // RollingUpdateAzureMachinePoolDeploymentStrategyType replaces AzureMachinePoolMachines with older models with 32 // AzureMachinePoolMachines based on the latest model. 33 // i.e. gradually scale down the old AzureMachinePoolMachines and scale up the new ones. 34 RollingUpdateAzureMachinePoolDeploymentStrategyType AzureMachinePoolDeploymentStrategyType = "RollingUpdate" 35 36 // OldestDeletePolicyType will delete machines with the oldest creation date first. 37 OldestDeletePolicyType AzureMachinePoolDeletePolicyType = "Oldest" 38 // NewestDeletePolicyType will delete machines with the newest creation date first. 39 NewestDeletePolicyType AzureMachinePoolDeletePolicyType = "Newest" 40 // RandomDeletePolicyType will delete machines in random order. 41 RandomDeletePolicyType AzureMachinePoolDeletePolicyType = "Random" 42 ) 43 44 type ( 45 // AzureMachinePoolMachineTemplate defines the template for an AzureMachine. 46 AzureMachinePoolMachineTemplate struct { 47 // VMSize is the size of the Virtual Machine to build. 48 // See https://learn.microsoft.com/rest/api/compute/virtualmachines/createorupdate#virtualmachinesizetypes 49 VMSize string `json:"vmSize"` 50 51 // Image is used to provide details of an image to use during VM creation. 52 // If image details are omitted the image will default the Azure Marketplace "capi" offer, 53 // which is based on Ubuntu. 54 // +kubebuilder:validation:nullable 55 // +optional 56 Image *infrav1.Image `json:"image,omitempty"` 57 58 // OSDisk contains the operating system disk information for a Virtual Machine 59 OSDisk infrav1.OSDisk `json:"osDisk"` 60 61 // DataDisks specifies the list of data disks to be created for a Virtual Machine 62 // +optional 63 DataDisks []infrav1.DataDisk `json:"dataDisks,omitempty"` 64 65 // SSHPublicKey is the SSH public key string, base64-encoded to add to a Virtual Machine. Linux only. 66 // Refer to documentation on how to set up SSH access on Windows instances. 67 // +optional 68 SSHPublicKey string `json:"sshPublicKey"` 69 70 // Deprecated: AcceleratedNetworking should be set in the networkInterfaces field. 71 // +optional 72 AcceleratedNetworking *bool `json:"acceleratedNetworking,omitempty"` 73 74 // Diagnostics specifies the diagnostics settings for a virtual machine. 75 // If not specified then Boot diagnostics (Managed) will be enabled. 76 // +optional 77 Diagnostics *infrav1.Diagnostics `json:"diagnostics,omitempty"` 78 79 // TerminateNotificationTimeout enables or disables VMSS scheduled events termination notification with specified timeout 80 // allowed values are between 5 and 15 (mins) 81 // +optional 82 TerminateNotificationTimeout *int `json:"terminateNotificationTimeout,omitempty"` 83 84 // SecurityProfile specifies the Security profile settings for a virtual machine. 85 // +optional 86 SecurityProfile *infrav1.SecurityProfile `json:"securityProfile,omitempty"` 87 88 // SpotVMOptions allows the ability to specify the Machine should use a Spot VM 89 // +optional 90 SpotVMOptions *infrav1.SpotVMOptions `json:"spotVMOptions,omitempty"` 91 92 // Deprecated: SubnetName should be set in the networkInterfaces field. 93 // +optional 94 SubnetName string `json:"subnetName,omitempty"` 95 96 // VMExtensions specifies a list of extensions to be added to the scale set. 97 // +optional 98 VMExtensions []infrav1.VMExtension `json:"vmExtensions,omitempty"` 99 100 // NetworkInterfaces specifies a list of network interface configurations. 101 // If left unspecified, the VM will get a single network interface with a 102 // single IPConfig in the subnet specified in the cluster's node subnet field. 103 // The primary interface will be the first networkInterface specified (index 0) in the list. 104 // +optional 105 NetworkInterfaces []infrav1.NetworkInterface `json:"networkInterfaces,omitempty"` 106 } 107 108 // AzureMachinePoolSpec defines the desired state of AzureMachinePool. 109 AzureMachinePoolSpec struct { 110 // Location is the Azure region location e.g. westus2 111 Location string `json:"location"` 112 113 // Template contains the details used to build a replica virtual machine within the Machine Pool 114 Template AzureMachinePoolMachineTemplate `json:"template"` 115 116 // AdditionalTags is an optional set of tags to add to an instance, in addition to the ones added by default by the 117 // Azure provider. If both the AzureCluster and the AzureMachine specify the same tag name with different values, the 118 // AzureMachine's value takes precedence. 119 // +optional 120 AdditionalTags infrav1.Tags `json:"additionalTags,omitempty"` 121 122 // ProviderID is the identification ID of the Virtual Machine Scale Set 123 // +optional 124 ProviderID string `json:"providerID,omitempty"` 125 126 // ProviderIDList are the identification IDs of machine instances provided by the provider. 127 // This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances. 128 // +optional 129 ProviderIDList []string `json:"providerIDList,omitempty"` 130 131 // Identity is the type of identity used for the Virtual Machine Scale Set. 132 // The type 'SystemAssigned' is an implicitly created identity. 133 // The generated identity will be assigned a Subscription contributor role. 134 // The type 'UserAssigned' is a standalone Azure resource provided by the user 135 // and assigned to the VM 136 // +kubebuilder:default=None 137 // +optional 138 Identity infrav1.VMIdentity `json:"identity,omitempty"` 139 140 // SystemAssignedIdentityRole defines the role and scope to assign to the system assigned identity. 141 // +optional 142 SystemAssignedIdentityRole *infrav1.SystemAssignedIdentityRole `json:"systemAssignedIdentityRole,omitempty"` 143 144 // UserAssignedIdentities is a list of standalone Azure identities provided by the user 145 // The lifecycle of a user-assigned identity is managed separately from the lifecycle of 146 // the AzureMachinePool. 147 // See https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-cli 148 // +optional 149 UserAssignedIdentities []infrav1.UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` 150 151 // Deprecated: RoleAssignmentName should be set in the systemAssignedIdentityRole field. 152 // +optional 153 RoleAssignmentName string `json:"roleAssignmentName,omitempty"` 154 155 // The deployment strategy to use to replace existing AzureMachinePoolMachines with new ones. 156 // +optional 157 // +kubebuilder:default={type: "RollingUpdate", rollingUpdate: {maxSurge: 1, maxUnavailable: 0, deletePolicy: Oldest}} 158 Strategy AzureMachinePoolDeploymentStrategy `json:"strategy,omitempty"` 159 160 // OrchestrationMode specifies the orchestration mode for the Virtual Machine Scale Set 161 // +kubebuilder:default=Uniform 162 OrchestrationMode infrav1.OrchestrationModeType `json:"orchestrationMode,omitempty"` 163 164 // PlatformFaultDomainCount specifies the number of fault domains that the Virtual Machine Scale Set can use. 165 // The count determines the spreading algorithm of the Azure fault domain. 166 // +optional 167 PlatformFaultDomainCount *int32 `json:"platformFaultDomainCount,omitempty"` 168 169 // ZoneBalane dictates whether to force strictly even Virtual Machine distribution cross x-zones in case there is zone outage. 170 // +optional 171 ZoneBalance *bool `json:"zoneBalance,omitempty"` 172 } 173 174 // AzureMachinePoolDeploymentStrategyType is the type of deployment strategy employed to rollout a new version of 175 // the AzureMachinePool. 176 AzureMachinePoolDeploymentStrategyType string 177 178 // AzureMachinePoolDeploymentStrategy describes how to replace existing machines with new ones. 179 AzureMachinePoolDeploymentStrategy struct { 180 // Type of deployment. Currently the only supported strategy is RollingUpdate 181 // +optional 182 // +kubebuilder:validation:Enum=RollingUpdate 183 // +optional 184 // +kubebuilder:default=RollingUpdate 185 Type AzureMachinePoolDeploymentStrategyType `json:"type,omitempty"` 186 187 // Rolling update config params. Present only if 188 // MachineDeploymentStrategyType = RollingUpdate. 189 // +optional 190 RollingUpdate *MachineRollingUpdateDeployment `json:"rollingUpdate,omitempty"` 191 } 192 193 // AzureMachinePoolDeletePolicyType is the type of DeletePolicy employed to select machines to be deleted during an 194 // upgrade. 195 AzureMachinePoolDeletePolicyType string 196 197 // MachineRollingUpdateDeployment is used to control the desired behavior of rolling update. 198 MachineRollingUpdateDeployment struct { 199 // The maximum number of machines that can be unavailable during the update. 200 // Value can be an absolute number (ex: 5) or a percentage of desired 201 // machines (ex: 10%). 202 // Absolute number is calculated from percentage by rounding down. 203 // This can not be 0 if MaxSurge is 0. 204 // Defaults to 0. 205 // Example: when this is set to 30%, the old MachineSet can be scaled 206 // down to 70% of desired machines immediately when the rolling update 207 // starts. Once new machines are ready, old MachineSet can be scaled 208 // down further, followed by scaling up the new MachineSet, ensuring 209 // that the total number of machines available at all times 210 // during the update is at least 70% of desired machines. 211 // +optional 212 // +kubebuilder:default:=0 213 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"` 214 215 // The maximum number of machines that can be scheduled above the 216 // desired number of machines. 217 // Value can be an absolute number (ex: 5) or a percentage of 218 // desired machines (ex: 10%). 219 // This can not be 0 if MaxUnavailable is 0. 220 // Absolute number is calculated from percentage by rounding up. 221 // Defaults to 1. 222 // Example: when this is set to 30%, the new MachineSet can be scaled 223 // up immediately when the rolling update starts, such that the total 224 // number of old and new machines do not exceed 130% of desired 225 // machines. Once old machines have been killed, new MachineSet can 226 // be scaled up further, ensuring that total number of machines running 227 // at any time during the update is at most 130% of desired machines. 228 // +optional 229 // +kubebuilder:default:=1 230 MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"` 231 232 // DeletePolicy defines the policy used by the MachineDeployment to identify nodes to delete when downscaling. 233 // Valid values are "Random, "Newest", "Oldest" 234 // When no value is supplied, the default is Oldest 235 // +optional 236 // +kubebuilder:validation:Enum=Random;Newest;Oldest 237 // +kubebuilder:default:=Oldest 238 DeletePolicy AzureMachinePoolDeletePolicyType `json:"deletePolicy,omitempty"` 239 } 240 241 // AzureMachinePoolStatus defines the observed state of AzureMachinePool. 242 AzureMachinePoolStatus struct { 243 // Ready is true when the provider resource is ready. 244 // +optional 245 Ready bool `json:"ready"` 246 247 // Replicas is the most recently observed number of replicas. 248 // +optional 249 Replicas int32 `json:"replicas"` 250 251 // Instances is the VM instance status for each VM in the VMSS 252 // +optional 253 Instances []*AzureMachinePoolInstanceStatus `json:"instances,omitempty"` 254 255 // Image is the current image used in the AzureMachinePool. When the spec image is nil, this image is populated 256 // with the details of the defaulted Azure Marketplace "capi" offer. 257 // +optional 258 Image *infrav1.Image `json:"image,omitempty"` 259 260 // Version is the Kubernetes version for the current VMSS model 261 // +optional 262 Version string `json:"version"` 263 264 // ProvisioningState is the provisioning state of the Azure virtual machine. 265 // +optional 266 ProvisioningState *infrav1.ProvisioningState `json:"provisioningState,omitempty"` 267 268 // FailureReason will be set in the event that there is a terminal problem 269 // reconciling the MachinePool and will contain a succinct value suitable 270 // for machine interpretation. 271 // 272 // This field should not be set for transitive errors that a controller 273 // faces that are expected to be fixed automatically over 274 // time (like service outages), but instead indicate that something is 275 // fundamentally wrong with the MachinePool's spec or the configuration of 276 // the controller, and that manual intervention is required. Examples 277 // of terminal errors would be invalid combinations of settings in the 278 // spec, values that are unsupported by the controller, or the 279 // responsible controller itself being critically misconfigured. 280 // 281 // Any transient errors that occur during the reconciliation of MachinePools 282 // can be added as events to the MachinePool object and/or logged in the 283 // controller's output. 284 // +optional 285 FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"` 286 287 // FailureMessage will be set in the event that there is a terminal problem 288 // reconciling the MachinePool and will contain a more verbose string suitable 289 // for logging and human consumption. 290 // 291 // This field should not be set for transitive errors that a controller 292 // faces that are expected to be fixed automatically over 293 // time (like service outages), but instead indicate that something is 294 // fundamentally wrong with the MachinePool's spec or the configuration of 295 // the controller, and that manual intervention is required. Examples 296 // of terminal errors would be invalid combinations of settings in the 297 // spec, values that are unsupported by the controller, or the 298 // responsible controller itself being critically misconfigured. 299 // 300 // Any transient errors that occur during the reconciliation of MachinePools 301 // can be added as events to the MachinePool object and/or logged in the 302 // controller's output. 303 // +optional 304 FailureMessage *string `json:"failureMessage,omitempty"` 305 306 // Conditions defines current service state of the AzureMachinePool. 307 // +optional 308 Conditions clusterv1.Conditions `json:"conditions,omitempty"` 309 310 // LongRunningOperationStates saves the state for Azure long-running operations so they can be continued on the 311 // next reconciliation loop. 312 // +optional 313 LongRunningOperationStates infrav1.Futures `json:"longRunningOperationStates,omitempty"` 314 315 // InfrastructureMachineKind is the kind of the infrastructure resources behind MachinePool Machines. 316 // +optional 317 InfrastructureMachineKind string `json:"infrastructureMachineKind,omitempty"` 318 } 319 320 // AzureMachinePoolInstanceStatus provides status information for each instance in the VMSS. 321 AzureMachinePoolInstanceStatus struct { 322 // Version defines the Kubernetes version for the VM Instance 323 // +optional 324 Version string `json:"version"` 325 326 // ProvisioningState is the provisioning state of the Azure virtual machine instance. 327 // +optional 328 ProvisioningState *infrav1.ProvisioningState `json:"provisioningState"` 329 330 // ProviderID is the provider identification of the VMSS Instance 331 // +optional 332 ProviderID string `json:"providerID"` 333 334 // InstanceID is the identification of the Machine Instance within the VMSS 335 // +optional 336 InstanceID string `json:"instanceID"` 337 338 // InstanceName is the name of the Machine Instance within the VMSS 339 // +optional 340 InstanceName string `json:"instanceName"` 341 342 // LatestModelApplied indicates the instance is running the most up-to-date VMSS model. A VMSS model describes 343 // the image version the VM is running. If the instance is not running the latest model, it means the instance 344 // may not be running the version of Kubernetes the Machine Pool has specified and needs to be updated. 345 LatestModelApplied bool `json:"latestModelApplied"` 346 } 347 348 // +kubebuilder:object:root=true 349 // +kubebuilder:subresource:status 350 // +kubebuilder:resource:path=azuremachinepools,scope=Namespaced,categories=cluster-api,shortName=amp 351 // +kubebuilder:storageversion 352 // +kubebuilder:printcolumn:name="Replicas",type="string",JSONPath=".status.replicas",description="AzureMachinePool replicas count" 353 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="AzureMachinePool replicas count" 354 // +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.provisioningState",description="Azure VMSS provisioning state" 355 // +kubebuilder:printcolumn:name="Cluster",type="string",priority=1,JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AzureMachinePool belongs" 356 // +kubebuilder:printcolumn:name="MachinePool",type="string",priority=1,JSONPath=".metadata.ownerReferences[?(@.kind==\"MachinePool\")].name",description="MachinePool object to which this AzureMachinePool belongs" 357 // +kubebuilder:printcolumn:name="VMSS ID",type="string",priority=1,JSONPath=".spec.providerID",description="Azure VMSS ID" 358 // +kubebuilder:printcolumn:name="VM Size",type="string",priority=1,JSONPath=".spec.template.vmSize",description="Azure VM Size" 359 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of this AzureMachinePool" 360 361 // AzureMachinePool is the Schema for the azuremachinepools API. 362 AzureMachinePool struct { 363 metav1.TypeMeta `json:",inline"` 364 metav1.ObjectMeta `json:"metadata,omitempty"` 365 366 Spec AzureMachinePoolSpec `json:"spec,omitempty"` 367 Status AzureMachinePoolStatus `json:"status,omitempty"` 368 } 369 370 // +kubebuilder:object:root=true 371 372 // AzureMachinePoolList contains a list of AzureMachinePools. 373 AzureMachinePoolList struct { 374 metav1.TypeMeta `json:",inline"` 375 metav1.ListMeta `json:"metadata,omitempty"` 376 Items []AzureMachinePool `json:"items"` 377 } 378 ) 379 380 // GetConditions returns the list of conditions for an AzureMachinePool API object. 381 func (amp *AzureMachinePool) GetConditions() clusterv1.Conditions { 382 return amp.Status.Conditions 383 } 384 385 // SetConditions will set the given conditions on an AzureMachinePool object. 386 func (amp *AzureMachinePool) SetConditions(conditions clusterv1.Conditions) { 387 amp.Status.Conditions = conditions 388 } 389 390 // GetFutures returns the list of long running operation states for an AzureMachinePool API object. 391 func (amp *AzureMachinePool) GetFutures() infrav1.Futures { 392 return amp.Status.LongRunningOperationStates 393 } 394 395 // SetFutures will set the given long running operation states on an AzureMachinePool object. 396 func (amp *AzureMachinePool) SetFutures(futures infrav1.Futures) { 397 amp.Status.LongRunningOperationStates = futures 398 } 399 400 func init() { 401 SchemeBuilder.Register(&AzureMachinePool{}, &AzureMachinePoolList{}) 402 }