sigs.k8s.io/cluster-api-provider-aws@v1.5.5/api/v1beta1/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 "k8s.io/apimachinery/pkg/util/sets" 21 22 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" 23 ) 24 25 // AWSResourceReference is a reference to a specific AWS resource by ID or filters. 26 // Only one of ID or Filters may be specified. Specifying more than one will result in 27 // a validation error. 28 type AWSResourceReference struct { 29 // ID of resource 30 // +optional 31 ID *string `json:"id,omitempty"` 32 33 // ARN of resource. 34 // +optional 35 // Deprecated: This field has no function and is going to be removed in the next release. 36 ARN *string `json:"arn,omitempty"` 37 38 // Filters is a set of key/value pairs used to identify a resource 39 // They are applied according to the rules defined by the AWS API: 40 // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html 41 // +optional 42 Filters []Filter `json:"filters,omitempty"` 43 } 44 45 // AMIReference is a reference to a specific AWS resource by ID, ARN, or filters. 46 // Only one of ID, ARN or Filters may be specified. Specifying more than one will result in 47 // a validation error. 48 type AMIReference struct { 49 // ID of resource 50 // +optional 51 ID *string `json:"id,omitempty"` 52 53 // EKSOptimizedLookupType If specified, will look up an EKS Optimized image in SSM Parameter store 54 // +kubebuilder:validation:Enum:=AmazonLinux;AmazonLinuxGPU 55 // +optional 56 EKSOptimizedLookupType *EKSAMILookupType `json:"eksLookupType,omitempty"` 57 } 58 59 // Filter is a filter used to identify an AWS resource. 60 type Filter struct { 61 // Name of the filter. Filter names are case-sensitive. 62 Name string `json:"name"` 63 64 // Values includes one or more filter values. Filter values are case-sensitive. 65 Values []string `json:"values"` 66 } 67 68 // AWSMachineProviderConditionType is a valid value for AWSMachineProviderCondition.Type. 69 type AWSMachineProviderConditionType string 70 71 // Valid conditions for an AWS machine instance. 72 const ( 73 // MachineCreated indicates whether the machine has been created or not. If not, 74 // it should include a reason and message for the failure. 75 MachineCreated AWSMachineProviderConditionType = "MachineCreated" 76 ) 77 78 // AZSelectionScheme defines the scheme of selecting AZs. 79 type AZSelectionScheme string 80 81 var ( 82 // AZSelectionSchemeOrdered will select AZs based on alphabetical order. 83 AZSelectionSchemeOrdered = AZSelectionScheme("Ordered") 84 85 // AZSelectionSchemeRandom will select AZs randomly. 86 AZSelectionSchemeRandom = AZSelectionScheme("Random") 87 ) 88 89 // InstanceState describes the state of an AWS instance. 90 type InstanceState string 91 92 var ( 93 // InstanceStatePending is the string representing an instance in a pending state. 94 InstanceStatePending = InstanceState("pending") 95 96 // InstanceStateRunning is the string representing an instance in a running state. 97 InstanceStateRunning = InstanceState("running") 98 99 // InstanceStateShuttingDown is the string representing an instance shutting down. 100 InstanceStateShuttingDown = InstanceState("shutting-down") 101 102 // InstanceStateTerminated is the string representing an instance that has been terminated. 103 InstanceStateTerminated = InstanceState("terminated") 104 105 // InstanceStateStopping is the string representing an instance 106 // that is in the process of being stopped and can be restarted. 107 InstanceStateStopping = InstanceState("stopping") 108 109 // InstanceStateStopped is the string representing an instance 110 // that has been stopped and can be restarted. 111 InstanceStateStopped = InstanceState("stopped") 112 113 // InstanceRunningStates defines the set of states in which an EC2 instance is 114 // running or going to be running soon. 115 InstanceRunningStates = sets.NewString( 116 string(InstanceStatePending), 117 string(InstanceStateRunning), 118 ) 119 120 // InstanceOperationalStates defines the set of states in which an EC2 instance is 121 // or can return to running, and supports all EC2 operations. 122 InstanceOperationalStates = InstanceRunningStates.Union( 123 sets.NewString( 124 string(InstanceStateStopping), 125 string(InstanceStateStopped), 126 ), 127 ) 128 129 // InstanceKnownStates represents all known EC2 instance states. 130 InstanceKnownStates = InstanceOperationalStates.Union( 131 sets.NewString( 132 string(InstanceStateShuttingDown), 133 string(InstanceStateTerminated), 134 ), 135 ) 136 ) 137 138 // Instance describes an AWS instance. 139 type Instance struct { 140 ID string `json:"id"` 141 142 // The current state of the instance. 143 State InstanceState `json:"instanceState,omitempty"` 144 145 // The instance type. 146 Type string `json:"type,omitempty"` 147 148 // The ID of the subnet of the instance. 149 SubnetID string `json:"subnetId,omitempty"` 150 151 // The ID of the AMI used to launch the instance. 152 ImageID string `json:"imageId,omitempty"` 153 154 // The name of the SSH key pair. 155 SSHKeyName *string `json:"sshKeyName,omitempty"` 156 157 // SecurityGroupIDs are one or more security group IDs this instance belongs to. 158 SecurityGroupIDs []string `json:"securityGroupIds,omitempty"` 159 160 // UserData is the raw data script passed to the instance which is run upon bootstrap. 161 // This field must not be base64 encoded and should only be used when running a new instance. 162 UserData *string `json:"userData,omitempty"` 163 164 // The name of the IAM instance profile associated with the instance, if applicable. 165 IAMProfile string `json:"iamProfile,omitempty"` 166 167 // Addresses contains the AWS instance associated addresses. 168 Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"` 169 170 // The private IPv4 address assigned to the instance. 171 PrivateIP *string `json:"privateIp,omitempty"` 172 173 // The public IPv4 address assigned to the instance, if applicable. 174 PublicIP *string `json:"publicIp,omitempty"` 175 176 // Specifies whether enhanced networking with ENA is enabled. 177 ENASupport *bool `json:"enaSupport,omitempty"` 178 179 // Indicates whether the instance is optimized for Amazon EBS I/O. 180 EBSOptimized *bool `json:"ebsOptimized,omitempty"` 181 182 // Configuration options for the root storage volume. 183 // +optional 184 RootVolume *Volume `json:"rootVolume,omitempty"` 185 186 // Configuration options for the non root storage volumes. 187 // +optional 188 NonRootVolumes []Volume `json:"nonRootVolumes,omitempty"` 189 190 // Specifies ENIs attached to instance 191 NetworkInterfaces []string `json:"networkInterfaces,omitempty"` 192 193 // The tags associated with the instance. 194 Tags map[string]string `json:"tags,omitempty"` 195 196 // Availability zone of instance 197 AvailabilityZone string `json:"availabilityZone,omitempty"` 198 199 // SpotMarketOptions option for configuring instances to be run using AWS Spot instances. 200 SpotMarketOptions *SpotMarketOptions `json:"spotMarketOptions,omitempty"` 201 202 // Tenancy indicates if instance should run on shared or single-tenant hardware. 203 // +optional 204 Tenancy string `json:"tenancy,omitempty"` 205 206 // IDs of the instance's volumes 207 // +optional 208 VolumeIDs []string `json:"volumeIDs,omitempty"` 209 } 210 211 // Volume encapsulates the configuration options for the storage device. 212 type Volume struct { 213 // Device name 214 // +optional 215 DeviceName string `json:"deviceName,omitempty"` 216 217 // Size specifies size (in Gi) of the storage device. 218 // Must be greater than the image snapshot size or 8 (whichever is greater). 219 // +kubebuilder:validation:Minimum=8 220 Size int64 `json:"size"` 221 222 // Type is the type of the volume (e.g. gp2, io1, etc...). 223 // +optional 224 Type VolumeType `json:"type,omitempty"` 225 226 // IOPS is the number of IOPS requested for the disk. Not applicable to all types. 227 // +optional 228 IOPS int64 `json:"iops,omitempty"` 229 230 // Throughput to provision in MiB/s supported for the volume type. Not applicable to all types. 231 // +optional 232 Throughput *int64 `json:"throughput,omitempty"` 233 234 // Encrypted is whether the volume should be encrypted or not. 235 // +optional 236 Encrypted *bool `json:"encrypted,omitempty"` 237 238 // EncryptionKey is the KMS key to use to encrypt the volume. Can be either a KMS key ID or ARN. 239 // If Encrypted is set and this is omitted, the default AWS key will be used. 240 // The key must already exist and be accessible by the controller. 241 // +optional 242 EncryptionKey string `json:"encryptionKey,omitempty"` 243 } 244 245 // VolumeType describes the EBS volume type. 246 // See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html 247 type VolumeType string 248 249 var ( 250 // VolumeTypeIO1 is the string representing a provisioned iops ssd io1 volume. 251 VolumeTypeIO1 = VolumeType("io1") 252 253 // VolumeTypeIO2 is the string representing a provisioned iops ssd io2 volume. 254 VolumeTypeIO2 = VolumeType("io2") 255 256 // VolumeTypeGP2 is the string representing a general purpose ssd gp2 volume. 257 VolumeTypeGP2 = VolumeType("gp2") 258 259 // VolumeTypeGP3 is the string representing a general purpose ssd gp3 volume. 260 VolumeTypeGP3 = VolumeType("gp3") 261 262 // VolumeTypesGP are volume types provisioned for general purpose io. 263 VolumeTypesGP = sets.NewString( 264 string(VolumeTypeIO1), 265 string(VolumeTypeIO2), 266 ) 267 268 // VolumeTypesProvisioned are volume types provisioned for high performance io. 269 VolumeTypesProvisioned = sets.NewString( 270 string(VolumeTypeIO1), 271 string(VolumeTypeIO2), 272 ) 273 ) 274 275 // SpotMarketOptions defines the options available to a user when configuring 276 // Machines to run on Spot instances. 277 // Most users should provide an empty struct. 278 type SpotMarketOptions struct { 279 // MaxPrice defines the maximum price the user is willing to pay for Spot VM instances 280 // +optional 281 // +kubebuilder:validation:pattern="^[0-9]+(\.[0-9]+)?$" 282 MaxPrice *string `json:"maxPrice,omitempty"` 283 } 284 285 // EKSAMILookupType specifies which AWS AMI to use for a AWSMachine and AWSMachinePool. 286 type EKSAMILookupType string 287 288 const ( 289 // AmazonLinux is the default AMI type. 290 AmazonLinux EKSAMILookupType = "AmazonLinux" 291 // AmazonLinuxGPU is the AmazonLinux GPU AMI type. 292 AmazonLinuxGPU EKSAMILookupType = "AmazonLinuxGPU" 293 )