@@ -455,6 +455,22 @@ type VPCSpec struct {
455
455
// +optional
456
456
// +kubebuilder:validation:Enum:=ip-name;resource-name
457
457
PrivateDNSHostnameTypeOnLaunch * string `json:"privateDnsHostnameTypeOnLaunch,omitempty"`
458
+
459
+ // ElasticIPPool contains specific configuration to allocate Public IPv4 address (Elastic IP) from user-defined pool
460
+ // brought to AWS for core infrastructure resources, like NAT Gateways and Public Network Load Balancers for
461
+ // the API Server.
462
+ // +optional
463
+ ElasticIPPool * ElasticIPPool `json:"elasticIpPool,omitempty"`
464
+
465
+ // SubnetSchema specifies how CidrBlock should be divided on subnets in the VPC depending on the number of AZs.
466
+ // PreferPrivate - one private subnet for each AZ plus one other subnet that will be further sub-divided for the public subnets.
467
+ // PreferPublic - have the reverse logic of PreferPrivate, one public subnet for each AZ plus one other subnet
468
+ // that will be further sub-divided for the private subnets.
469
+ // Defaults to PreferPrivate
470
+ // +optional
471
+ // +kubebuilder:default=PreferPrivate
472
+ // +kubebuilder:validation:Enum=PreferPrivate;PreferPublic
473
+ SubnetSchema * SubnetSchemaType `json:"subnetSchema,omitempty"`
458
474
}
459
475
460
476
// String returns a string representation of the VPC.
@@ -477,6 +493,22 @@ func (v *VPCSpec) IsIPv6Enabled() bool {
477
493
return v .IPv6 != nil
478
494
}
479
495
496
+ // GetElasticIPPool returns the custom Elastic IP Pool configuration when present.
497
+ func (v * VPCSpec ) GetElasticIPPool () * ElasticIPPool {
498
+ return v .ElasticIPPool
499
+ }
500
+
501
+ // GetPublicIpv4Pool returns the custom public IPv4 pool brought to AWS when present.
502
+ func (v * VPCSpec ) GetPublicIpv4Pool () * string {
503
+ if v .ElasticIPPool == nil {
504
+ return nil
505
+ }
506
+ if v .ElasticIPPool .PublicIpv4Pool != nil {
507
+ return v .ElasticIPPool .PublicIpv4Pool
508
+ }
509
+ return nil
510
+ }
511
+
480
512
// SubnetSpec configures an AWS Subnet.
481
513
type SubnetSpec struct {
482
514
// ID defines a unique identifier to reference this resource.
@@ -715,6 +747,17 @@ func (s Subnets) FilterPrivate() (res Subnets) {
715
747
return
716
748
}
717
749
750
+ // FilterNonCni returns the subnets that are NOT intended for usage with the CNI pod network
751
+ // (i.e. do NOT have the `sigs.k8s.io/cluster-api-provider-aws/association=secondary` tag).
752
+ func (s Subnets ) FilterNonCni () (res Subnets ) {
753
+ for _ , x := range s {
754
+ if x .Tags [NameAWSSubnetAssociation ] != SecondarySubnetTagValue {
755
+ res = append (res , x )
756
+ }
757
+ }
758
+ return
759
+ }
760
+
718
761
// FilterPublic returns a slice containing all subnets marked as public.
719
762
func (s Subnets ) FilterPublic () (res Subnets ) {
720
763
for _ , x := range s {
@@ -897,6 +940,10 @@ type IngressRule struct {
897
940
// The field will be combined with source security group IDs if specified.
898
941
// +optional
899
942
SourceSecurityGroupRoles []SecurityGroupRole `json:"sourceSecurityGroupRoles,omitempty"`
943
+
944
+ // NatGatewaysIPsSource use the NAT gateways IPs as the source for the ingress rule.
945
+ // +optional
946
+ NatGatewaysIPsSource bool `json:"natGatewaysIPsSource,omitempty"`
900
947
}
901
948
902
949
// String returns a string representation of the ingress rule.
@@ -1002,3 +1049,57 @@ func (z ZoneType) String() string {
1002
1049
func (z ZoneType ) Equal (other ZoneType ) bool {
1003
1050
return z == other
1004
1051
}
1052
+
1053
+ // ElasticIPPool allows configuring a Elastic IP pool for resources allocating
1054
+ // public IPv4 addresses on public subnets.
1055
+ type ElasticIPPool struct {
1056
+ // PublicIpv4Pool sets a custom Public IPv4 Pool used to create Elastic IP address for resources
1057
+ // created in public IPv4 subnets. Every IPv4 address, Elastic IP, will be allocated from the custom
1058
+ // Public IPv4 pool that you brought to AWS, instead of Amazon-provided pool. The public IPv4 pool
1059
+ // resource ID starts with 'ipv4pool-ec2'.
1060
+ //
1061
+ // +kubebuilder:validation:MaxLength=30
1062
+ // +optional
1063
+ PublicIpv4Pool * string `json:"publicIpv4Pool,omitempty"`
1064
+
1065
+ // PublicIpv4PoolFallBackOrder defines the fallback action when the Public IPv4 Pool has been exhausted,
1066
+ // no more IPv4 address available in the pool.
1067
+ //
1068
+ // When set to 'amazon-pool', the controller check if the pool has available IPv4 address, when pool has reached the
1069
+ // IPv4 limit, the address will be claimed from Amazon-pool (default).
1070
+ //
1071
+ // When set to 'none', the controller will fail the Elastic IP allocation when the publicIpv4Pool is exhausted.
1072
+ //
1073
+ // +kubebuilder:validation:Enum:=amazon-pool;none
1074
+ // +optional
1075
+ PublicIpv4PoolFallBackOrder * PublicIpv4PoolFallbackOrder `json:"publicIpv4PoolFallbackOrder,omitempty"`
1076
+
1077
+ // TODO(mtulio): add future support of user-defined Elastic IP to allow users to assign BYO Public IP from
1078
+ // 'static'/preallocated amazon-provided IPsstrucute currently holds only 'BYO Public IP from Public IPv4 Pool' (user brought to AWS),
1079
+ // although a dedicated structure would help to hold 'BYO Elastic IP' variants like:
1080
+ // - AllocationIdPoolApiLoadBalancer: an user-defined (static) IP address to the Public API Load Balancer.
1081
+ // - AllocationIdPoolNatGateways: an user-defined (static) IP address to allocate to NAT Gateways (egress traffic).
1082
+ }
1083
+
1084
+ // PublicIpv4PoolFallbackOrder defines the list of available fallback action when the PublicIpv4Pool is exhausted.
1085
+ // 'none' let the controllers return failures when the PublicIpv4Pool is exhausted - no more IPv4 available.
1086
+ // 'amazon-pool' let the controllers to skip the PublicIpv4Pool and use the Amazon pool, the default.
1087
+ // +kubebuilder:validation:XValidation:rule="self in ['none','amazon-pool']",message="allowed values are 'none' and 'amazon-pool'"
1088
+ type PublicIpv4PoolFallbackOrder string
1089
+
1090
+ const (
1091
+ // PublicIpv4PoolFallbackOrderAmazonPool refers to use Amazon-pool Public IPv4 Pool as a fallback strategy.
1092
+ PublicIpv4PoolFallbackOrderAmazonPool = PublicIpv4PoolFallbackOrder ("amazon-pool" )
1093
+
1094
+ // PublicIpv4PoolFallbackOrderNone refers to not use any fallback strategy.
1095
+ PublicIpv4PoolFallbackOrderNone = PublicIpv4PoolFallbackOrder ("none" )
1096
+ )
1097
+
1098
+ func (r PublicIpv4PoolFallbackOrder ) String () string {
1099
+ return string (r )
1100
+ }
1101
+
1102
+ // Equal compares PublicIpv4PoolFallbackOrder types and return true if input param is equal.
1103
+ func (r PublicIpv4PoolFallbackOrder ) Equal (e PublicIpv4PoolFallbackOrder ) bool {
1104
+ return r == e
1105
+ }
0 commit comments