Repository navigation
Expand file tree
/
Copy pathtypes.go
More file actions
697 lines (561 loc) · 28.8 KB
/
Copy pathtypes.go
File metadata and controls
697 lines (561 loc) · 28.8 KB
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/*
Copyright 2022 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 v1beta2
import (
"strings"
"k8s.io/apimachinery/pkg/util/sets"
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
)
const (
// PreventDeletionLabel can be used in situations where preventing delation is allowed. The docs
// and the CRD will call this out where its allowed.
PreventDeletionLabel = "aws.cluster.x-k8s.io/prevent-deletion"
)
// 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"`
// 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, EKS optimized lookup, or filters.
// Only one of ID, EKSOptimizedLookupType, or Filters may be specified. Specifying more than one will result in
// a validation error.
// +kubebuilder:validation:XValidation:rule="[has(self.id), has(self.eksLookupType), has(self.filters) && size(self.filters) > 0].filter(x, x).size() <= 1",message="only one of id, eksLookupType, or filters may be specified"
// +kubebuilder:validation:XValidation:rule="!has(self.filters) || self.filters.all(f, size(f.name) > 0 && size(f.values) > 0)",message="each ami.filters entry must have a non-empty name and at least one value"
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;AmazonLinux2023;AmazonLinux2023GPU
// +optional
EKSOptimizedLookupType *EKSAMILookupType `json:"eksLookupType,omitempty"`
// Filters is a set of key/value pairs used to identify an AMI.
// They are applied according to the rules defined by the AWS API:
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html
//
// When multiple AMIs match, the most recently created one (by CreationDate)
// is selected. The result is therefore not pinned and may change as new
// matching images are published; set ID instead when a stable, reproducible
// image is required.
//
// Filters is mutually exclusive with id, eksLookupType, imageLookupFormat,
// imageLookupOrg, and imageLookupBaseOS.
// +optional
Filters []Filter `json:"filters,omitempty"`
// OwnerIDs is a list of AWS account IDs that own the AMI. When omitted,
// all AMIs visible to the caller's credentials are searched. Set to
// ["self"] to restrict the search to the current account, or list specific
// account IDs to search across accounts.
// Only used when Filters is non-empty; ignored when ID is set.
// +optional
OwnerIDs []string `json:"ownerIDs,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"
)
const (
// ExternalResourceGCAnnotation is the name of an annotation that indicates if
// external resources should be garbage collected for the cluster.
ExternalResourceGCAnnotation = "aws.cluster.x-k8s.io/external-resource-gc"
// ExternalResourceGCTasksAnnotation is the name of an annotation that indicates what
// external resources tasks should be executed by garbage collector for the cluster.
ExternalResourceGCTasksAnnotation = "aws.cluster.x-k8s.io/external-resource-tasks-gc"
)
// GCTask defines a task to be executed by the garbage collector.
type GCTask string
var (
// GCTaskLoadBalancer defines a task to cleaning up resources for AWS load balancers.
GCTaskLoadBalancer = GCTask("load-balancer")
// GCTaskTargetGroup defines a task to cleaning up resources for AWS target groups.
GCTaskTargetGroup = GCTask("target-group")
// GCTaskSecurityGroup defines a task to cleaning up resources for AWS security groups.
GCTaskSecurityGroup = GCTask("security-group")
)
// 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 []clusterv1beta1.MachineAddress `json:"addresses,omitempty"`
// The private IPv4 address assigned to the instance.
PrivateIP *string `json:"privateIp,omitempty"`
// The IPv6 address assigned to the instance.
IPv6Address *string `json:"ipv6Address,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"`
// NetworkInterfaceType is the interface type of the primary network Interface.
NetworkInterfaceType NetworkInterfaceType `json:"networkInterfaceType,omitempty"`
// AssignPrimaryIPv6 specifies whether to enable assigning a primary IPv6 address to the primary network Interface.
AssignPrimaryIPv6 *PrimaryIPv6AssignmentState `json:"assignPrimaryIPv6,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"`
// PlacementGroupName specifies the name of the placement group in which to launch the instance.
// +optional
PlacementGroupName string `json:"placementGroupName,omitempty"`
// PlacementGroupPartition is the partition number within the placement group in which to launch the instance.
// This value is only valid if the placement group, referred in `PlacementGroupName`, was created with
// strategy set to partition.
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=7
// +optional
PlacementGroupPartition int64 `json:"placementGroupPartition,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"`
// InstanceMetadataOptions is the metadata options for the EC2 instance.
// +optional
InstanceMetadataOptions *InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"`
// PrivateDNSName is the options for the instance hostname.
// +optional
PrivateDNSName *PrivateDNSName `json:"privateDnsName,omitempty"`
// PublicIPOnLaunch is the option to associate a public IP on instance launch
// +optional
PublicIPOnLaunch *bool `json:"publicIPOnLaunch,omitempty"`
// CapacityReservationID specifies the target Capacity Reservation into which the instance should be launched.
// +optional
CapacityReservationID *string `json:"capacityReservationId,omitempty"`
// MarketType specifies the type of market for the EC2 instance. Valid values include:
// "OnDemand" (default): The instance runs as a standard OnDemand instance.
// "Spot": The instance runs as a Spot instance. When SpotMarketOptions is provided, the marketType defaults to "Spot".
// "CapacityBlock": The instance utilizes pre-purchased compute capacity (capacity blocks) with AWS Capacity Reservations.
// If this value is selected, CapacityReservationID must be specified to identify the target reservation.
// If marketType is not specified and spotMarketOptions is provided, the marketType defaults to "Spot".
// +optional
MarketType MarketType `json:"marketType,omitempty"`
// HostAffinity specifies the dedicated host affinity setting for the instance.
// When HostAffinity is set to "host", an instance started onto a specific host always restarts on the same host if stopped:
// - If HostID is set, the instance launches on the specific host and must return to that same host after any stop/start (Targeted & Pinned).
// - If HostID is not set, the instance gets launched on any available and must returns to the same host after any stop/start (Auto-placed & Pinned).
// When HostAffinity is set to "default" (the default value), the instance (when restarted) can return on any available host:
// - If HostID is set, the instance launches on the specified host now, but (when restarted) can return to any available hosts (Targeted & Flexible).
// - If HostID is not set, the instance launches on any available host now, and (when restarted) can return to any available hosts (Auto-placed & Flexible).
// +optional
// +kubebuilder:validation:Enum:=default;host
HostAffinity *string `json:"hostAffinity,omitempty"`
// HostID specifies the dedicated host on which the instance should be started.
// +optional
HostID *string `json:"hostID,omitempty"`
// DynamicHostAllocation enables automatic allocation of dedicated hosts.
// This field is mutually exclusive with HostID.
// +optional
DynamicHostAllocation *DynamicHostAllocationSpec `json:"dynamicHostAllocation,omitempty"`
// CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
// "Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
// "None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
// "CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation. Note that this is incompatible with a MarketType of `Spot`
// +kubebuilder:validation:Enum="";None;CapacityReservationsOnly;Open
// +optional
CapacityReservationPreference CapacityReservationPreference `json:"capacityReservationPreference,omitempty"`
// CPUOptions defines CPU-related settings for the instance, including the confidential computing policy.
// When omitted, this means no opinion and the AWS platform is left to choose a reasonable default.
// +optional
CPUOptions CPUOptions `json:"cpuOptions,omitempty,omitzero"`
}
// CapacityReservationPreference describes the preferred use of capacity reservations
// of an instance
// +kubebuilder:validation:Enum:="";None;CapacityReservationsOnly;Open
type CapacityReservationPreference string
const (
// CapacityReservationPreferenceNone the instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
CapacityReservationPreferenceNone CapacityReservationPreference = "None"
// CapacityReservationPreferenceOnly the instance will only run if matched or targeted to a Capacity Reservation. Note that this is incompatible with a MarketType of `Spot`
CapacityReservationPreferenceOnly CapacityReservationPreference = "CapacityReservationsOnly"
// CapacityReservationPreferenceOpen the instance may make use of open Capacity Reservations that match its AZ and InstanceType.
CapacityReservationPreferenceOpen CapacityReservationPreference = "Open"
)
// DedicatedHostInfo contains information about a dedicated host.
type DedicatedHostInfo struct {
// HostID is the ID of the dedicated host.
HostID string `json:"hostID"`
// InstanceFamily is the instance family supported by the host.
InstanceFamily string `json:"instanceFamily"`
// InstanceType is the instance type supported by the host.
InstanceType string `json:"instanceType"`
// AvailabilityZone is the AZ where the host is located.
AvailabilityZone string `json:"availabilityZone"`
// State is the current state of the dedicated host.
State string `json:"state"`
// TotalCapacity is the total number of instances that can be launched on the host.
TotalCapacity int32 `json:"totalCapacity"`
// AvailableCapacity is the number of instances that can still be launched on the host.
AvailableCapacity int32 `json:"availableCapacity"`
// Tags associated with the dedicated host.
Tags map[string]string `json:"tags,omitempty"`
}
// MarketType describes the market type of an Instance
// +kubebuilder:validation:Enum:=OnDemand;Spot;CapacityBlock
type MarketType string
const (
// MarketTypeOnDemand is a MarketType enum value
MarketTypeOnDemand MarketType = "OnDemand"
// MarketTypeSpot is a MarketType enum value
MarketTypeSpot MarketType = "Spot"
// MarketTypeCapacityBlock is a MarketType enum value
MarketTypeCapacityBlock MarketType = "CapacityBlock"
)
// InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags
type InstanceMetadataState string
const (
// InstanceMetadataEndpointStateDisabled represents the disabled state
InstanceMetadataEndpointStateDisabled = InstanceMetadataState("disabled")
// InstanceMetadataEndpointStateEnabled represents the enabled state
InstanceMetadataEndpointStateEnabled = InstanceMetadataState("enabled")
)
// HTTPTokensState describes the state of InstanceMetadataOptions.HTTPTokensState
type HTTPTokensState string
const (
// HTTPTokensStateOptional represents the optional state
HTTPTokensStateOptional = HTTPTokensState("optional")
// HTTPTokensStateRequired represents the required state (IMDSv2)
HTTPTokensStateRequired = HTTPTokensState("required")
)
// PrimaryIPv6AssignmentState describes whether to assign a primary IPv6 address to the primary network interface.
type PrimaryIPv6AssignmentState string
const (
// PrimaryIPv6AssignmentStateEnabled enables assigning a primary IPv6 address
PrimaryIPv6AssignmentStateEnabled = PrimaryIPv6AssignmentState("enabled")
// PrimaryIPv6AssignmentStateDisabled disables assigning a primary IPv6 address
PrimaryIPv6AssignmentStateDisabled = PrimaryIPv6AssignmentState("disabled")
)
// SourceDestCheck describes whether the source/destination check is enabled on
// an instance's network interfaces.
// +kubebuilder:validation:Enum=Enabled;Disabled
type SourceDestCheck string
const (
// SourceDestCheckEnabled enables the source/destination check, which is the AWS default.
SourceDestCheckEnabled SourceDestCheck = "Enabled"
// SourceDestCheckDisabled disables the source/destination check, allowing the instance
// to forward traffic for which it is not the source or destination.
SourceDestCheckDisabled SourceDestCheck = "Disabled"
)
// EnclaveOptions defines the options for Nitro Enclave support on the instance.
type EnclaveOptions struct {
// Enabled enables the instance for AWS Nitro Enclaves.
// +optional
Enabled *bool `json:"enabled,omitempty"`
}
// InstanceMetadataOptions describes metadata options for the EC2 instance.
type InstanceMetadataOptions struct {
// Enables or disables the HTTP metadata endpoint on your instances.
//
// If you specify a value of disabled, you cannot access your instance metadata.
//
// Default: enabled
//
// +kubebuilder:validation:Enum:=enabled;disabled
// +kubebuilder:default=enabled
HTTPEndpoint InstanceMetadataState `json:"httpEndpoint,omitempty"`
// Enables or disables the IPv6 endpoint for the instance metadata service.
// This applies only if you enabled the HTTP metadata endpoint.
//
// Default: disabled
//
// +kubebuilder:validation:Enum:=enabled;disabled
// +kubebuilder:default=disabled
HTTPProtocolIPv6 InstanceMetadataState `json:"httpProtocolIpv6,omitempty"`
// The desired HTTP PUT response hop limit for instance metadata requests. The
// larger the number, the further instance metadata requests can travel.
//
// Default: 1
//
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=64
// +kubebuilder:default=1
HTTPPutResponseHopLimit int64 `json:"httpPutResponseHopLimit,omitempty"`
// The state of token usage for your instance metadata requests.
//
// If the state is optional, you can choose to retrieve instance metadata with
// or without a session token on your request. If you retrieve the IAM role
// credentials without a token, the version 1.0 role credentials are returned.
// If you retrieve the IAM role credentials using a valid session token, the
// version 2.0 role credentials are returned.
//
// If the state is required, you must send a session token with any instance
// metadata retrieval requests. In this state, retrieving the IAM role credentials
// always returns the version 2.0 credentials; the version 1.0 credentials are
// not available.
//
// Default: optional
//
// +kubebuilder:validation:Enum:=optional;required
// +kubebuilder:default=optional
HTTPTokens HTTPTokensState `json:"httpTokens,omitempty"`
// Set to enabled to allow access to instance tags from the instance metadata.
// Set to disabled to turn off access to instance tags from the instance metadata.
// For more information, see Work with instance tags using the instance metadata
// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#work-with-tags-in-IMDS).
//
// Default: disabled
//
// +kubebuilder:validation:Enum:=enabled;disabled
// +kubebuilder:default=disabled
InstanceMetadataTags InstanceMetadataState `json:"instanceMetadataTags,omitempty"`
}
// SetDefaults sets the default values for the InstanceMetadataOptions.
func (obj *InstanceMetadataOptions) SetDefaults() {
if obj.HTTPEndpoint == "" {
obj.HTTPEndpoint = InstanceMetadataEndpointStateEnabled
}
if obj.HTTPProtocolIPv6 == "" {
obj.HTTPProtocolIPv6 = InstanceMetadataEndpointStateDisabled
}
if obj.HTTPPutResponseHopLimit == 0 {
obj.HTTPPutResponseHopLimit = 1
}
if obj.HTTPTokens == "" {
obj.HTTPTokens = HTTPTokensStateOptional // Defaults to IMDSv1
}
if obj.InstanceMetadataTags == "" {
obj.InstanceMetadataTags = InstanceMetadataEndpointStateDisabled
}
}
// 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"
// AmazonLinux2023 is the AmazonLinux 2023 AMI type.
AmazonLinux2023 EKSAMILookupType = "AmazonLinux2023"
// AmazonLinux2023GPU is the AmazonLinux 2023 GPU AMI type.
AmazonLinux2023GPU EKSAMILookupType = "AmazonLinux2023GPU"
)
// PrivateDNSName is the options for the instance hostname.
type PrivateDNSName struct {
// EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records.
// +optional
EnableResourceNameDNSAAAARecord *bool `json:"enableResourceNameDnsAAAARecord,omitempty"`
// EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records.
// +optional
EnableResourceNameDNSARecord *bool `json:"enableResourceNameDnsARecord,omitempty"`
// The type of hostname to assign to an instance.
// +optional
// +kubebuilder:validation:Enum:=ip-name;resource-name
HostnameType *string `json:"hostnameType,omitempty"`
}
// SubnetSchemaType specifies how given network should be divided on subnets
// in the VPC depending on the number of AZs.
type SubnetSchemaType string
// Name returns subnet schema type name without prefix.
func (s *SubnetSchemaType) Name() string {
return strings.ToLower(strings.TrimPrefix(string(*s), "Prefer"))
}
var (
// SubnetSchemaPreferPrivate allocates more subnets in the VPC to private subnets.
SubnetSchemaPreferPrivate = SubnetSchemaType("PreferPrivate")
// SubnetSchemaPreferPublic allocates more subnets in the VPC to public subnets.
SubnetSchemaPreferPublic = SubnetSchemaType("PreferPublic")
)
// AWSConfidentialComputePolicy represents the confidential compute configuration for the instance.
// +kubebuilder:validation:Enum=Disabled;AMDEncryptedVirtualizationNestedPaging
type AWSConfidentialComputePolicy string
const (
// AWSConfidentialComputePolicyDisabled disables confidential computing for the instance.
AWSConfidentialComputePolicyDisabled AWSConfidentialComputePolicy = "Disabled"
// AWSConfidentialComputePolicySEVSNP enables AMD SEV-SNP as the confidential computing technology for the instance.
AWSConfidentialComputePolicySEVSNP AWSConfidentialComputePolicy = "AMDEncryptedVirtualizationNestedPaging"
)
// NestedVirtualizationPolicy represents the nested virtualization configuration for the instance.
// +kubebuilder:validation:Enum=enabled;disabled
type NestedVirtualizationPolicy string
const (
// NestedVirtualizationPolicyEnabled enables nested virtualization for the instance.
NestedVirtualizationPolicyEnabled NestedVirtualizationPolicy = "enabled"
// NestedVirtualizationPolicyDisabled disables nested virtualization for the instance.
NestedVirtualizationPolicyDisabled NestedVirtualizationPolicy = "disabled"
)
// CPUOptions defines CPU-related settings for the instance, including the confidential computing policy.
// +kubebuilder:validation:MinProperties=1
type CPUOptions struct {
// ConfidentialCompute specifies whether confidential computing should be enabled for the instance,
// and, if so, which confidential computing technology to use.
// Valid values are: Disabled, AMDEncryptedVirtualizationNestedPaging
// When set to Disabled, confidential computing will be disabled for the instance.
// When set to AMDEncryptedVirtualizationNestedPaging, AMD SEV-SNP will be used as the confidential computing technology for the instance.
// In this case, ensure the following conditions are met:
// 1) The selected instance type supports AMD SEV-SNP.
// 2) The selected AWS region supports AMD SEV-SNP.
// 3) The selected AMI supports AMD SEV-SNP.
// More details can be checked at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sev-snp.html
// When omitted, this means no opinion and the AWS platform is left to choose a reasonable default,
// which is subject to change without notice. The current default is Disabled.
// +optional
ConfidentialCompute AWSConfidentialComputePolicy `json:"confidentialCompute,omitempty"`
// NestedVirtualization specifies whether to enable nested virtualization on the instance.
// Nested virtualization is supported on C8i, M8i, and R8i instance types.
// Valid values are: enabled, disabled
// +optional
NestedVirtualization NestedVirtualizationPolicy `json:"nestedVirtualization,omitempty"`
}