From 8fba12f2092285fe4278cf14a839e71e5828922c Mon Sep 17 00:00:00 2001 From: barbacbd Date: Wed, 17 Sep 2025 15:52:21 -0400 Subject: [PATCH] OCPBUGS-61876: Provide a MinPortsPerVM for Nat Router ** This is a regression for the openshift installer. Instead of filling this value in, the default will be 64 (so that this is backwards compatible), otherwise the user can provide this information in the cluster spec. ** MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT config. If not set, a default number of ports is allocated to a VM. This is rounded up to the nearest power of 2. For example, if the value of this field is 50, at least 64 ports are allocated to a VM. --- api/v1beta1/types.go | 10 ++++++++++ cloud/scope/cluster.go | 1 + cloud/scope/managedcluster.go | 1 + .../infrastructure.cluster.x-k8s.io_gcpclusters.yaml | 11 +++++++++++ ...tructure.cluster.x-k8s.io_gcpclustertemplates.yaml | 11 +++++++++++ ...structure.cluster.x-k8s.io_gcpmanagedclusters.yaml | 11 +++++++++++ ...e.cluster.x-k8s.io_gcpmanagedclustertemplates.yaml | 11 +++++++++++ 7 files changed, 56 insertions(+) diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index bbe110191..6d2b97c8a 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -147,6 +147,16 @@ type NetworkSpec struct { // +kubebuilder:default:=1460 // +optional Mtu int64 `json:"mtu,omitempty"` + + // MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT + // config. If not set, a default number of ports is allocated to a VM. This is + // rounded up to the nearest power of 2. For example, if the value of this + // field is 50, at least 64 ports are allocated to a VM. + // +kubebuilder:validation:Minimum:=2 + // +kubebuilder:validation:Maximum:=65536 + // +kubebuilder:default:=64 + // +optional + MinPortsPerVM int64 `json:"minPortsPerVm,omitempty"` } // LoadBalancerType defines the Load Balancer that should be created. diff --git a/cloud/scope/cluster.go b/cloud/scope/cluster.go index 706bdad3b..dd86493a1 100644 --- a/cloud/scope/cluster.go +++ b/cloud/scope/cluster.go @@ -237,6 +237,7 @@ func (s *ClusterScope) NatRouterSpec() *compute.Router { Name: fmt.Sprintf("%s-%s", networkSpec.Name, "nat"), NatIpAllocateOption: "AUTO_ONLY", SourceSubnetworkIpRangesToNat: "ALL_SUBNETWORKS_ALL_IP_RANGES", + MinPortsPerVm: s.GCPCluster.Spec.Network.MinPortsPerVM, }, }, } diff --git a/cloud/scope/managedcluster.go b/cloud/scope/managedcluster.go index 51ec04a43..25bcac8bf 100644 --- a/cloud/scope/managedcluster.go +++ b/cloud/scope/managedcluster.go @@ -221,6 +221,7 @@ func (s *ManagedClusterScope) NatRouterSpec() *compute.Router { Name: fmt.Sprintf("%s-%s", networkSpec.Name, "nat"), NatIpAllocateOption: "AUTO_ONLY", SourceSubnetworkIpRangesToNat: "ALL_SUBNETWORKS_ALL_IP_RANGES", + MinPortsPerVm: s.GCPManagedCluster.Spec.Network.MinPortsPerVM, }, }, } diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml index ea314885b..ac786ec4f 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml @@ -188,6 +188,17 @@ spec: (useful for changing apiserver port) format: int32 type: integer + minPortsPerVm: + default: 64 + description: |- + MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT + config. If not set, a default number of ports is allocated to a VM. This is + rounded up to the nearest power of 2. For example, if the value of this + field is 50, at least 64 ports are allocated to a VM. + format: int64 + maximum: 65536 + minimum: 2 + type: integer mtu: default: 1460 description: |- diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclustertemplates.yaml index b55917eea..7f320eafe 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclustertemplates.yaml @@ -207,6 +207,17 @@ spec: backend (useful for changing apiserver port) format: int32 type: integer + minPortsPerVm: + default: 64 + description: |- + MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT + config. If not set, a default number of ports is allocated to a VM. This is + rounded up to the nearest power of 2. For example, if the value of this + field is 50, at least 64 ports are allocated to a VM. + format: int64 + maximum: 65536 + minimum: 2 + type: integer mtu: default: 1460 description: |- diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml index 573b66583..dcea8d322 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml @@ -184,6 +184,17 @@ spec: (useful for changing apiserver port) format: int32 type: integer + minPortsPerVm: + default: 64 + description: |- + MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT + config. If not set, a default number of ports is allocated to a VM. This is + rounded up to the nearest power of 2. For example, if the value of this + field is 50, at least 64 ports are allocated to a VM. + format: int64 + maximum: 65536 + minimum: 2 + type: integer mtu: default: 1460 description: |- diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclustertemplates.yaml index d527cb3f2..70994589f 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclustertemplates.yaml @@ -178,6 +178,17 @@ spec: backend (useful for changing apiserver port) format: int32 type: integer + minPortsPerVm: + default: 64 + description: |- + MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT + config. If not set, a default number of ports is allocated to a VM. This is + rounded up to the nearest power of 2. For example, if the value of this + field is 50, at least 64 ports are allocated to a VM. + format: int64 + maximum: 65536 + minimum: 2 + type: integer mtu: default: 1460 description: |-