sigs.k8s.io/cluster-api-provider-aws@v1.5.5/exp/api/v1beta1/awsmachinepool_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/runtime/schema" 22 23 infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1" 24 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" 25 "sigs.k8s.io/cluster-api/errors" 26 ) 27 28 // Constants block. 29 const ( 30 // LaunchTemplateLatestVersion defines the launching of the latest version of the template. 31 LaunchTemplateLatestVersion = "$Latest" 32 ) 33 34 // AWSMachinePoolSpec defines the desired state of AWSMachinePool. 35 type AWSMachinePoolSpec struct { 36 // ProviderID is the ARN of the associated ASG 37 // +optional 38 ProviderID string `json:"providerID,omitempty"` 39 40 // MinSize defines the minimum size of the group. 41 // +kubebuilder:default=1 42 // +kubebuilder:validation:Minimum=0 43 MinSize int32 `json:"minSize"` 44 45 // MaxSize defines the maximum size of the group. 46 // +kubebuilder:default=1 47 // +kubebuilder:validation:Minimum=1 48 MaxSize int32 `json:"maxSize"` 49 50 // AvailabilityZones is an array of availability zones instances can run in 51 AvailabilityZones []string `json:"availabilityZones,omitempty"` 52 53 // Subnets is an array of subnet configurations 54 // +optional 55 Subnets []infrav1.AWSResourceReference `json:"subnets,omitempty"` 56 57 // AdditionalTags is an optional set of tags to add to an instance, in addition to the ones added by default by the 58 // AWS provider. 59 // +optional 60 AdditionalTags infrav1.Tags `json:"additionalTags,omitempty"` 61 62 // AWSLaunchTemplate specifies the launch template and version to use when an instance is launched. 63 // +kubebuilder:validation:Required 64 AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate"` 65 66 // MixedInstancesPolicy describes how multiple instance types will be used by the ASG. 67 MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"` 68 69 // ProviderIDList are the identification IDs of machine instances provided by the provider. 70 // This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances. 71 // +optional 72 ProviderIDList []string `json:"providerIDList,omitempty"` 73 74 // The amount of time, in seconds, after a scaling activity completes before another scaling activity can start. 75 // If no value is supplied by user a default value of 300 seconds is set 76 // +optional 77 DefaultCoolDown metav1.Duration `json:"defaultCoolDown,omitempty"` 78 79 // RefreshPreferences describes set of preferences associated with the instance refresh request. 80 // +optional 81 RefreshPreferences *RefreshPreferences `json:"refreshPreferences,omitempty"` 82 83 // Enable or disable the capacity rebalance autoscaling group feature 84 // +optional 85 CapacityRebalance bool `json:"capacityRebalance,omitempty"` 86 } 87 88 // RefreshPreferences defines the specs for instance refreshing. 89 type RefreshPreferences struct { 90 // The strategy to use for the instance refresh. The only valid value is Rolling. 91 // A rolling update is an update that is applied to all instances in an Auto 92 // Scaling group until all instances have been updated. 93 // +optional 94 Strategy *string `json:"strategy,omitempty"` 95 96 // The number of seconds until a newly launched instance is configured and ready 97 // to use. During this time, the next replacement will not be initiated. 98 // The default is to use the value for the health check grace period defined for the group. 99 // +optional 100 InstanceWarmup *int64 `json:"instanceWarmup,omitempty"` 101 102 // The amount of capacity as a percentage in ASG that must remain healthy 103 // during an instance refresh. The default is 90. 104 // +optional 105 MinHealthyPercentage *int64 `json:"minHealthyPercentage,omitempty"` 106 } 107 108 // AWSMachinePoolStatus defines the observed state of AWSMachinePool. 109 type AWSMachinePoolStatus struct { 110 // Ready is true when the provider resource is ready. 111 // +optional 112 Ready bool `json:"ready"` 113 114 // Replicas is the most recently observed number of replicas 115 // +optional 116 Replicas int32 `json:"replicas"` 117 118 // Conditions defines current service state of the AWSMachinePool. 119 // +optional 120 Conditions clusterv1.Conditions `json:"conditions,omitempty"` 121 122 // Instances contains the status for each instance in the pool 123 // +optional 124 Instances []AWSMachinePoolInstanceStatus `json:"instances,omitempty"` 125 126 // The ID of the launch template 127 LaunchTemplateID string `json:"launchTemplateID,omitempty"` 128 129 // FailureReason will be set in the event that there is a terminal problem 130 // reconciling the Machine and will contain a succinct value suitable 131 // for machine interpretation. 132 // 133 // This field should not be set for transitive errors that a controller 134 // faces that are expected to be fixed automatically over 135 // time (like service outages), but instead indicate that something is 136 // fundamentally wrong with the Machine's spec or the configuration of 137 // the controller, and that manual intervention is required. Examples 138 // of terminal errors would be invalid combinations of settings in the 139 // spec, values that are unsupported by the controller, or the 140 // responsible controller itself being critically misconfigured. 141 // 142 // Any transient errors that occur during the reconciliation of Machines 143 // can be added as events to the Machine object and/or logged in the 144 // controller's output. 145 // +optional 146 FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"` 147 148 // FailureMessage will be set in the event that there is a terminal problem 149 // reconciling the Machine and will contain a more verbose string suitable 150 // for logging and human consumption. 151 // 152 // This field should not be set for transitive errors that a controller 153 // faces that are expected to be fixed automatically over 154 // time (like service outages), but instead indicate that something is 155 // fundamentally wrong with the Machine's spec or the configuration of 156 // the controller, and that manual intervention is required. Examples 157 // of terminal errors would be invalid combinations of settings in the 158 // spec, values that are unsupported by the controller, or the 159 // responsible controller itself being critically misconfigured. 160 // 161 // Any transient errors that occur during the reconciliation of Machines 162 // can be added as events to the Machine object and/or logged in the 163 // controller's output. 164 // +optional 165 FailureMessage *string `json:"failureMessage,omitempty"` 166 167 ASGStatus *ASGStatus `json:"asgStatus,omitempty"` 168 } 169 170 // AWSMachinePoolInstanceStatus defines the status of the AWSMachinePoolInstance. 171 type AWSMachinePoolInstanceStatus struct { 172 // InstanceID is the identification of the Machine Instance within ASG 173 // +optional 174 InstanceID string `json:"instanceID,omitempty"` 175 176 // Version defines the Kubernetes version for the Machine Instance 177 // +optional 178 Version *string `json:"version,omitempty"` 179 } 180 181 // +kubebuilder:object:root=true 182 // +kubebuilder:subresource:status 183 // +kubebuilder:storageversion 184 // +kubebuilder:resource:path=awsmachinepools,scope=Namespaced,categories=cluster-api,shortName=awsmp 185 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Machine ready status" 186 // +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.replicas",description="Machine ready status" 187 // +kubebuilder:printcolumn:name="MinSize",type="integer",JSONPath=".spec.minSize",description="Minimum instanes in ASG" 188 // +kubebuilder:printcolumn:name="MaxSize",type="integer",JSONPath=".spec.maxSize",description="Maximum instanes in ASG" 189 // +kubebuilder:printcolumn:name="LaunchTemplate ID",type="string",JSONPath=".status.launchTemplateID",description="Launch Template ID" 190 191 // AWSMachinePool is the Schema for the awsmachinepools API. 192 type AWSMachinePool struct { 193 metav1.TypeMeta `json:",inline"` 194 metav1.ObjectMeta `json:"metadata,omitempty"` 195 196 Spec AWSMachinePoolSpec `json:"spec,omitempty"` 197 Status AWSMachinePoolStatus `json:"status,omitempty"` 198 } 199 200 // +kubebuilder:object:root=true 201 202 // AWSMachinePoolList contains a list of AWSMachinePool. 203 type AWSMachinePoolList struct { 204 metav1.TypeMeta `json:",inline"` 205 metav1.ListMeta `json:"metadata,omitempty"` 206 Items []AWSMachinePool `json:"items"` 207 } 208 209 func init() { 210 SchemeBuilder.Register(&AWSMachinePool{}, &AWSMachinePoolList{}) 211 } 212 213 // GetConditions returns the observations of the operational state of the AWSMachinePool resource. 214 func (r *AWSMachinePool) GetConditions() clusterv1.Conditions { 215 return r.Status.Conditions 216 } 217 218 // SetConditions sets the underlying service state of the AWSMachinePool to the predescribed clusterv1.Conditions. 219 func (r *AWSMachinePool) SetConditions(conditions clusterv1.Conditions) { 220 r.Status.Conditions = conditions 221 } 222 223 // GetObjectKind will return the ObjectKind of an AWSMachinePool. 224 func (r *AWSMachinePool) GetObjectKind() schema.ObjectKind { 225 return &r.TypeMeta 226 } 227 228 // GetObjectKind will return the ObjectKind of an AWSMachinePoolList. 229 func (r *AWSMachinePoolList) GetObjectKind() schema.ObjectKind { 230 return &r.TypeMeta 231 }