Skip to content

Commit

Permalink
feat: support IPAM Manager for VPC IPv6 creation
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxFedotov committed Aug 24, 2023
1 parent f43a36b commit 5f272fb
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 37 deletions.
8 changes: 8 additions & 0 deletions api/v1beta1/awscluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
restoreIPAMPool(restored.Spec.NetworkSpec.VPC.IPAMPool, dst.Spec.NetworkSpec.VPC.IPAMPool)
}

if restored.Spec.NetworkSpec.VPC.IsIPv6Enabled() && restored.Spec.NetworkSpec.VPC.IPv6.IPAMPool != nil {
if dst.Spec.NetworkSpec.VPC.IPv6.IPAMPool == nil {
dst.Spec.NetworkSpec.VPC.IPv6.IPAMPool = &infrav2.IPAMPool{}
}

restoreIPAMPool(restored.Spec.NetworkSpec.VPC.IPv6.IPAMPool, dst.Spec.NetworkSpec.VPC.IPv6.IPAMPool)
}

return nil
}

Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ func Convert_v1beta2_IngressRule_To_v1beta1_IngressRule(in *v1beta2.IngressRule,
func Convert_v1beta2_VPCSpec_To_v1beta1_VPCSpec(in *v1beta2.VPCSpec, out *VPCSpec, s conversion.Scope) error {
return autoConvert_v1beta2_VPCSpec_To_v1beta1_VPCSpec(in, out, s)
}

func Convert_v1beta2_IPv6_To_v1beta1_IPv6(in *v1beta2.IPv6, out *IPv6, s conversion.Scope) error {
return autoConvert_v1beta2_IPv6_To_v1beta1_IPv6(in, out, s)
}
36 changes: 24 additions & 12 deletions api/v1beta1/zz_generated.conversion.go

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

12 changes: 11 additions & 1 deletion api/v1beta2/network_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,24 @@ type NetworkSpec struct {
// IPv6 contains ipv6 specific settings for the network.
type IPv6 struct {
// CidrBlock is the CIDR block provided by Amazon when VPC has enabled IPv6.
// Mutually exclusive with IPAMPool.
// +optional
CidrBlock string `json:"cidrBlock,omitempty"`

// PoolID is the IP pool which must be defined in case of BYO IP is defined.
// Must be specified if CidrBlock is set.
// Mutually exclusive with IPAMPool.
// +optional
PoolID string `json:"poolId,omitempty"`

// EgressOnlyInternetGatewayID is the id of the egress only internet gateway associated with an IPv6 enabled VPC.
// +optional
EgressOnlyInternetGatewayID *string `json:"egressOnlyInternetGatewayId,omitempty"`

// IPAMPool defines the IPAMv6 pool to be used for VPC.
// Mutually exclusive with CidrBlock.
// +optional
IPAMPool *IPAMPool `json:"ipamPool,omitempty"`
}

// IPAMPool defines the IPAM pool to be used for VPC.
Expand All @@ -264,9 +272,11 @@ type VPCSpec struct {

// CidrBlock is the CIDR block to be used when the provider creates a managed VPC.
// Defaults to 10.0.0.0/16.
// Mutually exclusive with IPAMPool.
CidrBlock string `json:"cidrBlock,omitempty"`

// IPAMPool defines the IPAM pool to be used for VPC.
// IPAMPool defines the IPAMv4 pool to be used for VPC.
// Mutually exclusive with CidrBlock.
IPAMPool *IPAMPool `json:"ipamPool,omitempty"`

// IPv6 contains ipv6 specific settings for the network. Supported only in managed clusters.
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ spec:
cidrBlock:
description: CidrBlock is the CIDR block to be used when the
provider creates a managed VPC. Defaults to 10.0.0.0/16.
Mutually exclusive with IPAMPool.
type: string
id:
description: ID is the vpc-id of the VPC this provider should
Expand All @@ -493,8 +494,8 @@ spec:
associated with the VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAM pool to be used for
VPC.
description: IPAMPool defines the IPAMv4 pool to be used for
VPC. Mutually exclusive with CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool this provider
Expand All @@ -518,16 +519,37 @@ spec:
properties:
cidrBlock:
description: CidrBlock is the CIDR block provided by Amazon
when VPC has enabled IPv6.
when VPC has enabled IPv6. Mutually exclusive with IPAMPool.
type: string
egressOnlyInternetGatewayId:
description: EgressOnlyInternetGatewayID is the id of
the egress only internet gateway associated with an
IPv6 enabled VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAMv6 pool to be used
for VPC. Mutually exclusive with CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool this provider
should use to create VPC.
type: string
name:
description: Name is the name of the IPAM pool this
provider should use to create VPC.
type: string
netmaskLength:
description: The netmask length of the IPv4 CIDR you
want to allocate to VPC from an Amazon VPC IP Address
Manager (IPAM) pool. Defaults to /16 for IPv4 if
not specified.
format: int64
type: integer
type: object
poolId:
description: PoolID is the IP pool which must be defined
in case of BYO IP is defined.
in case of BYO IP is defined. Must be specified if CidrBlock
is set. Mutually exclusive with IPAMPool.
type: string
type: object
tags:
Expand Down Expand Up @@ -1950,6 +1972,7 @@ spec:
cidrBlock:
description: CidrBlock is the CIDR block to be used when the
provider creates a managed VPC. Defaults to 10.0.0.0/16.
Mutually exclusive with IPAMPool.
type: string
id:
description: ID is the vpc-id of the VPC this provider should
Expand All @@ -1960,8 +1983,8 @@ spec:
associated with the VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAM pool to be used for
VPC.
description: IPAMPool defines the IPAMv4 pool to be used for
VPC. Mutually exclusive with CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool this provider
Expand All @@ -1985,16 +2008,37 @@ spec:
properties:
cidrBlock:
description: CidrBlock is the CIDR block provided by Amazon
when VPC has enabled IPv6.
when VPC has enabled IPv6. Mutually exclusive with IPAMPool.
type: string
egressOnlyInternetGatewayId:
description: EgressOnlyInternetGatewayID is the id of
the egress only internet gateway associated with an
IPv6 enabled VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAMv6 pool to be used
for VPC. Mutually exclusive with CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool this provider
should use to create VPC.
type: string
name:
description: Name is the name of the IPAM pool this
provider should use to create VPC.
type: string
netmaskLength:
description: The netmask length of the IPv4 CIDR you
want to allocate to VPC from an Amazon VPC IP Address
Manager (IPAM) pool. Defaults to /16 for IPv4 if
not specified.
format: int64
type: integer
type: object
poolId:
description: PoolID is the IP pool which must be defined
in case of BYO IP is defined.
in case of BYO IP is defined. Must be specified if CidrBlock
is set. Mutually exclusive with IPAMPool.
type: string
type: object
tags:
Expand Down
30 changes: 26 additions & 4 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,7 @@ spec:
cidrBlock:
description: CidrBlock is the CIDR block to be used when the
provider creates a managed VPC. Defaults to 10.0.0.0/16.
Mutually exclusive with IPAMPool.
type: string
id:
description: ID is the vpc-id of the VPC this provider should
Expand All @@ -1296,8 +1297,8 @@ spec:
associated with the VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAM pool to be used for
VPC.
description: IPAMPool defines the IPAMv4 pool to be used for
VPC. Mutually exclusive with CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool this provider
Expand All @@ -1321,16 +1322,37 @@ spec:
properties:
cidrBlock:
description: CidrBlock is the CIDR block provided by Amazon
when VPC has enabled IPv6.
when VPC has enabled IPv6. Mutually exclusive with IPAMPool.
type: string
egressOnlyInternetGatewayId:
description: EgressOnlyInternetGatewayID is the id of
the egress only internet gateway associated with an
IPv6 enabled VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAMv6 pool to be used
for VPC. Mutually exclusive with CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool this provider
should use to create VPC.
type: string
name:
description: Name is the name of the IPAM pool this
provider should use to create VPC.
type: string
netmaskLength:
description: The netmask length of the IPv4 CIDR you
want to allocate to VPC from an Amazon VPC IP Address
Manager (IPAM) pool. Defaults to /16 for IPv4 if
not specified.
format: int64
type: integer
type: object
poolId:
description: PoolID is the IP pool which must be defined
in case of BYO IP is defined.
in case of BYO IP is defined. Must be specified if CidrBlock
is set. Mutually exclusive with IPAMPool.
type: string
type: object
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ spec:
cidrBlock:
description: CidrBlock is the CIDR block to be used
when the provider creates a managed VPC. Defaults
to 10.0.0.0/16.
to 10.0.0.0/16. Mutually exclusive with IPAMPool.
type: string
id:
description: ID is the vpc-id of the VPC this provider
Expand All @@ -903,8 +903,8 @@ spec:
gateway associated with the VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAM pool to be
used for VPC.
description: IPAMPool defines the IPAMv4 pool to be
used for VPC. Mutually exclusive with CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool this
Expand All @@ -929,16 +929,41 @@ spec:
properties:
cidrBlock:
description: CidrBlock is the CIDR block provided
by Amazon when VPC has enabled IPv6.
by Amazon when VPC has enabled IPv6. Mutually
exclusive with IPAMPool.
type: string
egressOnlyInternetGatewayId:
description: EgressOnlyInternetGatewayID is the
id of the egress only internet gateway associated
with an IPv6 enabled VPC.
type: string
ipamPool:
description: IPAMPool defines the IPAMv6 pool
to be used for VPC. Mutually exclusive with
CidrBlock.
properties:
id:
description: ID is the ID of the IPAM pool
this provider should use to create VPC.
type: string
name:
description: Name is the name of the IPAM
pool this provider should use to create
VPC.
type: string
netmaskLength:
description: The netmask length of the IPv4
CIDR you want to allocate to VPC from an
Amazon VPC IP Address Manager (IPAM) pool.
Defaults to /16 for IPv4 if not specified.
format: int64
type: integer
type: object
poolId:
description: PoolID is the IP pool which must
be defined in case of BYO IP is defined.
be defined in case of BYO IP is defined. Must
be specified if CidrBlock is set. Mutually exclusive
with IPAMPool.
type: string
type: object
tags:
Expand Down
Loading

0 comments on commit 5f272fb

Please sign in to comment.