Skip to content

Commit baa3f03

Browse files
authored
Merge pull request #1531 from barbacbd/min-ports-per-vm
Provide a MinPortsPerVM for Nat Router
2 parents 221292a + 8fba12f commit baa3f03

7 files changed

+56
-0
lines changed

api/v1beta1/types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ type NetworkSpec struct {
147147
// +kubebuilder:default:=1460
148148
// +optional
149149
Mtu int64 `json:"mtu,omitempty"`
150+
151+
// MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT
152+
// config. If not set, a default number of ports is allocated to a VM. This is
153+
// rounded up to the nearest power of 2. For example, if the value of this
154+
// field is 50, at least 64 ports are allocated to a VM.
155+
// +kubebuilder:validation:Minimum:=2
156+
// +kubebuilder:validation:Maximum:=65536
157+
// +kubebuilder:default:=64
158+
// +optional
159+
MinPortsPerVM int64 `json:"minPortsPerVm,omitempty"`
150160
}
151161

152162
// LoadBalancerType defines the Load Balancer that should be created.

cloud/scope/cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ func (s *ClusterScope) NatRouterSpec() *compute.Router {
237237
Name: fmt.Sprintf("%s-%s", networkSpec.Name, "nat"),
238238
NatIpAllocateOption: "AUTO_ONLY",
239239
SourceSubnetworkIpRangesToNat: "ALL_SUBNETWORKS_ALL_IP_RANGES",
240+
MinPortsPerVm: s.GCPCluster.Spec.Network.MinPortsPerVM,
240241
},
241242
},
242243
}

cloud/scope/managedcluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ func (s *ManagedClusterScope) NatRouterSpec() *compute.Router {
221221
Name: fmt.Sprintf("%s-%s", networkSpec.Name, "nat"),
222222
NatIpAllocateOption: "AUTO_ONLY",
223223
SourceSubnetworkIpRangesToNat: "ALL_SUBNETWORKS_ALL_IP_RANGES",
224+
MinPortsPerVm: s.GCPManagedCluster.Spec.Network.MinPortsPerVM,
224225
},
225226
},
226227
}

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ spec:
188188
(useful for changing apiserver port)
189189
format: int32
190190
type: integer
191+
minPortsPerVm:
192+
default: 64
193+
description: |-
194+
MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT
195+
config. If not set, a default number of ports is allocated to a VM. This is
196+
rounded up to the nearest power of 2. For example, if the value of this
197+
field is 50, at least 64 ports are allocated to a VM.
198+
format: int64
199+
maximum: 65536
200+
minimum: 2
201+
type: integer
191202
mtu:
192203
default: 1460
193204
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclustertemplates.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ spec:
207207
backend (useful for changing apiserver port)
208208
format: int32
209209
type: integer
210+
minPortsPerVm:
211+
default: 64
212+
description: |-
213+
MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT
214+
config. If not set, a default number of ports is allocated to a VM. This is
215+
rounded up to the nearest power of 2. For example, if the value of this
216+
field is 50, at least 64 ports are allocated to a VM.
217+
format: int64
218+
maximum: 65536
219+
minimum: 2
220+
type: integer
210221
mtu:
211222
default: 1460
212223
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ spec:
184184
(useful for changing apiserver port)
185185
format: int32
186186
type: integer
187+
minPortsPerVm:
188+
default: 64
189+
description: |-
190+
MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT
191+
config. If not set, a default number of ports is allocated to a VM. This is
192+
rounded up to the nearest power of 2. For example, if the value of this
193+
field is 50, at least 64 ports are allocated to a VM.
194+
format: int64
195+
maximum: 65536
196+
minimum: 2
197+
type: integer
187198
mtu:
188199
default: 1460
189200
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclustertemplates.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ spec:
178178
backend (useful for changing apiserver port)
179179
format: int32
180180
type: integer
181+
minPortsPerVm:
182+
default: 64
183+
description: |-
184+
MinPortsPerVM: Minimum number of ports allocated to a VM from this NAT
185+
config. If not set, a default number of ports is allocated to a VM. This is
186+
rounded up to the nearest power of 2. For example, if the value of this
187+
field is 50, at least 64 ports are allocated to a VM.
188+
format: int64
189+
maximum: 65536
190+
minimum: 2
191+
type: integer
181192
mtu:
182193
default: 1460
183194
description: |-

0 commit comments

Comments
 (0)