Skip to content

Commit d182347

Browse files
committed
feat: Pull in EKS APIs
1 parent bab9a86 commit d182347

32 files changed

+3526
-140
lines changed

api/external/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/awsmachine_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ const (
2929

3030
// DefaultIgnitionVersion represents default Ignition version generated for machine userdata.
3131
DefaultIgnitionVersion = "2.3"
32+
33+
// DefaultIgnitionStorageType represents the default storage type of Ignition userdata
34+
DefaultIgnitionStorageType = IgnitionStorageTypeOptionClusterObjectStore
35+
36+
// DefaultMachinePoolIgnitionStorageType represents the default storage type of Ignition userdata for machine pools.
37+
//
38+
// This is only different from DefaultIgnitionStorageType because of backward compatibility. Machine pools used to
39+
// default to store Ignition user data directly on the EC2 instance. Since the choice between remote storage (S3)
40+
// and direct storage was introduced, the default was kept, but might change in newer API versions.
41+
DefaultMachinePoolIgnitionStorageType = IgnitionStorageTypeOptionUnencryptedUserData
3242
)
3343

3444
// SecretBackend defines variants for backend secret storage.
@@ -64,6 +74,8 @@ const (
6474
)
6575

6676
// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
77+
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.marketType) || self.marketType != 'Spot'",message="capacityReservationId may not be set when marketType is Spot"
78+
// +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.spotMarketOptions)",message="capacityReservationId cannot be set when spotMarketOptions is specified"
6779
type AWSMachineSpec struct {
6880
// ProviderID is the unique identifier as specified by the cloud provider.
6981
ProviderID *string `json:"providerID,omitempty"`
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2025 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 v1beta2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// AWSManagedClusterTemplateSpec defines the desired state of AWSManagedClusterTemplate.
24+
type AWSManagedClusterTemplateSpec struct {
25+
Template AWSManagedClusterTemplateResource `json:"template"`
26+
}
27+
28+
// +kubebuilder:object:root=true
29+
// +kubebuilder:resource:path=awsmanagedclustertemplates,scope=Namespaced,categories=cluster-api,shortName=amct
30+
// +kubebuilder:storageversion
31+
32+
// AWSManagedClusterTemplate is the Schema for the AWSManagedClusterTemplates API.
33+
type AWSManagedClusterTemplate struct {
34+
metav1.TypeMeta `json:",inline"`
35+
metav1.ObjectMeta `json:"metadata,omitempty"`
36+
37+
Spec AWSManagedClusterTemplateSpec `json:"spec,omitempty"`
38+
}
39+
40+
// +kubebuilder:object:root=true
41+
42+
// AWSManagedClusterTemplateList contains a list of AWSManagedClusterTemplates.
43+
type AWSManagedClusterTemplateList struct {
44+
metav1.TypeMeta `json:",inline"`
45+
metav1.ListMeta `json:"metadata,omitempty"`
46+
Items []AWSManagedClusterTemplate `json:"items"`
47+
}
48+
49+
func init() {
50+
SchemeBuilder.Register(&AWSManagedClusterTemplate{}, &AWSManagedClusterTemplateList{})
51+
}
52+
53+
// AWSManagedClusterTemplateResource describes the data needed to create an AWSManagedCluster from a template.
54+
type AWSManagedClusterTemplateResource struct {
55+
Spec AWSManagedClusterSpec `json:"spec"`
56+
}

api/external/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"sort"
2222
"time"
2323

24+
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
2425
"github.com/aws/aws-sdk-go/aws"
25-
"github.com/aws/aws-sdk-go/service/ec2"
2626
"k8s.io/utils/ptr"
2727
)
2828

@@ -207,6 +207,14 @@ type TargetGroupAttribute string
207207
var (
208208
// TargetGroupAttributeEnablePreserveClientIP defines the attribute key for enabling preserve client IP.
209209
TargetGroupAttributeEnablePreserveClientIP = "preserve_client_ip.enabled"
210+
211+
// TargetGroupAttributeEnableConnectionTermination defines the attribute key for terminating
212+
// established connections to unhealthy targets.
213+
TargetGroupAttributeEnableConnectionTermination = "target_health_state.unhealthy.connection_termination.enabled"
214+
215+
// TargetGroupAttributeUnhealthyDrainingIntervalSeconds defines the attribute key for the
216+
// unhealthy target connection draining interval.
217+
TargetGroupAttributeUnhealthyDrainingIntervalSeconds = "target_health_state.unhealthy.draining_interval_seconds"
210218
)
211219

212220
// LoadBalancerAttribute defines a set of attributes for a V2 load balancer.
@@ -352,6 +360,10 @@ type NetworkSpec struct {
352360
// +optional
353361
AdditionalControlPlaneIngressRules []IngressRule `json:"additionalControlPlaneIngressRules,omitempty"`
354362

363+
// AdditionalNodeIngressRules is an optional set of ingress rules to add to every node
364+
// +optional
365+
AdditionalNodeIngressRules []IngressRule `json:"additionalNodeIngressRules,omitempty"`
366+
355367
// NodePortIngressRuleCidrBlocks is an optional set of CIDR blocks to allow traffic to nodes' NodePort services.
356368
// If none are specified here, all IPs are allowed to connect.
357369
// +optional
@@ -655,11 +667,11 @@ func (s *SubnetSpec) IsEdgeWavelength() bool {
655667
}
656668

657669
// SetZoneInfo updates the subnets with zone information.
658-
func (s *SubnetSpec) SetZoneInfo(zones []*ec2.AvailabilityZone) error {
659-
zoneInfo := func(zoneName string) *ec2.AvailabilityZone {
670+
func (s *SubnetSpec) SetZoneInfo(zones []types.AvailabilityZone) error {
671+
zoneInfo := func(zoneName string) *types.AvailabilityZone {
660672
for _, zone := range zones {
661673
if aws.StringValue(zone.ZoneName) == zoneName {
662-
return zone
674+
return &zone
663675
}
664676
}
665677
return nil
@@ -814,7 +826,7 @@ func (s Subnets) GetUniqueZones() []string {
814826
}
815827

816828
// SetZoneInfo updates the subnets with zone information.
817-
func (s Subnets) SetZoneInfo(zones []*ec2.AvailabilityZone) error {
829+
func (s Subnets) SetZoneInfo(zones []types.AvailabilityZone) error {
818830
for i := range s {
819831
if err := s[i].SetZoneInfo(zones); err != nil {
820832
return err

api/external/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/tags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ const (
195195
// of the bootstrap secret that was used to create the user data for the latest launch
196196
// template version.
197197
LaunchTemplateBootstrapDataSecret = NameAWSProviderPrefix + "bootstrap-data-secret"
198+
199+
// LaunchTemplateBootstrapDataHash is the tag we use to store the hash of the raw bootstrap data.
200+
// If bootstrap data is stored in S3, this hash relates to that data, not to the EC2 instance
201+
// user data which only references the S3 object. We store this tag on launch template versions
202+
// so that S3 bootstrap data objects can be deleted when they get outdated.
203+
LaunchTemplateBootstrapDataHash = NameAWSProviderPrefix + "bootstrap-data-hash"
198204
)
199205

200206
// ClusterTagKey generates the key for resources associated with a cluster.

api/external/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/zz_generated.deepcopy.go

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2022 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 v1beta2
18+
19+
import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
20+
21+
// Conditions and condition Reasons for the EKSConfig object
22+
// FROM: https://github.com/kubernetes-sigs/cluster-api/blob/main/bootstrap/kubeadm/api/v1beta1/condition_consts.go
23+
24+
const (
25+
// DataSecretAvailableCondition documents the status of the bootstrap secret generation process.
26+
//
27+
// NOTE: When the DataSecret generation starts the process completes immediately and within the
28+
// same reconciliation, so the user will always see a transition from Wait to Generated without having
29+
// evidence that BootstrapSecret generation is started/in progress.
30+
DataSecretAvailableCondition clusterv1.ConditionType = "DataSecretAvailable"
31+
32+
// DataSecretGenerationFailedReason (Severity=Warning) documents a EKSConfig controller detecting
33+
// an error while generating a data secret; those kind of errors are usually due to misconfigurations
34+
// and user intervention is required to get them fixed.
35+
DataSecretGenerationFailedReason = "DataSecretGenerationFailed"
36+
37+
// WaitingForClusterInfrastructureReason (Severity=Info) document a bootstrap secret generation process
38+
// waiting for the cluster infrastructure to be ready.
39+
//
40+
// NOTE: Having the cluster infrastructure ready is a pre-condition for starting to create machines;
41+
// the EKSConfig controller ensure this pre-condition is satisfied.
42+
WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure"
43+
44+
// WaitingForControlPlaneInitializationReason (Severity=Info) documents a bootstrap secret generation process
45+
// waiting for the control plane to be initialized.
46+
//
47+
// NOTE: This is a pre-condition for starting to create machines;
48+
// the EKSConfig controller ensure this pre-condition is satisfied.
49+
WaitingForControlPlaneInitializationReason = "WaitingForControlPlaneInitialization"
50+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2022 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 v1beta2
18+
19+
// Hub marks EKSConfig as a conversion hub.
20+
func (*EKSConfig) Hub() {}
21+
22+
// Hub marks EKSConfigList as a conversion hub.
23+
func (*EKSConfigList) Hub() {}
24+
25+
// Hub marks EKSConfigTemplate as a conversion hub.
26+
func (*EKSConfigTemplate) Hub() {}
27+
28+
// Hub marks EKSConfigTemplateList as a conversion hub.
29+
func (*EKSConfigTemplateList) Hub() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2022 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 v1beta2 contains API Schema definitions for the Amazon EKS Bootstrap v1beta2 API group.
18+
// +gencrdrefdocs:force //nolint: revive
19+
// +groupName=bootstrap.cluster.x-k8s.io
20+
// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta1
21+
package v1beta2

0 commit comments

Comments
 (0)