Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 9cc0483

Browse files
authored
feat: CAPA 2.4.0 APIs and e2e (nutanix-cloud-native#415)
1 parent 04ff9ee commit 9cc0483

File tree

12 files changed

+333
-276
lines changed

12 files changed

+333
-276
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ type AWSClusterSpec struct {
6060
// +optional
6161
ControlPlaneLoadBalancer *AWSLoadBalancerSpec `json:"controlPlaneLoadBalancer,omitempty"`
6262

63+
// SecondaryControlPlaneLoadBalancer is an additional load balancer that can be used for the control plane.
64+
//
65+
// An example use case is to have a separate internal load balancer for internal traffic,
66+
// and a separate external load balancer for external traffic.
67+
//
68+
// +optional
69+
SecondaryControlPlaneLoadBalancer *AWSLoadBalancerSpec `json:"secondaryControlPlaneLoadBalancer,omitempty"`
70+
6371
// ImageLookupFormat is the AMI naming format to look up machine images when
6472
// a machine does not specify an AMI. When set, this will be used for all
6573
// cluster machines unless a machine specifies a different ImageLookupOrg.
@@ -91,8 +99,10 @@ type AWSClusterSpec struct {
9199
// +optional
92100
Bastion Bastion `json:"bastion"`
93101

94-
// IdentityRef is a reference to a identity to be used when reconciling this cluster
95102
// +optional
103+
104+
// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
105+
// If no identity is specified, the default identity for this controller will be used.
96106
IdentityRef *AWSIdentityReference `json:"identityRef,omitempty"`
97107

98108
// S3Bucket contains options to configure a supporting S3 bucket for this
@@ -159,10 +169,11 @@ type Bastion struct {
159169
type LoadBalancerType string
160170

161171
var (
162-
LoadBalancerTypeClassic = LoadBalancerType("classic")
163-
LoadBalancerTypeELB = LoadBalancerType("elb")
164-
LoadBalancerTypeALB = LoadBalancerType("alb")
165-
LoadBalancerTypeNLB = LoadBalancerType("nlb")
172+
LoadBalancerTypeClassic = LoadBalancerType("classic")
173+
LoadBalancerTypeELB = LoadBalancerType("elb")
174+
LoadBalancerTypeALB = LoadBalancerType("alb")
175+
LoadBalancerTypeNLB = LoadBalancerType("nlb")
176+
LoadBalancerTypeDisabled = LoadBalancerType("disabled")
166177
)
167178

168179
// AWSLoadBalancerSpec defines the desired state of an AWS load balancer.
@@ -221,7 +232,7 @@ type AWSLoadBalancerSpec struct {
221232

222233
// LoadBalancerType sets the type for a load balancer. The default type is classic.
223234
// +kubebuilder:default=classic
224-
// +kubebuilder:validation:Enum:=classic;elb;alb;nlb
235+
// +kubebuilder:validation:Enum:=classic;elb;alb;nlb;disabled
225236
LoadBalancerType LoadBalancerType `json:"loadBalancerType,omitempty"`
226237

227238
// DisableHostsRewrite disabled the hair pinning issue solution that adds the NLB's address as 127.0.0.1 to the hosts

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ var (
4343
SecretBackendSecretsManager = SecretBackend("secrets-manager")
4444
)
4545

46+
// IgnitionStorageTypeOption defines the different storage types for Ignition.
47+
type IgnitionStorageTypeOption string
48+
49+
const (
50+
// IgnitionStorageTypeOptionClusterObjectStore means the chosen Ignition storage type is ClusterObjectStore.
51+
IgnitionStorageTypeOptionClusterObjectStore = IgnitionStorageTypeOption("ClusterObjectStore")
52+
53+
// IgnitionStorageTypeOptionUnencryptedUserData means the chosen Ignition storage type is UnencryptedUserData.
54+
IgnitionStorageTypeOptionUnencryptedUserData = IgnitionStorageTypeOption("UnencryptedUserData")
55+
)
56+
4657
// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
4758
type AWSMachineSpec struct {
4859
// ProviderID is the unique identifier as specified by the cloud provider.
@@ -114,6 +125,11 @@ type AWSMachineSpec struct {
114125
// +optional
115126
Subnet *AWSResourceReference `json:"subnet,omitempty"`
116127

128+
// SecurityGroupOverrides is an optional set of security groups to use for the node.
129+
// This is optional - if not provided security groups from the cluster will be used.
130+
// +optional
131+
SecurityGroupOverrides map[SecurityGroupRole]string `json:"securityGroupOverrides,omitempty"`
132+
117133
// SSHKeyName is the name of the ssh key to attach to the instance. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name)
118134
// +optional
119135
SSHKeyName *string `json:"sshKeyName,omitempty"`
@@ -160,6 +176,10 @@ type AWSMachineSpec struct {
160176
// +optional
161177
// +kubebuilder:validation:Enum:=default;dedicated;host
162178
Tenancy string `json:"tenancy,omitempty"`
179+
180+
// PrivateDNSName is the options for the instance hostname.
181+
// +optional
182+
PrivateDNSName *PrivateDNSName `json:"privateDnsName,omitempty"`
163183
}
164184

165185
// CloudInit defines options related to the bootstrapping systems where
@@ -197,6 +217,26 @@ type Ignition struct {
197217
// +kubebuilder:default="2.3"
198218
// +kubebuilder:validation:Enum="2.3";"3.0";"3.1";"3.2";"3.3";"3.4"
199219
Version string `json:"version,omitempty"`
220+
221+
// StorageType defines how to store the boostrap user data for Ignition.
222+
// This can be used to instruct Ignition from where to fetch the user data to bootstrap an instance.
223+
//
224+
// When omitted, the storage option will default to ClusterObjectStore.
225+
//
226+
// When set to "ClusterObjectStore", if the capability is available and a Cluster ObjectStore configuration
227+
// is correctly provided in the Cluster object (under .spec.s3Bucket),
228+
// an object store will be used to store bootstrap user data.
229+
//
230+
// When set to "UnencryptedUserData", EC2 Instance User Data will be used to store the machine bootstrap user data, unencrypted.
231+
// This option is considered less secure than others as user data may contain sensitive informations (keys, certificates, etc.)
232+
// and users with ec2:DescribeInstances permission or users running pods
233+
// that can access the ec2 metadata service have access to this sensitive information.
234+
// So this is only to be used at ones own risk, and only when other more secure options are not viable.
235+
//
236+
// +optional
237+
// +kubebuilder:default="ClusterObjectStore"
238+
// +kubebuilder:validation:Enum:="ClusterObjectStore";"UnencryptedUserData"
239+
StorageType IgnitionStorageTypeOption `json:"storageType,omitempty"`
200240
}
201241

202242
// AWSMachineStatus defines the observed state of AWSMachine.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ const (
125125
LoadBalancerReadyCondition clusterv1.ConditionType = "LoadBalancerReady"
126126
// WaitForDNSNameReason used while waiting for a DNS name for the API server to be populated.
127127
WaitForDNSNameReason = "WaitForDNSName"
128+
// WaitForExternalControlPlaneEndpointReason is available when the AWS Cluster is waiting for an externally managed
129+
// Load Balancer, such as an external Control Plane provider.
130+
WaitForExternalControlPlaneEndpointReason = "WaitForExternalControlPlaneEndpoint"
128131
// WaitForDNSNameResolveReason used while waiting for DNS name to resolve.
129132
WaitForDNSNameResolveReason = "WaitForDNSNameResolve"
130133
// LoadBalancerFailedReason used when an error occurs during load balancer reconciliation.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func SetDefaults_AWSClusterSpec(s *AWSClusterSpec) { //nolint:golint,stylecheck
6969
if s.ControlPlaneLoadBalancer.LoadBalancerType == "" {
7070
s.ControlPlaneLoadBalancer.LoadBalancerType = LoadBalancerTypeClassic
7171
}
72+
if s.SecondaryControlPlaneLoadBalancer != nil {
73+
if s.SecondaryControlPlaneLoadBalancer.LoadBalancerType == "" {
74+
s.SecondaryControlPlaneLoadBalancer.LoadBalancerType = LoadBalancerTypeNLB
75+
}
76+
if s.SecondaryControlPlaneLoadBalancer.Scheme == nil {
77+
s.SecondaryControlPlaneLoadBalancer.Scheme = &ELBSchemeInternal
78+
}
79+
}
7280
}
7381

7482
// SetDefaults_Labels is used to default cluster scope resources for clusterctl move.

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ type NetworkStatus struct {
3737
// APIServerELB is the Kubernetes api server load balancer.
3838
APIServerELB LoadBalancer `json:"apiServerElb,omitempty"`
3939

40+
// SecondaryAPIServerELB is the secondary Kubernetes api server load balancer.
41+
SecondaryAPIServerELB LoadBalancer `json:"secondaryAPIServerELB,omitempty"`
42+
4043
// NatGatewaysIPs contains the public IPs of the NAT Gateways
4144
NatGatewaysIPs []string `json:"natGatewaysIPs,omitempty"`
4245
}
@@ -323,6 +326,25 @@ type VPCSpec struct {
323326
// +kubebuilder:default=Ordered
324327
// +kubebuilder:validation:Enum=Ordered;Random
325328
AvailabilityZoneSelection *AZSelectionScheme `json:"availabilityZoneSelection,omitempty"`
329+
330+
// EmptyRoutesDefaultVPCSecurityGroup specifies whether the default VPC security group ingress
331+
// and egress rules should be removed.
332+
//
333+
// By default, when creating a VPC, AWS creates a security group called `default` with ingress and egress
334+
// rules that allow traffic from anywhere. The group could be used as a potential surface attack and
335+
// it's generally suggested that the group rules are removed or modified appropriately.
336+
//
337+
// NOTE: This only applies when the VPC is managed by the Cluster API AWS controller.
338+
//
339+
// +optional
340+
EmptyRoutesDefaultVPCSecurityGroup bool `json:"emptyRoutesDefaultVPCSecurityGroup,omitempty"`
341+
342+
// PrivateDNSHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch.
343+
// For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address (ip-name)
344+
// or the instance ID (resource-name). For IPv6 only subnets, an instance DNS name must be based on the instance ID (resource-name).
345+
// +optional
346+
// +kubebuilder:validation:Enum:=ip-name;resource-name
347+
PrivateDNSHostnameTypeOnLaunch *string `json:"privateDnsHostnameTypeOnLaunch,omitempty"`
326348
}
327349

328350
// String returns a string representation of the VPC.
@@ -435,10 +457,13 @@ func (s Subnets) IDs() []string {
435457
}
436458

437459
// FindByID returns a single subnet matching the given id or nil.
460+
//
461+
// The returned pointer can be used to write back into the original slice.
438462
func (s Subnets) FindByID(id string) *SubnetSpec {
439-
for _, x := range s {
463+
for i := range s {
464+
x := &(s[i]) // pointer to original structure
440465
if x.GetResourceID() == id {
441-
return &x
466+
return x
442467
}
443468
}
444469
return nil
@@ -447,12 +472,15 @@ func (s Subnets) FindByID(id string) *SubnetSpec {
447472
// FindEqual returns a subnet spec that is equal to the one passed in.
448473
// Two subnets are defined equal to each other if their id is equal
449474
// or if they are in the same vpc and the cidr block is the same.
475+
//
476+
// The returned pointer can be used to write back into the original slice.
450477
func (s Subnets) FindEqual(spec *SubnetSpec) *SubnetSpec {
451-
for _, x := range s {
478+
for i := range s {
479+
x := &(s[i]) // pointer to original structure
452480
if (spec.GetResourceID() != "" && x.GetResourceID() == spec.GetResourceID()) ||
453481
(spec.CidrBlock == x.CidrBlock) ||
454482
(spec.IPv6CidrBlock != "" && spec.IPv6CidrBlock == x.IPv6CidrBlock) {
455-
return &x
483+
return x
456484
}
457485
}
458486
return nil

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ const (
190190

191191
// MachineNameTagKey is the key for machine name.
192192
MachineNameTagKey = "MachineName"
193+
194+
// LaunchTemplateBootstrapDataSecret is the tag we use to store the `<namespace>/<name>`
195+
// of the bootstrap secret that was used to create the user data for the latest launch
196+
// template version.
197+
LaunchTemplateBootstrapDataSecret = NameAWSProviderPrefix + "bootstrap-data-secret"
193198
)
194199

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

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ type Instance struct {
232232
// InstanceMetadataOptions is the metadata options for the EC2 instance.
233233
// +optional
234234
InstanceMetadataOptions *InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"`
235+
236+
// PrivateDNSName is the options for the instance hostname.
237+
// +optional
238+
PrivateDNSName *PrivateDNSName `json:"privateDnsName,omitempty"`
235239
}
236240

237241
// InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags
@@ -407,3 +411,17 @@ const (
407411
// AmazonLinuxGPU is the AmazonLinux GPU AMI type.
408412
AmazonLinuxGPU EKSAMILookupType = "AmazonLinuxGPU"
409413
)
414+
415+
// PrivateDNSName is the options for the instance hostname.
416+
type PrivateDNSName struct {
417+
// EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records.
418+
// +optional
419+
EnableResourceNameDNSAAAARecord *bool `json:"enableResourceNameDnsAAAARecord,omitempty"`
420+
// EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records.
421+
// +optional
422+
EnableResourceNameDNSARecord *bool `json:"enableResourceNameDnsARecord,omitempty"`
423+
// The type of hostname to assign to an instance.
424+
// +optional
425+
// +kubebuilder:validation:Enum:=ip-name;resource-name
426+
HostnameType *string `json:"hostnameType,omitempty"`
427+
}

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

Lines changed: 60 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)