From 08a0ec3f95ce419f9ec2e31577f7eed94e8c1dda Mon Sep 17 00:00:00 2001
From: Vladimir Nachev
+(Appears on:
+NetworkConfig)
+
+ CloudNAT contains information about the the CloudNAT configurationCloudNAT
+
+
Field | +Description | +
---|---|
+minPortsPerVM
+
+int32
+
+ |
+
+(Optional)
+ MinPortsPerVM is the minimum number of ports allocated to a VM in the NAT config. +The default value is 2048 ports. + |
+
@@ -434,6 +466,20 @@ VPC
cloudNAT
+
+
+CloudNAT
+
+
+CloudNAT contains configation about the the CloudNAT configuration
+internal
string
diff --git a/controllers/provider-gcp/pkg/apis/gcp/types_infrastructure.go b/controllers/provider-gcp/pkg/apis/gcp/types_infrastructure.go
index 8d0235f68..0217e3916 100644
--- a/controllers/provider-gcp/pkg/apis/gcp/types_infrastructure.go
+++ b/controllers/provider-gcp/pkg/apis/gcp/types_infrastructure.go
@@ -33,6 +33,8 @@ type InfrastructureConfig struct {
type NetworkConfig struct {
// VPC indicates whether to use an existing VPC or create a new one.
VPC *VPC
+ // CloudNAT contains configation about the the CloudNAT resource
+ CloudNAT *CloudNAT
// Internal is a private subnet (used for internal load balancers).
Internal *string
// Workers is the worker subnet range to create (used for the VMs).
@@ -92,3 +94,10 @@ type CloudRouter struct {
// Name is the CloudRouter name.
Name string
}
+
+// CloudNAT contains information about the the CloudNAT configuration
+type CloudNAT struct {
+ // MinPortsPerVM is the minimum number of ports allocated to a VM in the NAT config.
+ // The default value is 2048 ports.
+ MinPortsPerVM *int32
+}
diff --git a/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/types_infrastructure.go b/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/types_infrastructure.go
index be5b04870..30812f40f 100644
--- a/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/types_infrastructure.go
+++ b/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/types_infrastructure.go
@@ -34,6 +34,9 @@ type NetworkConfig struct {
// VPC indicates whether to use an existing VPC or create a new one.
// +optional
VPC *VPC `json:"vpc,omitempty"`
+ // CloudNAT contains configation about the the CloudNAT configuration
+ // +optional
+ CloudNAT *CloudNAT `json:"cloudNAT,omitempty"`
// Internal is a private subnet (used for internal load balancers).
// +optional
Internal *string `json:"internal,omitempty"`
@@ -95,3 +98,11 @@ type CloudRouter struct {
// Name is the CloudRouter name.
Name string `json:"name,omitempty"`
}
+
+// CloudNAT contains information about the the CloudNAT configuration
+type CloudNAT struct {
+ // MinPortsPerVM is the minimum number of ports allocated to a VM in the NAT config.
+ // The default value is 2048 ports.
+ // +optional
+ MinPortsPerVM *int32 `json:"minPortsPerVM,omitempty"`
+}
diff --git a/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.conversion.go b/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.conversion.go
index f0fe16cc3..fe61c4563 100644
--- a/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.conversion.go
+++ b/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.conversion.go
@@ -45,6 +45,16 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
+ if err := s.AddGeneratedConversionFunc((*CloudNAT)(nil), (*gcp.CloudNAT)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_v1alpha1_CloudNAT_To_gcp_CloudNAT(a.(*CloudNAT), b.(*gcp.CloudNAT), scope)
+ }); err != nil {
+ return err
+ }
+ if err := s.AddGeneratedConversionFunc((*gcp.CloudNAT)(nil), (*CloudNAT)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_gcp_CloudNAT_To_v1alpha1_CloudNAT(a.(*gcp.CloudNAT), b.(*CloudNAT), scope)
+ }); err != nil {
+ return err
+ }
if err := s.AddGeneratedConversionFunc((*CloudProfileConfig)(nil), (*gcp.CloudProfileConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_CloudProfileConfig_To_gcp_CloudProfileConfig(a.(*CloudProfileConfig), b.(*gcp.CloudProfileConfig), scope)
}); err != nil {
@@ -198,6 +208,26 @@ func Convert_gcp_CloudControllerManagerConfig_To_v1alpha1_CloudControllerManager
return autoConvert_gcp_CloudControllerManagerConfig_To_v1alpha1_CloudControllerManagerConfig(in, out, s)
}
+func autoConvert_v1alpha1_CloudNAT_To_gcp_CloudNAT(in *CloudNAT, out *gcp.CloudNAT, s conversion.Scope) error {
+ out.MinPortsPerVM = (*int32)(unsafe.Pointer(in.MinPortsPerVM))
+ return nil
+}
+
+// Convert_v1alpha1_CloudNAT_To_gcp_CloudNAT is an autogenerated conversion function.
+func Convert_v1alpha1_CloudNAT_To_gcp_CloudNAT(in *CloudNAT, out *gcp.CloudNAT, s conversion.Scope) error {
+ return autoConvert_v1alpha1_CloudNAT_To_gcp_CloudNAT(in, out, s)
+}
+
+func autoConvert_gcp_CloudNAT_To_v1alpha1_CloudNAT(in *gcp.CloudNAT, out *CloudNAT, s conversion.Scope) error {
+ out.MinPortsPerVM = (*int32)(unsafe.Pointer(in.MinPortsPerVM))
+ return nil
+}
+
+// Convert_gcp_CloudNAT_To_v1alpha1_CloudNAT is an autogenerated conversion function.
+func Convert_gcp_CloudNAT_To_v1alpha1_CloudNAT(in *gcp.CloudNAT, out *CloudNAT, s conversion.Scope) error {
+ return autoConvert_gcp_CloudNAT_To_v1alpha1_CloudNAT(in, out, s)
+}
+
func autoConvert_v1alpha1_CloudProfileConfig_To_gcp_CloudProfileConfig(in *CloudProfileConfig, out *gcp.CloudProfileConfig, s conversion.Scope) error {
out.MachineImages = *(*[]gcp.MachineImages)(unsafe.Pointer(&in.MachineImages))
return nil
@@ -380,6 +410,7 @@ func Convert_gcp_MachineImages_To_v1alpha1_MachineImages(in *gcp.MachineImages,
func autoConvert_v1alpha1_NetworkConfig_To_gcp_NetworkConfig(in *NetworkConfig, out *gcp.NetworkConfig, s conversion.Scope) error {
out.VPC = (*gcp.VPC)(unsafe.Pointer(in.VPC))
+ out.CloudNAT = (*gcp.CloudNAT)(unsafe.Pointer(in.CloudNAT))
out.Internal = (*string)(unsafe.Pointer(in.Internal))
out.Worker = in.Worker
return nil
@@ -392,6 +423,7 @@ func Convert_v1alpha1_NetworkConfig_To_gcp_NetworkConfig(in *NetworkConfig, out
func autoConvert_gcp_NetworkConfig_To_v1alpha1_NetworkConfig(in *gcp.NetworkConfig, out *NetworkConfig, s conversion.Scope) error {
out.VPC = (*VPC)(unsafe.Pointer(in.VPC))
+ out.CloudNAT = (*CloudNAT)(unsafe.Pointer(in.CloudNAT))
out.Internal = (*string)(unsafe.Pointer(in.Internal))
out.Worker = in.Worker
return nil
diff --git a/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.deepcopy.go b/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.deepcopy.go
index 379be66e8..4d1a2f6b6 100644
--- a/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.deepcopy.go
+++ b/controllers/provider-gcp/pkg/apis/gcp/v1alpha1/zz_generated.deepcopy.go
@@ -47,6 +47,27 @@ func (in *CloudControllerManagerConfig) DeepCopy() *CloudControllerManagerConfig
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *CloudNAT) DeepCopyInto(out *CloudNAT) {
+ *out = *in
+ if in.MinPortsPerVM != nil {
+ in, out := &in.MinPortsPerVM, &out.MinPortsPerVM
+ *out = new(int32)
+ **out = **in
+ }
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudNAT.
+func (in *CloudNAT) DeepCopy() *CloudNAT {
+ if in == nil {
+ return nil
+ }
+ out := new(CloudNAT)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CloudProfileConfig) DeepCopyInto(out *CloudProfileConfig) {
*out = *in
@@ -238,6 +259,11 @@ func (in *NetworkConfig) DeepCopyInto(out *NetworkConfig) {
*out = new(VPC)
(*in).DeepCopyInto(*out)
}
+ if in.CloudNAT != nil {
+ in, out := &in.CloudNAT, &out.CloudNAT
+ *out = new(CloudNAT)
+ (*in).DeepCopyInto(*out)
+ }
if in.Internal != nil {
in, out := &in.Internal, &out.Internal
*out = new(string)
diff --git a/controllers/provider-gcp/pkg/apis/gcp/zz_generated.deepcopy.go b/controllers/provider-gcp/pkg/apis/gcp/zz_generated.deepcopy.go
index ea13e9419..36ac525be 100644
--- a/controllers/provider-gcp/pkg/apis/gcp/zz_generated.deepcopy.go
+++ b/controllers/provider-gcp/pkg/apis/gcp/zz_generated.deepcopy.go
@@ -47,6 +47,27 @@ func (in *CloudControllerManagerConfig) DeepCopy() *CloudControllerManagerConfig
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *CloudNAT) DeepCopyInto(out *CloudNAT) {
+ *out = *in
+ if in.MinPortsPerVM != nil {
+ in, out := &in.MinPortsPerVM, &out.MinPortsPerVM
+ *out = new(int32)
+ **out = **in
+ }
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudNAT.
+func (in *CloudNAT) DeepCopy() *CloudNAT {
+ if in == nil {
+ return nil
+ }
+ out := new(CloudNAT)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CloudProfileConfig) DeepCopyInto(out *CloudProfileConfig) {
*out = *in
@@ -238,6 +259,11 @@ func (in *NetworkConfig) DeepCopyInto(out *NetworkConfig) {
*out = new(VPC)
(*in).DeepCopyInto(*out)
}
+ if in.CloudNAT != nil {
+ in, out := &in.CloudNAT, &out.CloudNAT
+ *out = new(CloudNAT)
+ (*in).DeepCopyInto(*out)
+ }
if in.Internal != nil {
in, out := &in.Internal, &out.Internal
*out = new(string)
diff --git a/controllers/provider-gcp/pkg/internal/infrastructure/terraform.go b/controllers/provider-gcp/pkg/internal/infrastructure/terraform.go
index 6170e5b00..3d714bc0a 100644
--- a/controllers/provider-gcp/pkg/internal/infrastructure/terraform.go
+++ b/controllers/provider-gcp/pkg/internal/infrastructure/terraform.go
@@ -69,6 +69,7 @@ func ComputeTerraformerChartValues(
createVPC = true
createCloudRouter = true
cloudRouterName string
+ minPortsPerVM = int32(2048)
)
if config.Networks.VPC != nil {
@@ -81,6 +82,12 @@ func ComputeTerraformerChartValues(
}
}
+ if config.Networks.CloudNAT != nil {
+ if config.Networks.CloudNAT.MinPortsPerVM != nil {
+ minPortsPerVM = *config.Networks.CloudNAT.MinPortsPerVM
+ }
+ }
+
vpc := map[string]interface{}{
"name": vpcName,
}
@@ -107,6 +114,9 @@ func ComputeTerraformerChartValues(
"services": extensionscontroller.GetServiceNetwork(cluster),
"worker": config.Networks.Worker,
"internal": config.Networks.Internal,
+ "cloudNAT": map[string]interface{}{
+ "minPortsPerVM": minPortsPerVM,
+ },
},
"outputKeys": map[string]interface{}{
"vpcName": TerraformerOutputKeyVPCName,
diff --git a/controllers/provider-gcp/pkg/internal/infrastructure/terraform_test.go b/controllers/provider-gcp/pkg/internal/infrastructure/terraform_test.go
index 96c0a86d1..13d9f3c08 100644
--- a/controllers/provider-gcp/pkg/internal/infrastructure/terraform_test.go
+++ b/controllers/provider-gcp/pkg/internal/infrastructure/terraform_test.go
@@ -42,6 +42,8 @@ var _ = Describe("Terraform", func() {
serviceAccountData []byte
serviceAccount *internal.ServiceAccount
+ minPortsPerVM = int32(2048)
+
podsCIDR = "11.0.0.0/16"
servicesCIDR = "12.0.0.0/16"
@@ -218,6 +220,9 @@ var _ = Describe("Terraform", func() {
"services": servicesCIDR,
"worker": config.Networks.Worker,
"internal": config.Networks.Internal,
+ "cloudNAT": map[string]interface{}{
+ "minPortsPerVM": minPortsPerVM,
+ },
},
"outputKeys": map[string]interface{}{
"vpcName": TerraformerOutputKeyVPCName,
@@ -252,6 +257,9 @@ var _ = Describe("Terraform", func() {
"services": servicesCIDR,
"worker": config.Networks.Worker,
"internal": config.Networks.Internal,
+ "cloudNAT": map[string]interface{}{
+ "minPortsPerVM": minPortsPerVM,
+ },
},
"outputKeys": map[string]interface{}{
"vpcName": TerraformerOutputKeyVPCName,