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