Skip to content

Commit a81e877

Browse files
Merge pull request openshift#8175 from mtulio/SPLAT-1437-capa-byoip
SPLAT-1437: CAPI/AWS/BYOIP: supporting Public IPv4 Pool
2 parents f4d64f0 + 681d3cb commit a81e877

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

pkg/asset/machines/aws/awsmachines.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ import (
2323

2424
// MachineInput defines the inputs needed to generate a machine asset.
2525
type MachineInput struct {
26-
Role string
27-
Pool *types.MachinePool
28-
Subnets map[string]string
29-
Tags capa.Tags
30-
PublicIP bool
31-
Ignition *capa.Ignition
26+
Role string
27+
Pool *types.MachinePool
28+
Subnets map[string]string
29+
Tags capa.Tags
30+
PublicIP bool
31+
PublicIpv4Pool string
32+
Ignition *capa.Ignition
3233
}
3334

3435
// GenerateMachines returns manifests and runtime objects to provision the control plane (including bootstrap, if applicable) nodes using CAPI.
@@ -112,6 +113,14 @@ func GenerateMachines(clusterID string, in *MachineInput) ([]*asset.RuntimeFile,
112113
if in.Role == "bootstrap" {
113114
awsMachine.Name = capiutils.GenerateBoostrapMachineName(clusterID)
114115
awsMachine.Labels["install.openshift.io/bootstrap"] = ""
116+
117+
// Enable BYO Public IPv4 Pool when defined on install-config.yaml.
118+
if len(in.PublicIpv4Pool) > 0 {
119+
awsMachine.Spec.ElasticIPPool = &capa.ElasticIPPool{
120+
PublicIpv4Pool: ptr.To(in.PublicIpv4Pool),
121+
PublicIpv4PoolFallBackOrder: ptr.To(capa.PublicIpv4PoolFallbackOrderAmazonPool),
122+
}
123+
}
115124
}
116125

117126
// Handle additional security groups.

pkg/asset/machines/clusterapi.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,13 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
196196
pool.Replicas = ptr.To[int64](1)
197197
pool.Platform.AWS = &mpool
198198
bootstrapAWSMachine, err := aws.GenerateMachines(clusterID.InfraID, &aws.MachineInput{
199-
Role: "bootstrap",
200-
Subnets: bootstrapSubnets,
201-
Pool: &pool,
202-
Tags: tags,
203-
PublicIP: installConfig.Config.Publish == types.ExternalPublishingStrategy,
204-
Ignition: ignition,
199+
Role: "bootstrap",
200+
Subnets: bootstrapSubnets,
201+
Pool: &pool,
202+
Tags: tags,
203+
PublicIP: installConfig.Config.Publish == types.ExternalPublishingStrategy,
204+
PublicIpv4Pool: ic.Platform.AWS.PublicIpv4Pool,
205+
Ignition: ignition,
205206
})
206207
if err != nil {
207208
return fmt.Errorf("failed to create bootstrap machine object: %w", err)

pkg/asset/manifests/aws/cluster.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ func GenerateClusterAssets(ic *installconfig.InstallConfig, clusterID *installco
233233
return nil, fmt.Errorf("failed to set cluster zones or subnets: %w", err)
234234
}
235235

236+
// Enable BYO Public IPv4 when defined on install-config.yaml
237+
if len(ic.Config.Platform.AWS.PublicIpv4Pool) > 0 {
238+
awsCluster.Spec.NetworkSpec.VPC.ElasticIPPool = &capa.ElasticIPPool{
239+
PublicIpv4Pool: ptr.To(ic.Config.Platform.AWS.PublicIpv4Pool),
240+
PublicIpv4PoolFallBackOrder: ptr.To(capa.PublicIpv4PoolFallbackOrderAmazonPool),
241+
}
242+
}
243+
236244
manifests = append(manifests, &asset.RuntimeFile{
237245
Object: awsCluster,
238246
File: asset.File{Filename: "02_infra-cluster.yaml"},

0 commit comments

Comments
 (0)