Forráskód Böngészése

GKE Instance type change (#3842)

Co-authored-by: Soham Dessai <sd5we@virginia.edu>
Co-authored-by: sdess09 <37374498+sdess09@users.noreply.github.com>
Stefan McShane 2 éve
szülő
commit
f61bc2c209

+ 1 - 2
api/server/handlers/project_integration/preflight_check.go

@@ -4,9 +4,8 @@ import (
 	"fmt"
 	"net/http"
 
-	"github.com/porter-dev/api-contracts/generated/go/helpers"
-
 	"connectrpc.com/connect"
+	"github.com/porter-dev/api-contracts/generated/go/helpers"
 	porterv1 "github.com/porter-dev/api-contracts/generated/go/porter/v1"
 	"github.com/porter-dev/porter/api/server/handlers"
 	"github.com/porter-dev/porter/api/server/shared"

+ 45 - 4
dashboard/src/components/GCPProvisionerSettings.tsx

@@ -39,6 +39,7 @@ import ExpandableSection from "./porter/ExpandableSection";
 import PreflightChecks from "./PreflightChecks";
 import VerticalSteps from "./porter/VerticalSteps";
 import { useIntercom } from "lib/hooks/useIntercom";
+import { log } from "console";
 
 
 const locationOptions = [
@@ -55,7 +56,21 @@ const defaultClusterNetworking = new GKENetwork({
   serviceCidr: "10.75.0.0/16",
 });
 
-const clusterVersionOptions = [{ value: "1.25", label: "v1.25" }, { value: "1.26", label: "v1.26" }, { value: "1.27", label: "v1.27" }];
+const instanceTypes = [
+  { value: "e2-standard-2", label: "e2-standard-2" },
+  { value: "e2-standard-2", label: "e2-standard-4" },
+  { value: "e2-standard-8", label: "e2-standard-8" },
+  { value: "e2-standard-16", label: "e2-standard-16" },
+  { value: "e2-standard-32", label: "e2-standard-32" },
+  { value: "e2-standard-32", label: "e2-standard-32" },
+  // { value: "n1-standard-1", label: "n1-standard-1" }, // start of GPU nodes. 
+  // { value: "n1-standard-2", label: "n1-standard-2" },
+  // { value: "n1-standard-4", label: "n1-standard-4" },
+  // { value: "n1-standard-8", label: "n1-standard-8" },
+  // { value: "n1-standard-16", label: "n1-standard-16" }, // Maximum of 1 GPU per node until further notice
+];
+
+const clusterVersionOptions = [{ value: "1.27", label: "v1.27" }];
 
 type Props = RouteComponentProps & {
   selectedClusterVersion?: Contract;
@@ -83,6 +98,7 @@ const GCPProvisionerSettings: React.FC<Props> = (props) => {
   const [maxInstances, setMaxInstances] = useState(10);
   const [clusterNetworking, setClusterNetworking] = useState(defaultClusterNetworking);
   const [clusterVersion, setClusterVersion] = useState(clusterVersionOptions[0].value);
+  const [instanceType, setInstanceType] = useState(instanceTypes[0].value);
   const [isReadOnly, setIsReadOnly] = useState(false);
   const [errorMessage, setErrorMessage] = useState<string>("");
   const [errorDetails, setErrorDetails] = useState<string>("");
@@ -180,6 +196,20 @@ const GCPProvisionerSettings: React.FC<Props> = (props) => {
                 setActiveValue={setClusterVersion}
                 label="Cluster version"
               />
+              <Spacer y={0.25} />
+
+              <SelectRow
+                options={instanceTypes}
+                width="350px"
+                disabled={isReadOnly}
+                value={instanceType}
+                scrollBuffer={true}
+                dropdownMaxHeight="240px"
+                setActiveValue={setInstanceType}
+                label="Instance Type"
+              />
+              <Spacer y={0.25} />
+
               <InputRow
                 width="350px"
                 type="string"
@@ -261,7 +291,6 @@ const GCPProvisionerSettings: React.FC<Props> = (props) => {
                 maxInstances: 1,
                 nodePoolType: GKENodePoolType.GKE_NODE_POOL_TYPE_MONITORING
               }),
-
               new GKENodePool({
                 instanceType: "custom-2-4096",
                 minInstances: 1,
@@ -269,7 +298,7 @@ const GCPProvisionerSettings: React.FC<Props> = (props) => {
                 nodePoolType: GKENodePoolType.GKE_NODE_POOL_TYPE_SYSTEM
               }),
               new GKENodePool({
-                instanceType: "custom-2-4096",
+                instanceType: instanceType,
                 minInstances: 1, // TODO: make these customizable before merging
                 maxInstances: 10, // TODO: make these customizable before merging
                 nodePoolType: GKENodePoolType.GKE_NODE_POOL_TYPE_APPLICATION
@@ -358,9 +387,10 @@ const GCPProvisionerSettings: React.FC<Props> = (props) => {
     if (contract?.cluster) {
       if (contract.cluster?.gkeKind?.nodePools) {
         contract.cluster?.gkeKind?.nodePools.map((nodePool: any) => {
-          if (nodePool.nodePoolType === "NODE_POOL_TYPE_APPLICATION") {
+          if (nodePool.nodePoolType === "GKE_NODE_POOL_TYPE_APPLICATION") {
             setMinInstances(nodePool.minInstances);
             setMaxInstances(nodePool.maxInstances);
+            setInstanceType(nodePool.instanceType);
           }
         });
       }
@@ -529,6 +559,17 @@ const GCPProvisionerSettings: React.FC<Props> = (props) => {
             setActiveValue={setClusterVersion}
             label="Cluster version"
           />
+          <Spacer y={1} />
+          <SelectRow
+            options={instanceTypes}
+            width="350px"
+            disabled={isReadOnly}
+            value={instanceType}
+            scrollBuffer={true}
+            dropdownMaxHeight="240px"
+            setActiveValue={setInstanceType}
+            label="Instance Type"
+          />
         </StyledForm>
 
         <Button