sigs.k8s.io/cluster-api-provider-aws@v1.5.5/exp/api/v1alpha3/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 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 22 infrav1alpha3 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3" 23 ) 24 25 // EBS can be used to automatically set up EBS volumes when an instance is launched. 26 type EBS struct { 27 // Encrypted is whether the volume should be encrypted or not. 28 // +optional 29 Encrypted bool `json:"encrypted,omitempty"` 30 31 // The size of the volume, in GiB. 32 // This can be a number from 1-1,024 for standard, 4-16,384 for io1, 1-16,384 33 // for gp2, and 500-16,384 for st1 and sc1. If you specify a snapshot, the volume 34 // size must be equal to or larger than the snapshot size. 35 // +optional 36 VolumeSize int64 `json:"volumeSize,omitempty"` 37 38 // The volume type 39 // For more information, see Amazon EBS Volume Types (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html) 40 // +kubebuilder:validation:Enum=standard;io1;gp2;st1;sc1;io2 41 // +optional 42 VolumeType string `json:"volumeType,omitempty"` 43 } 44 45 // BlockDeviceMapping specifies the block devices for the instance. 46 // You can specify virtual devices and EBS volumes. 47 type BlockDeviceMapping struct { 48 // The device name exposed to the EC2 instance (for example, /dev/sdh or xvdh). 49 // +kubebuilder:validation:Required 50 DeviceName string `json:"deviceName,omitempty"` 51 52 // You can specify either VirtualName or Ebs, but not both. 53 // +optional 54 Ebs EBS `json:"ebs,omitempty"` 55 } 56 57 // AWSLaunchTemplate defines the desired state of AWSLaunchTemplate 58 type AWSLaunchTemplate struct { 59 // The name of the launch template. 60 Name string `json:"name,omitempty"` 61 62 // The name or the Amazon Resource Name (ARN) of the instance profile associated 63 // with the IAM role for the instance. The instance profile contains the IAM 64 // role. 65 IamInstanceProfile string `json:"iamInstanceProfile,omitempty"` 66 67 // AMI is the reference to the AMI from which to create the machine instance. 68 // +optional 69 AMI infrav1alpha3.AWSResourceReference `json:"ami,omitempty"` 70 71 // ImageLookupFormat is the AMI naming format to look up the image for this 72 // machine It will be ignored if an explicit AMI is set. Supports 73 // substitutions for {{.BaseOS}} and {{.K8sVersion}} with the base OS and 74 // kubernetes version, respectively. The BaseOS will be the value in 75 // ImageLookupBaseOS or ubuntu (the default), and the kubernetes version as 76 // defined by the packages produced by kubernetes/release without v as a 77 // prefix: 1.13.0, 1.12.5-mybuild.1, or 1.17.3. For example, the default 78 // image format of capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-* will end up 79 // searching for AMIs that match the pattern capa-ami-ubuntu-?1.18.0-* for a 80 // Machine that is targeting kubernetes v1.18.0 and the ubuntu base OS. See 81 // also: https://golang.org/pkg/text/template/ 82 // +optional 83 ImageLookupFormat string `json:"imageLookupFormat,omitempty"` 84 85 // ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set. 86 ImageLookupOrg string `json:"imageLookupOrg,omitempty"` 87 88 // ImageLookupBaseOS is the name of the base operating system to use for 89 // image lookup the AMI is not set. 90 ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` 91 92 // InstanceType is the type of instance to create. Example: m4.xlarge 93 InstanceType string `json:"instanceType,omitempty"` 94 95 // RootVolume encapsulates the configuration options for the root volume 96 // +optional 97 RootVolume *infrav1alpha3.Volume `json:"rootVolume,omitempty"` 98 99 // SSHKeyName is the name of the ssh key to attach to the instance. Valid values are empty string 100 // (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name) 101 // +optional 102 SSHKeyName *string `json:"sshKeyName,omitempty"` 103 104 // VersionNumber is the version of the launch template that is applied. 105 // Typically a new version is created when at least one of the following happens: 106 // 1) A new launch template spec is applied. 107 // 2) One or more parameters in an existing template is changed. 108 // 3) A new AMI is discovered. 109 VersionNumber *int64 `json:"versionNumber,omitempty"` 110 111 // AdditionalSecurityGroups is an array of references to security groups that should be applied to the 112 // instances. These security groups would be set in addition to any security groups defined 113 // at the cluster level or in the actuator. 114 // +optional 115 AdditionalSecurityGroups []infrav1alpha3.AWSResourceReference `json:"additionalSecurityGroups,omitempty"` 116 } 117 118 // Overrides are used to override the instance type specified by the launch template with multiple 119 // instance types that can be used to launch On-Demand Instances and Spot Instances. 120 type Overrides struct { 121 InstanceType string `json:"instanceType"` 122 } 123 124 // OnDemandAllocationStrategy indicates how to allocate instance types to fulfill On-Demand capacity. 125 type OnDemandAllocationStrategy string 126 127 var ( 128 // OnDemandAllocationStrategyPrioritized uses the order of instance type overrides 129 // for the LaunchTemplate to define the launch priority of each instance type. 130 OnDemandAllocationStrategyPrioritized = OnDemandAllocationStrategy("prioritized") 131 ) 132 133 // SpotAllocationStrategy indicates how to allocate instances across Spot Instance pools. 134 type SpotAllocationStrategy string 135 136 var ( 137 // SpotAllocationStrategyLowestPrice will make the Auto Scaling group launch 138 // instances using the Spot pools with the lowest price, and evenly allocates 139 // your instances across the number of Spot pools that you specify. 140 SpotAllocationStrategyLowestPrice = SpotAllocationStrategy("lowest-price") 141 142 // SpotAllocationStrategyCapacityOptimized will make the Auto Scaling group launch 143 // instances using Spot pools that are optimally chosen based on the available Spot capacity. 144 SpotAllocationStrategyCapacityOptimized = SpotAllocationStrategy("capacity-optimized") 145 ) 146 147 // InstancesDistribution to configure distribution of On-Demand Instances and Spot Instances. 148 type InstancesDistribution struct { 149 // +kubebuilder:validation:Enum=prioritized 150 // +kubebuilder:default=prioritized 151 OnDemandAllocationStrategy OnDemandAllocationStrategy `json:"onDemandAllocationStrategy,omitempty"` 152 153 // +kubebuilder:validation:Enum=lowest-price;capacity-optimized 154 // +kubebuilder:default=lowest-price 155 SpotAllocationStrategy SpotAllocationStrategy `json:"spotAllocationStrategy,omitempty"` 156 157 // +kubebuilder:default=0 158 OnDemandBaseCapacity *int64 `json:"onDemandBaseCapacity,omitempty"` 159 160 // +kubebuilder:default=100 161 OnDemandPercentageAboveBaseCapacity *int64 `json:"onDemandPercentageAboveBaseCapacity,omitempty"` 162 } 163 164 // MixedInstancesPolicy for an Auto Scaling group. 165 type MixedInstancesPolicy struct { 166 InstancesDistribution *InstancesDistribution `json:"instancesDistribution,omitempty"` 167 Overrides []Overrides `json:"overrides,omitempty"` 168 } 169 170 // Tags is a mapping for tags. 171 type Tags map[string]string 172 173 // AutoScalingGroup describes an AWS autoscaling group. 174 type AutoScalingGroup struct { 175 // The tags associated with the instance. 176 ID string `json:"id,omitempty"` 177 Tags infrav1alpha3.Tags `json:"tags,omitempty"` 178 Name string `json:"name,omitempty"` 179 DesiredCapacity *int32 `json:"desiredCapacity,omitempty"` 180 MaxSize int32 `json:"maxSize,omitempty"` 181 MinSize int32 `json:"minSize,omitempty"` 182 PlacementGroup string `json:"placementGroup,omitempty"` 183 Subnets []string `json:"subnets,omitempty"` 184 DefaultCoolDown metav1.Duration `json:"defaultCoolDown,omitempty"` 185 CapacityRebalance bool `json:"capacityRebalance,omitempty"` 186 187 MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"` 188 Status ASGStatus 189 Instances []infrav1alpha3.Instance `json:"instances,omitempty"` 190 } 191 192 // ASGStatus is a status string returned by the autoscaling API 193 type ASGStatus string 194 195 var ( 196 // ASGStatusDeleteInProgress is the string representing an ASG that is currently deleting. 197 ASGStatusDeleteInProgress = ASGStatus("Delete in progress") 198 )