Skip to content

feat: CAPA 2.4.0 APIs and e2e #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ type AWSClusterSpec struct {
// +optional
ControlPlaneLoadBalancer *AWSLoadBalancerSpec `json:"controlPlaneLoadBalancer,omitempty"`

// SecondaryControlPlaneLoadBalancer is an additional load balancer that can be used for the control plane.
//
// An example use case is to have a separate internal load balancer for internal traffic,
// and a separate external load balancer for external traffic.
//
// +optional
SecondaryControlPlaneLoadBalancer *AWSLoadBalancerSpec `json:"secondaryControlPlaneLoadBalancer,omitempty"`

// ImageLookupFormat is the AMI naming format to look up machine images when
// a machine does not specify an AMI. When set, this will be used for all
// cluster machines unless a machine specifies a different ImageLookupOrg.
Expand Down Expand Up @@ -91,8 +99,10 @@ type AWSClusterSpec struct {
// +optional
Bastion Bastion `json:"bastion"`

// IdentityRef is a reference to a identity to be used when reconciling this cluster
// +optional

// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
// If no identity is specified, the default identity for this controller will be used.
IdentityRef *AWSIdentityReference `json:"identityRef,omitempty"`

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

var (
LoadBalancerTypeClassic = LoadBalancerType("classic")
LoadBalancerTypeELB = LoadBalancerType("elb")
LoadBalancerTypeALB = LoadBalancerType("alb")
LoadBalancerTypeNLB = LoadBalancerType("nlb")
LoadBalancerTypeClassic = LoadBalancerType("classic")
LoadBalancerTypeELB = LoadBalancerType("elb")
LoadBalancerTypeALB = LoadBalancerType("alb")
LoadBalancerTypeNLB = LoadBalancerType("nlb")
LoadBalancerTypeDisabled = LoadBalancerType("disabled")
)

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

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

// DisableHostsRewrite disabled the hair pinning issue solution that adds the NLB's address as 127.0.0.1 to the hosts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ var (
SecretBackendSecretsManager = SecretBackend("secrets-manager")
)

// IgnitionStorageTypeOption defines the different storage types for Ignition.
type IgnitionStorageTypeOption string

const (
// IgnitionStorageTypeOptionClusterObjectStore means the chosen Ignition storage type is ClusterObjectStore.
IgnitionStorageTypeOptionClusterObjectStore = IgnitionStorageTypeOption("ClusterObjectStore")

// IgnitionStorageTypeOptionUnencryptedUserData means the chosen Ignition storage type is UnencryptedUserData.
IgnitionStorageTypeOptionUnencryptedUserData = IgnitionStorageTypeOption("UnencryptedUserData")
)

// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
type AWSMachineSpec struct {
// ProviderID is the unique identifier as specified by the cloud provider.
Expand Down Expand Up @@ -114,6 +125,11 @@ type AWSMachineSpec struct {
// +optional
Subnet *AWSResourceReference `json:"subnet,omitempty"`

// SecurityGroupOverrides is an optional set of security groups to use for the node.
// This is optional - if not provided security groups from the cluster will be used.
// +optional
SecurityGroupOverrides map[SecurityGroupRole]string `json:"securityGroupOverrides,omitempty"`

// 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)
// +optional
SSHKeyName *string `json:"sshKeyName,omitempty"`
Expand Down Expand Up @@ -160,6 +176,10 @@ type AWSMachineSpec struct {
// +optional
// +kubebuilder:validation:Enum:=default;dedicated;host
Tenancy string `json:"tenancy,omitempty"`

// PrivateDNSName is the options for the instance hostname.
// +optional
PrivateDNSName *PrivateDNSName `json:"privateDnsName,omitempty"`
}

// CloudInit defines options related to the bootstrapping systems where
Expand Down Expand Up @@ -197,6 +217,26 @@ type Ignition struct {
// +kubebuilder:default="2.3"
// +kubebuilder:validation:Enum="2.3";"3.0";"3.1";"3.2";"3.3";"3.4"
Version string `json:"version,omitempty"`

// StorageType defines how to store the boostrap user data for Ignition.
// This can be used to instruct Ignition from where to fetch the user data to bootstrap an instance.
//
// When omitted, the storage option will default to ClusterObjectStore.
//
// When set to "ClusterObjectStore", if the capability is available and a Cluster ObjectStore configuration
// is correctly provided in the Cluster object (under .spec.s3Bucket),
// an object store will be used to store bootstrap user data.
//
// When set to "UnencryptedUserData", EC2 Instance User Data will be used to store the machine bootstrap user data, unencrypted.
// This option is considered less secure than others as user data may contain sensitive informations (keys, certificates, etc.)
// and users with ec2:DescribeInstances permission or users running pods
// that can access the ec2 metadata service have access to this sensitive information.
// So this is only to be used at ones own risk, and only when other more secure options are not viable.
//
// +optional
// +kubebuilder:default="ClusterObjectStore"
// +kubebuilder:validation:Enum:="ClusterObjectStore";"UnencryptedUserData"
StorageType IgnitionStorageTypeOption `json:"storageType,omitempty"`
}

// AWSMachineStatus defines the observed state of AWSMachine.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ const (
LoadBalancerReadyCondition clusterv1.ConditionType = "LoadBalancerReady"
// WaitForDNSNameReason used while waiting for a DNS name for the API server to be populated.
WaitForDNSNameReason = "WaitForDNSName"
// WaitForExternalControlPlaneEndpointReason is available when the AWS Cluster is waiting for an externally managed
// Load Balancer, such as an external Control Plane provider.
WaitForExternalControlPlaneEndpointReason = "WaitForExternalControlPlaneEndpoint"
// WaitForDNSNameResolveReason used while waiting for DNS name to resolve.
WaitForDNSNameResolveReason = "WaitForDNSNameResolve"
// LoadBalancerFailedReason used when an error occurs during load balancer reconciliation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ func SetDefaults_AWSClusterSpec(s *AWSClusterSpec) { //nolint:golint,stylecheck
if s.ControlPlaneLoadBalancer.LoadBalancerType == "" {
s.ControlPlaneLoadBalancer.LoadBalancerType = LoadBalancerTypeClassic
}
if s.SecondaryControlPlaneLoadBalancer != nil {
if s.SecondaryControlPlaneLoadBalancer.LoadBalancerType == "" {
s.SecondaryControlPlaneLoadBalancer.LoadBalancerType = LoadBalancerTypeNLB
}
if s.SecondaryControlPlaneLoadBalancer.Scheme == nil {
s.SecondaryControlPlaneLoadBalancer.Scheme = &ELBSchemeInternal
}
}
}

// SetDefaults_Labels is used to default cluster scope resources for clusterctl move.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type NetworkStatus struct {
// APIServerELB is the Kubernetes api server load balancer.
APIServerELB LoadBalancer `json:"apiServerElb,omitempty"`

// SecondaryAPIServerELB is the secondary Kubernetes api server load balancer.
SecondaryAPIServerELB LoadBalancer `json:"secondaryAPIServerELB,omitempty"`

// NatGatewaysIPs contains the public IPs of the NAT Gateways
NatGatewaysIPs []string `json:"natGatewaysIPs,omitempty"`
}
Expand Down Expand Up @@ -323,6 +326,25 @@ type VPCSpec struct {
// +kubebuilder:default=Ordered
// +kubebuilder:validation:Enum=Ordered;Random
AvailabilityZoneSelection *AZSelectionScheme `json:"availabilityZoneSelection,omitempty"`

// EmptyRoutesDefaultVPCSecurityGroup specifies whether the default VPC security group ingress
// and egress rules should be removed.
//
// By default, when creating a VPC, AWS creates a security group called `default` with ingress and egress
// rules that allow traffic from anywhere. The group could be used as a potential surface attack and
// it's generally suggested that the group rules are removed or modified appropriately.
//
// NOTE: This only applies when the VPC is managed by the Cluster API AWS controller.
//
// +optional
EmptyRoutesDefaultVPCSecurityGroup bool `json:"emptyRoutesDefaultVPCSecurityGroup,omitempty"`

// PrivateDNSHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch.
// For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address (ip-name)
// or the instance ID (resource-name). For IPv6 only subnets, an instance DNS name must be based on the instance ID (resource-name).
// +optional
// +kubebuilder:validation:Enum:=ip-name;resource-name
PrivateDNSHostnameTypeOnLaunch *string `json:"privateDnsHostnameTypeOnLaunch,omitempty"`
}

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

// FindByID returns a single subnet matching the given id or nil.
//
// The returned pointer can be used to write back into the original slice.
func (s Subnets) FindByID(id string) *SubnetSpec {
for _, x := range s {
for i := range s {
x := &(s[i]) // pointer to original structure
if x.GetResourceID() == id {
return &x
return x
}
}
return nil
Expand All @@ -447,12 +472,15 @@ func (s Subnets) FindByID(id string) *SubnetSpec {
// FindEqual returns a subnet spec that is equal to the one passed in.
// Two subnets are defined equal to each other if their id is equal
// or if they are in the same vpc and the cidr block is the same.
//
// The returned pointer can be used to write back into the original slice.
func (s Subnets) FindEqual(spec *SubnetSpec) *SubnetSpec {
for _, x := range s {
for i := range s {
x := &(s[i]) // pointer to original structure
if (spec.GetResourceID() != "" && x.GetResourceID() == spec.GetResourceID()) ||
(spec.CidrBlock == x.CidrBlock) ||
(spec.IPv6CidrBlock != "" && spec.IPv6CidrBlock == x.IPv6CidrBlock) {
return &x
return x
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ const (

// MachineNameTagKey is the key for machine name.
MachineNameTagKey = "MachineName"

// LaunchTemplateBootstrapDataSecret is the tag we use to store the `<namespace>/<name>`
// of the bootstrap secret that was used to create the user data for the latest launch
// template version.
LaunchTemplateBootstrapDataSecret = NameAWSProviderPrefix + "bootstrap-data-secret"
)

// ClusterTagKey generates the key for resources associated with a cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ type Instance struct {
// 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"`
}

// InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags
Expand Down Expand Up @@ -407,3 +411,17 @@ const (
// AmazonLinuxGPU is the AmazonLinux GPU AMI type.
AmazonLinuxGPU EKSAMILookupType = "AmazonLinuxGPU"
)

// 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"`
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading