sigs.k8s.io/cluster-api-provider-aws@v1.5.5/exp/api/v1alpha4/awsmanagedmachinepool_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 v1alpha4 18 19 import ( 20 "fmt" 21 22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 24 infrav1alpha4 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha4" 25 iamv1 "sigs.k8s.io/cluster-api-provider-aws/iam/api/v1beta1" 26 clusterv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4" 27 "sigs.k8s.io/cluster-api/errors" 28 ) 29 30 const ( 31 // ManagedMachinePoolFinalizer allows the controller to clean up resources on delete. 32 ManagedMachinePoolFinalizer = "awsmanagedmachinepools.infrastructure.cluster.x-k8s.io" 33 ) 34 35 // ManagedMachineAMIType specifies which AWS AMI to use for a managed MachinePool. 36 type ManagedMachineAMIType string 37 38 const ( 39 // Al2x86_64 is the default AMI type. 40 Al2x86_64 ManagedMachineAMIType = "AL2_x86_64" 41 // Al2x86_64GPU is the x86-64 GPU AMI type. 42 Al2x86_64GPU ManagedMachineAMIType = "AL2_x86_64_GPU" 43 // Al2Arm64 is the Arm AMI type. 44 Al2Arm64 ManagedMachineAMIType = "AL2_ARM_64" 45 ) 46 47 // ManagedMachinePoolCapacityType specifies the capacity type to be used for the managed MachinePool. 48 type ManagedMachinePoolCapacityType string 49 50 const ( 51 // ManagedMachinePoolCapacityTypeOnDemand is the default capacity type, to launch on-demand instances. 52 ManagedMachinePoolCapacityTypeOnDemand ManagedMachinePoolCapacityType = "onDemand" 53 // ManagedMachinePoolCapacityTypeSpot is the spot instance capacity type to launch spot instances. 54 ManagedMachinePoolCapacityTypeSpot ManagedMachinePoolCapacityType = "spot" 55 ) 56 57 var ( 58 // DefaultEKSNodegroupRole is the name of the default IAM role to use for EKS nodegroups 59 // if no other role is supplied in the spec and if iam role creation is not enabled. The default 60 // can be created using clusterawsadm or created manually. 61 DefaultEKSNodegroupRole = fmt.Sprintf("eks-nodegroup%s", iamv1.DefaultNameSuffix) 62 ) 63 64 // AWSManagedMachinePoolSpec defines the desired state of AWSManagedMachinePool 65 type AWSManagedMachinePoolSpec struct { 66 // EKSNodegroupName specifies the name of the nodegroup in AWS 67 // corresponding to this MachinePool. If you don't specify a name 68 // then a default name will be created based on the namespace and 69 // name of the managed machine pool. 70 // +optional 71 EKSNodegroupName string `json:"eksNodegroupName,omitempty"` 72 73 // AvailabilityZones is an array of availability zones instances can run in 74 AvailabilityZones []string `json:"availabilityZones,omitempty"` 75 76 // SubnetIDs specifies which subnets are used for the 77 // auto scaling group of this nodegroup 78 // +optional 79 SubnetIDs []string `json:"subnetIDs,omitempty"` 80 81 // AdditionalTags is an optional set of tags to add to AWS resources managed by the AWS provider, in addition to the 82 // ones added by default. 83 // +optional 84 AdditionalTags infrav1alpha4.Tags `json:"additionalTags,omitempty"` 85 86 // RoleName specifies the name of IAM role for the node group. 87 // If the role is pre-existing we will treat it as unmanaged 88 // and not delete it on deletion. If the EKSEnableIAM feature 89 // flag is true and no name is supplied then a role is created. 90 // +optional 91 RoleName string `json:"roleName,omitempty"` 92 93 // AMIVersion defines the desired AMI release version. If no version number 94 // is supplied then the latest version for the Kubernetes version 95 // will be used 96 // +kubebuilder:validation:MinLength:=2 97 // +optional 98 AMIVersion *string `json:"amiVersion,omitempty"` 99 100 // AMIType defines the AMI type 101 // +kubebuilder:validation:Enum:=AL2_x86_64;AL2_x86_64_GPU;AL2_ARM_64 102 // +kubebuilder:default:=AL2_x86_64 103 // +optional 104 AMIType *ManagedMachineAMIType `json:"amiType,omitempty"` 105 106 // Labels specifies labels for the Kubernetes node objects 107 // +optional 108 Labels map[string]string `json:"labels,omitempty"` 109 110 // Taints specifies the taints to apply to the nodes of the machine pool 111 // +optional 112 Taints Taints `json:"taints,omitempty"` 113 114 // DiskSize specifies the root disk size 115 // +optional 116 DiskSize *int32 `json:"diskSize,omitempty"` 117 118 // InstanceType specifies the AWS instance type 119 // +optional 120 InstanceType *string `json:"instanceType,omitempty"` 121 122 // Scaling specifies scaling for the ASG behind this pool 123 // +optional 124 Scaling *ManagedMachinePoolScaling `json:"scaling,omitempty"` 125 126 // RemoteAccess specifies how machines can be accessed remotely 127 // +optional 128 RemoteAccess *ManagedRemoteAccess `json:"remoteAccess,omitempty"` 129 130 // ProviderIDList are the provider IDs of instances in the 131 // autoscaling group corresponding to the nodegroup represented by this 132 // machine pool 133 // +optional 134 ProviderIDList []string `json:"providerIDList,omitempty"` 135 136 // CapacityType specifies the capacity type for the ASG behind this pool 137 // +kubebuilder:validation:Enum:=onDemand;spot 138 // +kubebuilder:default:=onDemand 139 // +optional 140 CapacityType *ManagedMachinePoolCapacityType `json:"capacityType,omitempty"` 141 } 142 143 // ManagedMachinePoolScaling specifies scaling options. 144 type ManagedMachinePoolScaling struct { 145 MinSize *int32 `json:"minSize,omitempty"` 146 MaxSize *int32 `json:"maxSize,omitempty"` 147 } 148 149 // ManagedRemoteAccess specifies remote access settings for EC2 instances. 150 type ManagedRemoteAccess struct { 151 // SSHKeyName specifies which EC2 SSH key can be used to access machines. 152 // If left empty, the key from the control plane is used. 153 SSHKeyName *string `json:"sshKeyName,omitempty"` 154 155 // SourceSecurityGroups specifies which security groups are allowed access 156 SourceSecurityGroups []string `json:"sourceSecurityGroups,omitempty"` 157 158 // Public specifies whether to open port 22 to the public internet 159 Public bool `json:"public,omitempty"` 160 } 161 162 // AWSManagedMachinePoolStatus defines the observed state of AWSManagedMachinePool 163 type AWSManagedMachinePoolStatus struct { 164 // Ready denotes that the AWSManagedMachinePool nodegroup has joined 165 // the cluster 166 // +kubebuilder:default=false 167 Ready bool `json:"ready"` 168 169 // Replicas is the most recently observed number of replicas. 170 // +optional 171 Replicas int32 `json:"replicas"` 172 173 // FailureReason will be set in the event that there is a terminal problem 174 // reconciling the MachinePool and will contain a succinct value suitable 175 // for machine interpretation. 176 // 177 // This field should not be set for transitive errors that a controller 178 // faces that are expected to be fixed automatically over 179 // time (like service outages), but instead indicate that something is 180 // fundamentally wrong with the Machine's spec or the configuration of 181 // the controller, and that manual intervention is required. Examples 182 // of terminal errors would be invalid combinations of settings in the 183 // spec, values that are unsupported by the controller, or the 184 // responsible controller itself being critically misconfigured. 185 // 186 // Any transient errors that occur during the reconciliation of MachinePools 187 // can be added as events to the MachinePool object and/or logged in the 188 // controller's output. 189 // +optional 190 FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"` 191 192 // FailureMessage will be set in the event that there is a terminal problem 193 // reconciling the MachinePool and will contain a more verbose string suitable 194 // for logging and human consumption. 195 // 196 // This field should not be set for transitive errors that a controller 197 // faces that are expected to be fixed automatically over 198 // time (like service outages), but instead indicate that something is 199 // fundamentally wrong with the MachinePool's spec or the configuration of 200 // the controller, and that manual intervention is required. Examples 201 // of terminal errors would be invalid combinations of settings in the 202 // spec, values that are unsupported by the controller, or the 203 // responsible controller itself being critically misconfigured. 204 // 205 // Any transient errors that occur during the reconciliation of MachinePools 206 // can be added as events to the MachinePool object and/or logged in the 207 // controller's output. 208 // +optional 209 FailureMessage *string `json:"failureMessage,omitempty"` 210 211 // Conditions defines current service state of the managed machine pool 212 // +optional 213 Conditions clusterv1alpha4.Conditions `json:"conditions,omitempty"` 214 } 215 216 // +kubebuilder:object:root=true 217 // +kubebuilder:resource:path=awsmanagedmachinepools,scope=Namespaced,categories=cluster-api,shortName=awsmmp 218 // +kubebuilder:subresource:status 219 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="MachinePool ready status" 220 // +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.replicas",description="Number of replicas" 221 222 // AWSManagedMachinePool is the Schema for the awsmanagedmachinepools API 223 type AWSManagedMachinePool struct { 224 metav1.TypeMeta `json:",inline"` 225 metav1.ObjectMeta `json:"metadata,omitempty"` 226 227 Spec AWSManagedMachinePoolSpec `json:"spec,omitempty"` 228 Status AWSManagedMachinePoolStatus `json:"status,omitempty"` 229 } 230 231 // GetConditions returns the observations of the operational state of the AWSManagedMachinePool resource. 232 func (r *AWSManagedMachinePool) GetConditions() clusterv1alpha4.Conditions { 233 return r.Status.Conditions 234 } 235 236 // SetConditions sets the underlying service state of the AWSManagedMachinePool to the predescribed clusterv1alpha4.Conditions. 237 func (r *AWSManagedMachinePool) SetConditions(conditions clusterv1alpha4.Conditions) { 238 r.Status.Conditions = conditions 239 } 240 241 // +kubebuilder:object:root=true 242 243 // AWSManagedMachinePoolList contains a list of AWSManagedMachinePools. 244 type AWSManagedMachinePoolList struct { 245 metav1.TypeMeta `json:",inline"` 246 metav1.ListMeta `json:"metadata,omitempty"` 247 Items []AWSManagedMachinePool `json:"items"` 248 } 249 250 func init() { 251 SchemeBuilder.Register(&AWSManagedMachinePool{}, &AWSManagedMachinePoolList{}) 252 }