From 7d6ba98628be87a53832051f5565b3c8abb25b73 Mon Sep 17 00:00:00 2001 From: Marco Braga Date: Thu, 14 Mar 2024 11:39:22 -0300 Subject: [PATCH] CORS-2899: CAPA/edge-zones - Local Zones provisioner --- .../v2/api/v1beta2/network_types.go | 76 ++++++ .../pkg/cloud/services/network/natgateways.go | 36 +++ .../pkg/cloud/services/network/routetables.go | 11 +- .../v2/pkg/cloud/services/network/subnets.go | 38 +++ .../aws-infrastructure-components.yaml | 239 ++++++++++-------- pkg/asset/manifests/aws/zones_test.go | 26 +- .../v2/api/v1beta2/network_types.go | 28 ++ 7 files changed, 330 insertions(+), 124 deletions(-) diff --git a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go index d487183025a..856c45333b6 100644 --- a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go +++ b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go @@ -20,6 +20,8 @@ import ( "fmt" "sort" "time" + + "github.com/aws/aws-sdk-go/aws" ) const ( @@ -27,6 +29,12 @@ const ( DefaultAPIServerPort = 6443 // DefaultAPIServerPortString defines the API server port as a string for convenience. DefaultAPIServerPortString = "6443" + // ZoneTypeAvailabilityZone defines the regular AWS zones in the Region. + ZoneTypeAvailabilityZone = "availability-zone" + // ZoneTypeAvailabilityZone defines the AWS zone type in Local Zone infrastructure. + ZoneTypeLocalZone = "local-zone" + // ZoneTypeAvailabilityZone defines the AWS zone type in Wavelength infrastructure. + ZoneTypeWavelengthZone = "wavelength-zone" ) // NetworkStatus encapsulates AWS networking resources. @@ -420,6 +428,36 @@ type SubnetSpec struct { // Tags is a collection of tags describing the resource. Tags Tags `json:"tags,omitempty"` + + // ZoneName defines a zone name for this subnet + // If you're already set AvailabilityZone, it will take precendence. + // + // The valid values are availability-zone, local-zone , and wavelength-zone. + ZoneName *string `json:"zoneName,omitempty"` + + // ZoneType defines a zone type for this subnet + // If you're already set AvailabilityZone, it will take precendence. + // + // The valid values are availability-zone, local-zone , and wavelength-zone. + // + // Zone types local-zone or wavelength-zone is not selected to automatically create + // control plane or compute nodes. + // + // When local-zone, the public subnets will be associated to the public route table, + // the private subnets will try to create a NAT Gateway, when supported, otherwise + // the subnet will be associated to the private route table in the region (preferred parent zone, zone + // type availability-zone in the region, or first available). + // + // When wavelength-zone, the public subnets will be associated to the carrier route table, + // created altogether the Carrier Gateway when public subnets in AWS Wavelength Zone is defined. + // The private subnets will try to create a NAT Gateway, when supported, otherwise + // the subnet will be associated to the private route table in the region (preferred parent zone, zone + // type availability-zone in the region, or first available). + ZoneType *string `json:"zoneType,omitempty"` + + // ParentZoneName defines a parent zone name for the zone that the subnet is created, + // when applied. Available only in zone types local-zone or wavelength-zone. + ParentZoneName *string `json:"parentZoneName,omitempty"` } // GetResourceID returns the identifier for this subnet, @@ -436,6 +474,18 @@ func (s *SubnetSpec) String() string { return fmt.Sprintf("id=%s/az=%s/public=%v", s.GetResourceID(), s.AvailabilityZone, s.IsPublic) } +// IsEdge returns the true when the subnet is created in the edge zone, +// Local Zone or Wavelength. +func (s *SubnetSpec) IsEdge() bool { + if s.ZoneType == nil { + return false + } + if *s.ZoneType == ZoneTypeLocalZone || *s.ZoneType == ZoneTypeWavelengthZone { + return true + } + return false +} + // Subnets is a slice of Subnet. // +listType=map // +listMapKey=id @@ -453,6 +503,20 @@ func (s Subnets) ToMap() map[string]*SubnetSpec { // IDs returns a slice of the subnet ids. func (s Subnets) IDs() []string { + res := []string{} + for _, subnet := range s { + // Do not return edge zones (Local Zone or Wavelength Zone) to regular Subnet IDs, + // to keep compatibility. Use IDsWithEdge() get the the full list of zones + if subnet.IsEdge() { + continue + } + res = append(res, subnet.GetResourceID()) + } + return res +} + +// IDsWithEdge returns a slice of the subnet ids. +func (s Subnets) IDsWithEdge() []string { res := []string{} for _, subnet := range s { res = append(res, subnet.GetResourceID()) @@ -493,6 +557,12 @@ func (s Subnets) FindEqual(spec *SubnetSpec) *SubnetSpec { // FilterPrivate returns a slice containing all subnets marked as private. func (s Subnets) FilterPrivate() (res Subnets) { for _, x := range s { + if x.ZoneType != nil { + switch aws.StringValue(x.ZoneType) { + case ZoneTypeLocalZone, ZoneTypeWavelengthZone: + continue + } + } if !x.IsPublic { res = append(res, x) } @@ -503,6 +573,12 @@ func (s Subnets) FilterPrivate() (res Subnets) { // FilterPublic returns a slice containing all subnets marked as public. func (s Subnets) FilterPublic() (res Subnets) { for _, x := range s { + if x.ZoneType != nil { + switch aws.StringValue(x.ZoneType) { + case ZoneTypeLocalZone, ZoneTypeWavelengthZone: + continue + } + } if x.IsPublic { res = append(res, x) } diff --git a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/natgateways.go b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/natgateways.go index 807594f6046..95bf30a917d 100644 --- a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/natgateways.go +++ b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/natgateways.go @@ -341,3 +341,39 @@ func (s *Service) getNatGatewayForSubnet(sn *infrav1.SubnetSpec) (string, error) return "", errors.Errorf("no nat gateways available in %q for private subnet %q, current state: %+v", sn.AvailabilityZone, sn.GetResourceID(), azGateways) } + +func (s *Service) findNatGatewayForEdgeSubnet(sn *infrav1.SubnetSpec) (string, error) { + if sn.IsPublic { + return "", errors.Errorf("cannot find NAT gateway for a public subnet, got id %q", sn.GetResourceID()) + } + + // Check if public edge subnet in the edge zone has nat gateway + azGateways := make(map[string][]string) + for _, psn := range s.scope.Subnets().FilterPublic() { + if psn.NatGatewayID == nil { + continue + } + azGateways[psn.AvailabilityZone] = append(azGateways[psn.AvailabilityZone], *psn.NatGatewayID) + } + + if gws, ok := azGateways[sn.AvailabilityZone]; ok && len(gws) > 0 { + return gws[0], nil + } + + // if not, check if the parent zone public subnet has nat gateway + if sn.ParentZoneName != nil { + if gws, ok := azGateways[aws.StringValue(sn.ParentZoneName)]; ok && len(gws) > 0 { + return gws[0], nil + } + } + + // if not, get the first public subnet's nat gateway available + for zone, gws := range azGateways { + if len(gws[0]) > 0 { + fmt.Printf("\n>> Assigning route table ID %s to zone %s from zone %s\n", gws[0], sn.AvailabilityZone, zone) + return gws[0], nil + } + } + + return "", errors.Errorf("no nat gateways available in %q for private subnet %q, current state: %+v", sn.AvailabilityZone, sn.GetResourceID(), azGateways) +} diff --git a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/routetables.go b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/routetables.go index 777c12fd64c..8eea5b4b04b 100644 --- a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/routetables.go +++ b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/routetables.go @@ -61,7 +61,7 @@ func (s *Service) reconcileRouteTables() error { sn := &subnets[i] // We need to compile the minimum routes for this subnet first, so we can compare it or create them. var routes []*ec2.Route - if sn.IsPublic { + if sn.IsPublic && !sn.IsEdge() { if s.scope.VPC().InternetGatewayID == nil { return errors.Errorf("failed to create routing tables: internet gateway for %q is nil", s.scope.VPC().ID) } @@ -70,10 +70,17 @@ func (s *Service) reconcileRouteTables() error { routes = append(routes, s.getGatewayPublicIPv6Route()) } } else { - natGatewayID, err := s.getNatGatewayForSubnet(sn) + var natGatewayID string + // private subnets in the edge zones (Local or Wavelength zones) + if sn.IsEdge() { + natGatewayID, err = s.findNatGatewayForEdgeSubnet(sn) + } else { + natGatewayID, err = s.getNatGatewayForSubnet(sn) + } if err != nil { return err } + routes = append(routes, s.getNatGatewayPrivateRoute(natGatewayID)) if sn.IsIPv6 { if !s.scope.VPC().IsIPv6Enabled() { diff --git a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/subnets.go b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/subnets.go index 65a70e7445b..7133bd0a1aa 100644 --- a/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/subnets.go +++ b/cluster-api/providers/aws/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/network/subnets.go @@ -177,6 +177,44 @@ func (s *Service) reconcileSubnets() error { return errors.New("expected at least 1 subnet but got 0") } + // Reconciling the zone attributes for the subnet + zoneNames := make([]string, 0, len(subnets)) + for i := range subnets { + if subnets[i].ZoneType == nil { + zoneNames = append(zoneNames, subnets[i].AvailabilityZone) + } + } + zonesMap := make(map[string]*ec2.AvailabilityZone, len(zoneNames)) + + // s.scope.Info("\n>> Reconciling subnets> ZONES : %v", zoneNames) + fmt.Printf("\n\n >> Reconciling subnets> len(zoneNames) = %d \n\n", len(zoneNames)) + if len(zoneNames) > 0 { + out, err := s.EC2Client.DescribeAvailabilityZonesWithContext(context.TODO(), &ec2.DescribeAvailabilityZonesInput{ + ZoneNames: aws.StringSlice(zoneNames), + }) + if err != nil { + record.Eventf(s.scope.InfraCluster(), "FailedDescribeAvailableZones", "Failed getting available zones: %v", err) + return errors.Wrap(err, "failed to describe availability zones") + } + + for _, zone := range out.AvailabilityZones { + if _, ok := zonesMap[aws.StringValue(zone.ZoneName)]; !ok { + zonesMap[aws.StringValue(zone.ZoneName)] = zone + } + } + for i := range subnets { + sub := &subnets[i] + //if sub.ZoneType != nil { + // continue + //} + // sync required fields + sub.ZoneType = zonesMap[sub.AvailabilityZone].ZoneType + sub.ZoneName = zonesMap[sub.AvailabilityZone].ZoneName + sub.ParentZoneName = zonesMap[sub.AvailabilityZone].ParentZoneName + } + } + fmt.Printf("\n\n>> Reconciling subnets> zonesMap : %v \n\n", zonesMap) + // When the VPC is managed by CAPA, we need to create the subnets. if !unmanagedVPC { // Check that we need at least 1 private and 1 public subnet after we have updated the metadata diff --git a/data/data/cluster-api/aws-infrastructure-components.yaml b/data/data/cluster-api/aws-infrastructure-components.yaml index ebac4624010..237f8649901 100644 --- a/data/data/cluster-api/aws-infrastructure-components.yaml +++ b/data/data/cluster-api/aws-infrastructure-components.yaml @@ -1935,6 +1935,11 @@ spec: to determine routes for private subnets in the same AZ as the public subnet. type: string + parentZoneName: + description: ParentZoneName defines a parent zone name for + the zone that the subnet is created, when applied. Available + only in zone types local-zone or wavelength-zone. + type: string resourceID: description: ResourceID is the subnet identifier from AWS, READ ONLY. This field is populated when the provider manages @@ -1950,6 +1955,33 @@ spec: description: Tags is a collection of tags describing the resource. type: object + zoneName: + description: "ZoneName defines a zone name for this subnet + If you're already set AvailabilityZone, it will take precendence. + \n The valid values are availability-zone, local-zone + , and wavelength-zone." + type: string + zoneType: + description: "ZoneType defines a zone type for this subnet + If you're already set AvailabilityZone, it will take precendence. + \n The valid values are availability-zone, local-zone + , and wavelength-zone. \n Zone types local-zone or wavelength-zone + is not selected to automatically create control plane + or compute nodes. \n When local-zone, the public subnets + will be associated to the public route table, the private + subnets will try to create a NAT Gateway, when supported, + otherwise the subnet will be associated to the private + route table in the region (preferred parent zone, zone + type availability-zone in the region, or first available). + \n When wavelength-zone, the public subnets will be associated + to the carrier route table, created altogether the Carrier + Gateway when public subnets in AWS Wavelength Zone is + defined. The private subnets will try to create a NAT + Gateway, when supported, otherwise the subnet will be + associated to the private route table in the region (preferred + parent zone, zone type availability-zone in the region, + or first available)." + type: string required: - id type: object @@ -4396,6 +4428,12 @@ spec: routes for private subnets in the same AZ as the public subnet. type: string + parentZoneName: + description: ParentZoneName defines a parent zone + name for the zone that the subnet is created, + when applied. Available only in zone types local-zone + or wavelength-zone. + type: string resourceID: description: ResourceID is the subnet identifier from AWS, READ ONLY. This field is populated when @@ -4411,6 +4449,36 @@ spec: description: Tags is a collection of tags describing the resource. type: object + zoneName: + description: "ZoneName defines a zone name for this + subnet If you're already set AvailabilityZone, + it will take precendence. \n The valid values + are availability-zone, local-zone , and wavelength-zone." + type: string + zoneType: + description: "ZoneType defines a zone type for this + subnet If you're already set AvailabilityZone, + it will take precendence. \n The valid values + are availability-zone, local-zone , and wavelength-zone. + \n Zone types local-zone or wavelength-zone is + not selected to automatically create control plane + or compute nodes. \n When local-zone, the public + subnets will be associated to the public route + table, the private subnets will try to create + a NAT Gateway, when supported, otherwise the subnet + will be associated to the private route table + in the region (preferred parent zone, zone type + availability-zone in the region, or first available). + \n When wavelength-zone, the public subnets will + be associated to the carrier route table, created + altogether the Carrier Gateway when public subnets + in AWS Wavelength Zone is defined. The private + subnets will try to create a NAT Gateway, when + supported, otherwise the subnet will be associated + to the private route table in the region (preferred + parent zone, zone type availability-zone in the + region, or first available)." + type: string required: - id type: object @@ -6909,40 +6977,6 @@ spec: description: Ignition defined options related to the bootstrapping systems where Ignition is used. properties: - proxy: - description: Proxy defines proxy settings for Ignition. Only valid - for Ignition versions 3.1 and above. - properties: - httpProxy: - description: HTTPProxy is the HTTP proxy to use for Ignition. - A single URL that specifies the proxy server to use for - HTTP and HTTPS requests, unless overridden by the HTTPSProxy - or NoProxy options. - type: string - httpsProxy: - description: HTTPSProxy is the HTTPS proxy to use for Ignition. - A single URL that specifies the proxy server to use for - HTTPS requests, unless overridden by the NoProxy option. - type: string - noProxy: - description: "NoProxy is the list of domains to not proxy - for Ignition. Specifies a list of strings to hosts that - should be excluded from proxying. \n Each value is represented - by: - An IP address prefix (1.2.3.4) - An IP address prefix - in CIDR notation (1.2.3.4/8) - A domain name - A domain - name matches that name and all subdomains - A domain name - with a leading . matches subdomains only - A special DNS - label (*), indicates that no proxying should be done \n - An IP address prefix and domain name can also include a - literal port number (1.2.3.4:80)." - items: - description: IgnitionNoProxy defines the list of domains - to not proxy for Ignition. - maxLength: 2048 - type: string - maxItems: 64 - type: array - type: object storageType: default: ClusterObjectStore description: "StorageType defines how to store the boostrap user @@ -6965,24 +6999,6 @@ spec: - ClusterObjectStore - UnencryptedUserData type: string - tls: - description: TLS defines TLS settings for Ignition. Only valid - for Ignition versions 3.1 and above. - properties: - certificateAuthorities: - description: CASources defines the list of certificate authorities - to use for Ignition. The value is the certificate bundle - (in PEM format). The bundle can contain multiple concatenated - certificates. Supported schemes are http, https, tftp, s3, - arn, gs, and `data` (RFC 2397) URL scheme. - items: - description: IgnitionCASource defines the source of the - certificate authority to use for Ignition. - maxLength: 65536 - type: string - maxItems: 64 - type: array - type: object version: default: "2.3" description: Version defines which version of Ignition will be @@ -7980,42 +7996,6 @@ spec: description: Ignition defined options related to the bootstrapping systems where Ignition is used. properties: - proxy: - description: Proxy defines proxy settings for Ignition. - Only valid for Ignition versions 3.1 and above. - properties: - httpProxy: - description: HTTPProxy is the HTTP proxy to use for - Ignition. A single URL that specifies the proxy - server to use for HTTP and HTTPS requests, unless - overridden by the HTTPSProxy or NoProxy options. - type: string - httpsProxy: - description: HTTPSProxy is the HTTPS proxy to use - for Ignition. A single URL that specifies the proxy - server to use for HTTPS requests, unless overridden - by the NoProxy option. - type: string - noProxy: - description: "NoProxy is the list of domains to not - proxy for Ignition. Specifies a list of strings - to hosts that should be excluded from proxying. - \n Each value is represented by: - An IP address - prefix (1.2.3.4) - An IP address prefix in CIDR - notation (1.2.3.4/8) - A domain name - A domain - name matches that name and all subdomains - A domain - name with a leading . matches subdomains only - - A special DNS label (*), indicates that no proxying - should be done \n An IP address prefix and domain - name can also include a literal port number (1.2.3.4:80)." - items: - description: IgnitionNoProxy defines the list of - domains to not proxy for Ignition. - maxLength: 2048 - type: string - maxItems: 64 - type: array - type: object storageType: default: ClusterObjectStore description: "StorageType defines how to store the boostrap @@ -8040,25 +8020,6 @@ spec: - ClusterObjectStore - UnencryptedUserData type: string - tls: - description: TLS defines TLS settings for Ignition. Only - valid for Ignition versions 3.1 and above. - properties: - certificateAuthorities: - description: CASources defines the list of certificate - authorities to use for Ignition. The value is the - certificate bundle (in PEM format). The bundle can - contain multiple concatenated certificates. Supported - schemes are http, https, tftp, s3, arn, gs, and - `data` (RFC 2397) URL scheme. - items: - description: IgnitionCASource defines the source - of the certificate authority to use for Ignition. - maxLength: 65536 - type: string - maxItems: 64 - type: array - type: object version: default: "2.3" description: Version defines which version of Ignition @@ -9032,6 +8993,11 @@ spec: to determine routes for private subnets in the same AZ as the public subnet. type: string + parentZoneName: + description: ParentZoneName defines a parent zone name for + the zone that the subnet is created, when applied. Available + only in zone types local-zone or wavelength-zone. + type: string resourceID: description: ResourceID is the subnet identifier from AWS, READ ONLY. This field is populated when the provider manages @@ -9047,6 +9013,33 @@ spec: description: Tags is a collection of tags describing the resource. type: object + zoneName: + description: "ZoneName defines a zone name for this subnet + If you're already set AvailabilityZone, it will take precendence. + \n The valid values are availability-zone, local-zone + , and wavelength-zone." + type: string + zoneType: + description: "ZoneType defines a zone type for this subnet + If you're already set AvailabilityZone, it will take precendence. + \n The valid values are availability-zone, local-zone + , and wavelength-zone. \n Zone types local-zone or wavelength-zone + is not selected to automatically create control plane + or compute nodes. \n When local-zone, the public subnets + will be associated to the public route table, the private + subnets will try to create a NAT Gateway, when supported, + otherwise the subnet will be associated to the private + route table in the region (preferred parent zone, zone + type availability-zone in the region, or first available). + \n When wavelength-zone, the public subnets will be associated + to the carrier route table, created altogether the Carrier + Gateway when public subnets in AWS Wavelength Zone is + defined. The private subnets will try to create a NAT + Gateway, when supported, otherwise the subnet will be + associated to the private route table in the region (preferred + parent zone, zone type availability-zone in the region, + or first available)." + type: string required: - id type: object @@ -10871,6 +10864,11 @@ spec: to determine routes for private subnets in the same AZ as the public subnet. type: string + parentZoneName: + description: ParentZoneName defines a parent zone name for + the zone that the subnet is created, when applied. Available + only in zone types local-zone or wavelength-zone. + type: string resourceID: description: ResourceID is the subnet identifier from AWS, READ ONLY. This field is populated when the provider manages @@ -10886,6 +10884,33 @@ spec: description: Tags is a collection of tags describing the resource. type: object + zoneName: + description: "ZoneName defines a zone name for this subnet + If you're already set AvailabilityZone, it will take precendence. + \n The valid values are availability-zone, local-zone + , and wavelength-zone." + type: string + zoneType: + description: "ZoneType defines a zone type for this subnet + If you're already set AvailabilityZone, it will take precendence. + \n The valid values are availability-zone, local-zone + , and wavelength-zone. \n Zone types local-zone or wavelength-zone + is not selected to automatically create control plane + or compute nodes. \n When local-zone, the public subnets + will be associated to the public route table, the private + subnets will try to create a NAT Gateway, when supported, + otherwise the subnet will be associated to the private + route table in the region (preferred parent zone, zone + type availability-zone in the region, or first available). + \n When wavelength-zone, the public subnets will be associated + to the carrier route table, created altogether the Carrier + Gateway when public subnets in AWS Wavelength Zone is + defined. The private subnets will try to create a NAT + Gateway, when supported, otherwise the subnet will be + associated to the private route table in the region (preferred + parent zone, zone type availability-zone in the region, + or first available)." + type: string required: - id type: object diff --git a/pkg/asset/manifests/aws/zones_test.go b/pkg/asset/manifests/aws/zones_test.go index 1d9b46ba781..49a3cce2b6e 100644 --- a/pkg/asset/manifests/aws/zones_test.go +++ b/pkg/asset/manifests/aws/zones_test.go @@ -103,6 +103,16 @@ func stubInstallCOnfigPoolControl() *types.MachinePool { } } +func stubAwsCluster() *capa.AWSCluster { + return &capa.AWSCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "infraId", + Namespace: capiutils.Namespace, + }, + Spec: capa.AWSClusterSpec{}, + } +} + func Test_extractZonesFromInstallConfig(t *testing.T) { type args struct { in *zoneConfigInput @@ -191,14 +201,6 @@ func Test_extractZonesFromInstallConfig(t *testing.T) { } } -var stubAwsCluster = &capa.AWSCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "infraId", - Namespace: capiutils.Namespace, - }, - Spec: capa.AWSClusterSpec{}, -} - func Test_setZonesManagedVPC(t *testing.T) { type args struct { in *zoneConfigInput @@ -209,7 +211,6 @@ func Test_setZonesManagedVPC(t *testing.T) { wantErr bool want *capa.AWSCluster }{ - // TODO: Add test cases. { name: "empty clusterx", args: args{ @@ -217,7 +218,7 @@ func Test_setZonesManagedVPC(t *testing.T) { ClusterID: stubClusterID(), InstallConfig: stubInstallConfigComplete(), Config: stubInstallConfigTypeZones(), - Cluster: stubAwsCluster, + Cluster: stubAwsCluster(), }, }, want: func() *capa.AWSCluster { @@ -265,9 +266,6 @@ func Test_setZonesManagedVPC(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - // if err := setZonesManagedVPC(tt.args.in); (err != nil) != tt.wantErr { - // t.Errorf("setZonesManagedVPC() error = %v, wantErr %v", err, tt.wantErr) - // } err := setZonesManagedVPC(tt.args.in) if (err != nil) != tt.wantErr { t.Errorf("setZonesManagedVPC() error = %v, wantErr %v", err, tt.wantErr) @@ -276,8 +274,6 @@ func Test_setZonesManagedVPC(t *testing.T) { if tt.args.in.Cluster != nil { got = tt.args.in.Cluster } - // spew.Dump(tt.want) - // spew.Dump(got) if !reflect.DeepEqual(got, tt.want) { t.Errorf("setZonesManagedVPC() = %v, want %v", got, tt.want) fmt.Println("Want:") diff --git a/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go b/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go index d487183025a..b254bf535ef 100644 --- a/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go +++ b/vendor/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2/network_types.go @@ -420,6 +420,34 @@ type SubnetSpec struct { // Tags is a collection of tags describing the resource. Tags Tags `json:"tags,omitempty"` + + // ZoneName defines a zone name for this subnet + // If you're already set AvailabilityZone, it will take precendence. + // + // The valid values are availability-zone , local-zone , and wavelength-zone + ZoneName *string `json:"zoneName,omitempty"` + + // ZoneType defines a zone type for this subnet + // If you're already set AvailabilityZone, it will take precendence. + // + // The valid values are availability-zone, local-zone , and wavelength-zone. + // + // Zone types local-zone or wavelength-zone is not selected to automatically create + // control plane or compute nodes. + // + // When local-zone, the public subnets will be associated to the public route table, + // the private subnets will try to create a NAT Gateway, when supported, otherwise + // the subnet will be associated to the private route table in the region (preferred parent zone, zone + // type availability-zone in the region, or first available). + // + // When wavelength-zone, the public subnets will be associated to the carrier route table, + // created altogether the Carrier Gateway when public subnets in AWS Wavelength Zone is defined. + // The private subnets will try to create a NAT Gateway, when supported, otherwise + // the subnet will be associated to the private route table in the region (preferred parent zone, zone + // type availability-zone in the region, or first available). + ZoneType *string `json:"zoneType,omitempty"` + + ParentZoneName *string `json:"parentZoneName,omitempty"` } // GetResourceID returns the identifier for this subnet,