Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we might want to specify that this is configured on the Nat Router, I wasn't entirely sure what this doing otherwise. But it's only a comment, so not a blocker IMO.

// 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.
Expand Down
1 change: 1 addition & 0 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how does defaulting work here with existing objects? I guess worst-case (default not applied) the code does the same thing it did before (and 64 is also the default on the NatRouter, I believe, so we shouldn't be changing the actual value in GCP either)

},
},
}
Expand Down
1 change: 1 addition & 0 deletions cloud/scope/managedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
11 changes: 11 additions & 0 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_gcpclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down