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