From b67ec677bb5ef221cade0b0e660e465f6c9a2245 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Mon, 4 Mar 2024 13:19:29 -0500 Subject: [PATCH] add support for service cidr, show it in the create form (#4364) --- dashboard/src/lib/clusters/index.ts | 7 ++++++- dashboard/src/lib/clusters/types.ts | 3 +++ .../forms/aws/ConfigureEKSCluster.tsx | 14 +++++++++++++- .../forms/aws/CreateEKSClusterForm.tsx | 1 + .../forms/azure/CreateAKSClusterForm.tsx | 1 + .../forms/gcp/ConfigureGKECluster.tsx | 14 +++++++++++++- .../forms/gcp/CreateGKEClusterForm.tsx | 1 + .../infrastructure-dashboard/shared/NodeGroups.tsx | 10 +++++++--- .../tabs/overview/AKSClusterOverview.tsx | 1 + .../tabs/overview/EKSClusterOverview.tsx | 5 ++++- .../tabs/overview/GKEClusterOverview.tsx | 5 ++++- 11 files changed, 54 insertions(+), 8 deletions(-) diff --git a/dashboard/src/lib/clusters/index.ts b/dashboard/src/lib/clusters/index.ts index ddfaf7d784..f8e98ecd3e 100644 --- a/dashboard/src/lib/clusters/index.ts +++ b/dashboard/src/lib/clusters/index.ts @@ -97,8 +97,9 @@ function clientEKSConfigToProto( }); }), network: new AWSClusterNetwork({ - ...(existingConfig?.network ?? { serviceCidr: "172.20.0.0/16" }), // serviceCidr explicitly added for backwards compatibility with contracts without network fields + ...(existingConfig?.network ?? {}), vpcCidr: clientConfig.cidrRange, + serviceCidr: clientConfig.serviceCidrRange, }), loadBalancer: new LoadBalancer({ loadBalancerType: match(clientConfig.loadBalancer.type) @@ -164,6 +165,7 @@ function clientGKEConfigToProto( network: new GKENetwork({ ...(existingConfig?.network ?? {}), cidrRange: clientConfig.cidrRange, + serviceCidr: clientConfig.serviceCidrRange, }), }); } @@ -251,6 +253,7 @@ const clientEKSConfigFromProto = (value: EKS): EKSClientClusterConfig => { }; }), cidrRange: value.network?.vpcCidr ?? value.cidrRange ?? "", // network will always be provided in one of those fields + serviceCidrRange: value.network?.serviceCidr ?? "172.20.0.0/16", // serviceCidr explicitly added for backwards compatibility with contracts without network fields logging: { isApiServerLogsEnabled: value.logging?.enableApiServerLogs ?? false, isAuditLogsEnabled: value.logging?.enableAuditLogs ?? false, @@ -321,6 +324,7 @@ const clientGKEConfigFromProto = (value: GKE): GKEClientClusterConfig => { }; }), cidrRange: value.network?.cidrRange ?? "", // network will always be provided + serviceCidrRange: value.network?.serviceCidr ?? "", }; }; @@ -349,5 +353,6 @@ const clientAKSConfigFromProto = (value: AKS): AKSClientClusterConfig => { .with(AksSkuTier.STANDARD, () => "STANDARD" as const) .otherwise(() => "UNKNOWN" as const), cidrRange: value.cidrRange, + serviceCidrRange: "172.20.0.0/16", // not yet supported by AKS, this is a placeholder }; }; diff --git a/dashboard/src/lib/clusters/types.ts b/dashboard/src/lib/clusters/types.ts index 98da60162a..4983b69ec4 100644 --- a/dashboard/src/lib/clusters/types.ts +++ b/dashboard/src/lib/clusters/types.ts @@ -418,6 +418,7 @@ const eksConfigValidator = z.object({ region: awsRegionValidator, nodeGroups: eksNodeGroupValidator.array(), cidrRange: cidrRangeValidator, + serviceCidrRange: cidrRangeValidator, logging: z .object({ isApiServerLogsEnabled: z.boolean(), @@ -472,6 +473,7 @@ const gkeConfigValidator = z.object({ region: gcpRegionValidator, nodeGroups: gkeNodeGroupValidator.array(), cidrRange: cidrRangeValidator, + serviceCidrRange: cidrRangeValidator, }); const aksConfigValidator = z.object({ kind: z.literal("AKS"), @@ -481,6 +483,7 @@ const aksConfigValidator = z.object({ nodeGroups: aksNodeGroupValidator.array(), skuTier: z.enum(["UNKNOWN", "FREE", "STANDARD"]), cidrRange: cidrRangeValidator, + serviceCidrRange: cidrRangeValidator, }); const clusterConfigValidator = z.discriminatedUnion("kind", [ eksConfigValidator, diff --git a/dashboard/src/main/home/infrastructure-dashboard/forms/aws/ConfigureEKSCluster.tsx b/dashboard/src/main/home/infrastructure-dashboard/forms/aws/ConfigureEKSCluster.tsx index 83d83caeb2..12fbc28851 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/forms/aws/ConfigureEKSCluster.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/forms/aws/ConfigureEKSCluster.tsx @@ -93,7 +93,7 @@ const ConfigureEKSCluster: React.FC = ({ goBack }) => { CIDR range - Specify the CIDR range for your cluster. + Specify the VPC CIDR range for your cluster. = ({ goBack }) => { error={errors.cluster?.config?.cidrRange?.message} {...register("cluster.config.cidrRange")} /> + + + Specify the service CIDR range for your cluster. + + + ) : null, <> diff --git a/dashboard/src/main/home/infrastructure-dashboard/forms/aws/CreateEKSClusterForm.tsx b/dashboard/src/main/home/infrastructure-dashboard/forms/aws/CreateEKSClusterForm.tsx index efd5727792..b545b2df3d 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/forms/aws/CreateEKSClusterForm.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/forms/aws/CreateEKSClusterForm.tsx @@ -61,6 +61,7 @@ const CreateEKSClusterForm: React.FC = ({ }, ], cidrRange: "10.78.0.0/16", + serviceCidrRange: "172.20.0.0/16", }, }, }); diff --git a/dashboard/src/main/home/infrastructure-dashboard/forms/azure/CreateAKSClusterForm.tsx b/dashboard/src/main/home/infrastructure-dashboard/forms/azure/CreateAKSClusterForm.tsx index a5fc357423..5861ee6d81 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/forms/azure/CreateAKSClusterForm.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/forms/azure/CreateAKSClusterForm.tsx @@ -62,6 +62,7 @@ const CreateAKSClusterForm: React.FC = ({ }, ], cidrRange: "10.78.0.0/16", + serviceCidrRange: "172.20.0.0/16", // does not actually go into contract because not supported there yet skuTier: "FREE" as const, }, }, diff --git a/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/ConfigureGKECluster.tsx b/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/ConfigureGKECluster.tsx index 02cc2d25a7..de6727ddbf 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/ConfigureGKECluster.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/ConfigureGKECluster.tsx @@ -98,7 +98,7 @@ const ConfigureGKECluster: React.FC = ({ goBack }) => { CIDR range - Specify the CIDR range for your cluster. + Specify the VPC CIDR range for your cluster. = ({ goBack }) => { error={errors.cluster?.config?.cidrRange?.message} {...register("cluster.config.cidrRange")} /> + + + Specify the service CIDR range for your cluster. + + + ) : null, <> diff --git a/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/CreateGKEClusterForm.tsx b/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/CreateGKEClusterForm.tsx index 784a7d8403..004fc64b10 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/CreateGKEClusterForm.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/forms/gcp/CreateGKEClusterForm.tsx @@ -63,6 +63,7 @@ const CreateGKEClusterForm: React.FC = ({ }, ], cidrRange: "10.78.0.0/16", + serviceCidrRange: "172.20.0.0/16", }, }, }); diff --git a/dashboard/src/main/home/infrastructure-dashboard/shared/NodeGroups.tsx b/dashboard/src/main/home/infrastructure-dashboard/shared/NodeGroups.tsx index 9cd706bd26..97d38fab58 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/shared/NodeGroups.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/shared/NodeGroups.tsx @@ -22,8 +22,12 @@ import world from "assets/world.svg"; type Props = { availableMachineTypes: ClientMachineType[]; + isDefaultExpanded?: boolean; }; -const NodeGroups: React.FC = ({ availableMachineTypes }) => { +const NodeGroups: React.FC = ({ + availableMachineTypes, + isDefaultExpanded = true, +}) => { const { control } = useFormContext(); const { currentProject } = useContext(Context); const { @@ -52,7 +56,7 @@ const NodeGroups: React.FC = ({ availableMachineTypes }) => { {displayableNodeGroups.APPLICATION?.map((ng) => { return ( @@ -129,7 +133,7 @@ const NodeGroups: React.FC = ({ availableMachineTypes }) => { {displayableNodeGroups.CUSTOM?.map((ng) => { return ( diff --git a/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/AKSClusterOverview.tsx b/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/AKSClusterOverview.tsx index 32e0c4f652..5072754cbd 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/AKSClusterOverview.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/AKSClusterOverview.tsx @@ -77,6 +77,7 @@ const AKSClusterOverview: React.FC = () => { availableMachineTypes={CloudProviderAzure.machineTypes.filter((mt) => mt.supportedRegions.includes(region) )} + isDefaultExpanded={false} /> ); diff --git a/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/EKSClusterOverview.tsx b/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/EKSClusterOverview.tsx index 7a9eebb216..649f5e776c 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/EKSClusterOverview.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/EKSClusterOverview.tsx @@ -61,7 +61,10 @@ const EKSClusterOverview: React.FC = () => { - + ); }; diff --git a/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/GKEClusterOverview.tsx b/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/GKEClusterOverview.tsx index 18dfcdd848..4353208442 100644 --- a/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/GKEClusterOverview.tsx +++ b/dashboard/src/main/home/infrastructure-dashboard/tabs/overview/GKEClusterOverview.tsx @@ -51,7 +51,10 @@ const GKEClusterOverview: React.FC = () => { - + ); };