diff --git a/cloud/scope/machinepool.go b/cloud/scope/machinepool.go index fcad4fe59..155ee51f7 100644 --- a/cloud/scope/machinepool.go +++ b/cloud/scope/machinepool.go @@ -342,8 +342,7 @@ func (m *MachinePoolScope) InstanceTemplateResource(ctx context.Context) (*compu instance.Disks = append(instance.Disks, m.InstanceAdditionalDiskSpec()...) instance.Metadata = InstanceAdditionalMetadataSpec(m.GCPMachinePool.Spec.AdditionalMetadata) instance.ServiceAccounts = append(instance.ServiceAccounts, instanceServiceAccountsSpec(m.GCPMachinePool.Spec.ServiceAccount)) - var aliasIPRanges []infrav1.AliasIPRange // Not supported by MachinePool - instance.NetworkInterfaces = append(instance.NetworkInterfaces, InstanceNetworkInterfaceSpec(m.ClusterGetter, m.GCPMachinePool.Spec.PublicIP, m.GCPMachinePool.Spec.Subnet, aliasIPRanges)) + instance.NetworkInterfaces = append(instance.NetworkInterfaces, InstanceNetworkInterfaceSpec(m.ClusterGetter, m.GCPMachinePool.Spec.PublicIP, m.GCPMachinePool.Spec.Subnet, m.GCPMachinePool.Spec.AliasIPRanges)) instance.GuestAccelerators = instanceGuestAcceleratorsSpec(m.GCPMachinePool.Spec.GuestAccelerators) if len(instance.GuestAccelerators) > 0 { instance.Scheduling.OnHostMaintenance = onHostMaintenanceTerminate diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinepools.yaml index a3311a9ae..eb640b1f1 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinepools.yaml @@ -181,6 +181,32 @@ spec: items: type: string type: array + aliasIPRanges: + description: AliasIPRanges let you assign ranges of internal IP addresses + as aliases to a VM's network interfaces. + items: + description: AliasIPRange is an alias IP range attached to an instance's + network interface. + properties: + ipCidrRange: + description: |- + IPCidrRange is the IP alias ranges to allocate for this interface. This IP + CIDR range must belong to the specified subnetwork and cannot contain IP + addresses reserved by system or used by other network interfaces. This range + may be a single IP address (such as 10.2.3.4), a netmask (such as /24) or a + CIDR-formatted string (such as 10.1.2.0/24). + pattern: ^((([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])|(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(/([0-9]|[12][0-9]|3[0-2])))$ + type: string + subnetworkRangeName: + description: |- + SubnetworkRangeName is the name of a subnetwork secondary IP range from which + to allocate an IP alias range. If not specified, the primary range of the + subnetwork is used. + type: string + required: + - ipCidrRange + type: object + type: array confidentialCompute: description: |- ConfidentialCompute Defines whether the instance should have confidential compute enabled or not, and the confidential computing technology of choice. diff --git a/exp/api/v1beta1/gcpmachinepool_types.go b/exp/api/v1beta1/gcpmachinepool_types.go index faf01a596..4e3524fa6 100644 --- a/exp/api/v1beta1/gcpmachinepool_types.go +++ b/exp/api/v1beta1/gcpmachinepool_types.go @@ -22,6 +22,7 @@ import ( capg "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" + infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1" ) // Constants block. @@ -45,6 +46,10 @@ type GCPMachinePoolSpec struct { // +optional Subnet *string `json:"subnet,omitempty"` + // AliasIPRanges let you assign ranges of internal IP addresses as aliases to a VM's network interfaces. + // +optional + AliasIPRanges []infrav1.AliasIPRange `json:"aliasIPRanges,omitempty"` + // ImageFamily is the full reference to a valid image family to be used for this machine. // +optional ImageFamily *string `json:"imageFamily,omitempty"` diff --git a/exp/api/v1beta1/zz_generated.deepcopy.go b/exp/api/v1beta1/zz_generated.deepcopy.go index a6a17c225..5d3ae2f71 100644 --- a/exp/api/v1beta1/zz_generated.deepcopy.go +++ b/exp/api/v1beta1/zz_generated.deepcopy.go @@ -199,6 +199,11 @@ func (in *GCPMachinePoolSpec) DeepCopyInto(out *GCPMachinePoolSpec) { *out = new(string) **out = **in } + if in.AliasIPRanges != nil { + in, out := &in.AliasIPRanges, &out.AliasIPRanges + *out = make([]apiv1beta1.AliasIPRange, len(*in)) + copy(*out, *in) + } if in.ImageFamily != nil { in, out := &in.ImageFamily, &out.ImageFamily *out = new(string)