Răsfoiți Sursa

increase ram of monitoring node; update cost consent; allow for configurable SKU tier (#4044)

d-g-town 2 ani în urmă
părinte
comite
ed5722c676

+ 7 - 7
dashboard/package-lock.json

@@ -91,7 +91,7 @@
         "@babel/preset-typescript": "^7.15.0",
         "@ianvs/prettier-plugin-sort-imports": "^4.1.1",
         "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
-        "@porter-dev/api-contracts": "^0.2.52",
+        "@porter-dev/api-contracts": "^0.2.59",
         "@testing-library/jest-dom": "^4.2.4",
         "@testing-library/react": "^9.3.2",
         "@testing-library/user-event": "^7.1.2",
@@ -2658,9 +2658,9 @@
       }
     },
     "node_modules/@porter-dev/api-contracts": {
-      "version": "0.2.52",
-      "resolved": "https://registry.npmjs.org/@porter-dev/api-contracts/-/api-contracts-0.2.52.tgz",
-      "integrity": "sha512-mzRnBLm56vbX5wwgLnPqGHu9DpMacuESRYwQGszdWzK0T8xZiGEApHYCU1m+G9yYUUXaGUAGYgMrEBbkYwkj2g==",
+      "version": "0.2.59",
+      "resolved": "https://registry.npmjs.org/@porter-dev/api-contracts/-/api-contracts-0.2.59.tgz",
+      "integrity": "sha512-gYo+kO70nENeeovdQOo+hWd49r3X5LCcmc4dQFuSBpjRtpflCaDhPlW10Eq9ICyU7+gt2GRTv9PN7KWXhbcaiQ==",
       "dev": true,
       "dependencies": {
         "@bufbuild/protobuf": "^1.1.0"
@@ -19826,9 +19826,9 @@
       "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A=="
     },
     "@porter-dev/api-contracts": {
-      "version": "0.2.52",
-      "resolved": "https://registry.npmjs.org/@porter-dev/api-contracts/-/api-contracts-0.2.52.tgz",
-      "integrity": "sha512-mzRnBLm56vbX5wwgLnPqGHu9DpMacuESRYwQGszdWzK0T8xZiGEApHYCU1m+G9yYUUXaGUAGYgMrEBbkYwkj2g==",
+      "version": "0.2.59",
+      "resolved": "https://registry.npmjs.org/@porter-dev/api-contracts/-/api-contracts-0.2.59.tgz",
+      "integrity": "sha512-gYo+kO70nENeeovdQOo+hWd49r3X5LCcmc4dQFuSBpjRtpflCaDhPlW10Eq9ICyU7+gt2GRTv9PN7KWXhbcaiQ==",
       "dev": true,
       "requires": {
         "@bufbuild/protobuf": "^1.1.0"

+ 1 - 1
dashboard/package.json

@@ -98,7 +98,7 @@
     "@babel/preset-typescript": "^7.15.0",
     "@ianvs/prettier-plugin-sort-imports": "^4.1.1",
     "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
-    "@porter-dev/api-contracts": "^0.2.52",
+    "@porter-dev/api-contracts": "^0.2.59",
     "@testing-library/jest-dom": "^4.2.4",
     "@testing-library/react": "^9.3.2",
     "@testing-library/user-event": "^7.1.2",

+ 5 - 0
dashboard/src/assets/dot-vertical.svg

@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M12.0001 7.1999C10.6746 7.1999 9.6001 6.12539 9.6001 4.7999C9.6001 3.47442 10.6746 2.3999 12.0001 2.3999C13.3256 2.3999 14.4001 3.47442 14.4001 4.7999C14.4001 6.12539 13.3256 7.1999 12.0001 7.1999Z" stroke="white" stroke-width="2"/>
+<path d="M12.0001 14.3999C10.6746 14.3999 9.6001 13.3254 9.6001 11.9999C9.6001 10.6744 10.6746 9.5999 12.0001 9.5999C13.3256 9.5999 14.4001 10.6744 14.4001 11.9999C14.4001 13.3254 13.3256 14.3999 12.0001 14.3999Z" stroke="white" stroke-width="2"/>
+<path d="M12.0001 21.5999C10.6746 21.5999 9.6001 20.5254 9.6001 19.1999C9.6001 17.8744 10.6746 16.7999 12.0001 16.7999C13.3256 16.7999 14.4001 17.8744 14.4001 19.1999C14.4001 20.5254 13.3256 21.5999 12.0001 21.5999Z" stroke="white" stroke-width="2"/>
+</svg>

+ 2 - 12
dashboard/src/components/AzureCostConsent.tsx

@@ -1,24 +1,14 @@
-import React, { useState, useContext, useMemo } from "react";
+import React, { useState } from "react";
 import styled from "styled-components";
 
-import { integrationList } from "shared/common";
-import { Context } from "shared/Context";
-import api from "shared/api";
-
-import ProvisionerForm from "components/ProvisionerForm";
-import CloudFormationForm from "components/CloudFormationForm";
-import CredentialsForm from "components/CredentialsForm";
-import Helper from "components/form-components/Helper";
 import Modal from "./porter/Modal";
 import Text from "./porter/Text";
 import Spacer from "./porter/Spacer";
 import Fieldset from "./porter/Fieldset";
-import Checkbox from "./porter/Checkbox";
 import Button from "./porter/Button";
 import ExpandableSection from "./porter/ExpandableSection";
 import Input from "./porter/Input";
 import Link from "./porter/Link";
-import AzureCredentialForm from "components/AzureCredentialForm";
 
 type Props = {
   setCurrentStep: (step: string) => void;
@@ -103,7 +93,7 @@ const AzureCostConsent: React.FC<Props> = ({
         <Spacer y={0.5} />
         <Text color="helper">
           All Azure resources will be automatically deleted when you delete your
-          Porter project. Please enter the Azure base cost ("210.24") below to
+          Porter project. Please enter the Azure base cost (&quot;210.24&quot;) below to
           proceed:
         </Text>
         <Spacer y={1} />

+ 76 - 26
dashboard/src/components/AzureProvisionerSettings.tsx

@@ -1,33 +1,36 @@
-import React, { useEffect, useState, useContext } from "react";
+import React, {useContext, useEffect, useState} from "react";
 import styled from "styled-components";
-import { type RouteComponentProps, withRouter } from "react-router";
+import {type RouteComponentProps, withRouter} from "react-router";
 
-import { OFState } from "main/home/onboarding/state";
+import {OFState} from "main/home/onboarding/state";
 import api from "shared/api";
-import { Context } from "shared/Context";
-import { pushFiltered } from "shared/routing";
+import {Context} from "shared/Context";
+import {pushFiltered} from "shared/routing";
 
 import SelectRow from "components/form-components/SelectRow";
 import Heading from "components/form-components/Heading";
-import Helper from "components/form-components/Helper";
 import InputRow from "./form-components/InputRow";
 import {
-  Contract,
-  EnumKubernetesKind,
-  EnumCloudProvider,
-  Cluster,
   AKS,
   AKSNodePool,
-  NodePoolType,
+  AksSkuTier,
+  Cluster,
+  Contract,
+  EnumCloudProvider,
+  EnumKubernetesKind,
+  NodePoolType
 } from "@porter-dev/api-contracts";
-import { type ClusterType } from "shared/types";
+import {type ClusterType} from "shared/types";
 import Button from "./porter/Button";
 import Error from "./porter/Error";
 import Spacer from "./porter/Spacer";
 import Step from "./porter/Step";
 import Link from "./porter/Link";
 import Text from "./porter/Text";
-import { useIntercom } from "lib/hooks/useIntercom";
+import {useIntercom} from "lib/hooks/useIntercom";
+import Icon from "./porter/Icon";
+import dotVertical from "assets/dot-vertical.svg";
+import {Label} from "@tanstack/react-query-devtools/build/lib/Explorer";
 
 const locationOptions = [
   { value: "eastus", label: "East US" },
@@ -56,6 +59,11 @@ const machineTypeOptions = [
   { value: "Standard_A4_v2", label: "Standard_A4_v2" },
 ];
 
+const skuTierOptions = [
+  { value: AksSkuTier.FREE, label: "Free" },
+  { value: AksSkuTier.STANDARD, label: "Standard (for production workloads, +$73/month)" },
+];
+
 const clusterVersionOptions = [{ value: "v1.27.3", label: "v1.27" }, { value: "v1.24.9", label: "v1.24" }];
 
 type Props = RouteComponentProps & {
@@ -86,6 +94,7 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
   const [cidrRange, setCidrRange] = useState("10.78.0.0/16");
   const [clusterVersion, setClusterVersion] = useState("v1.27.3");
   const [isReadOnly, setIsReadOnly] = useState(false);
+  const [skuTier, setSkuTier] = useState(AksSkuTier.FREE)
   const [errorMessage, setErrorMessage] = useState<string>("");
   const [errorDetails, setErrorDetails] = useState<string>("");
   const [isClicked, setIsClicked] = useState(false);
@@ -198,7 +207,7 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
                 mode: "User",
               }),
               new AKSNodePool({
-                instanceType: "Standard_B2als_v2",
+                instanceType: "Standard_B2as_v2",
                 minInstances: 1,
                 maxInstances: 3,
                 nodePoolType: NodePoolType.MONITORING,
@@ -212,6 +221,7 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
                 mode: "User",
               }),
             ],
+            skuTier,
           }),
         },
       }),
@@ -295,20 +305,27 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
   }, []);
 
   useEffect(() => {
-    const contract = props.selectedClusterVersion as any;
-    if (contract?.cluster) {
-      contract.cluster.aksKind.nodePools.map((nodePool: any) => {
-        if (nodePool.nodePoolType === "NODE_POOL_TYPE_APPLICATION") {
+
+    if (!props.selectedClusterVersion) return;
+
+    // TODO: pass in contract as the already parsed object, rather than JSON (requires changes to AWS/GCP provisioning)
+    const contract = Contract.fromJsonString(JSON.stringify(props.selectedClusterVersion))
+
+    if (contract?.cluster?.kindValues && contract.cluster.kindValues.case === "aksKind") {
+      const aksValues = contract.cluster.kindValues.value
+      aksValues.nodePools.map((nodePool: AKSNodePool) => {
+        if (nodePool.nodePoolType === NodePoolType.APPLICATION) {
           setMachineType(nodePool.instanceType);
           setMinInstances(nodePool.minInstances);
           setMaxInstances(nodePool.maxInstances);
         }
       });
       setCreateStatus("");
-      setClusterName(contract.cluster.aksKind.clusterName);
-      setAzureLocation(contract.cluster.aksKind.location);
-      setClusterVersion(contract.cluster.aksKind.clusterVersion);
-      setCidrRange(contract.cluster.aksKind.cidrRange);
+      setClusterName(aksValues.clusterName);
+      setAzureLocation(aksValues.location);
+      setClusterVersion(aksValues.clusterVersion);
+      setCidrRange(aksValues.cidrRange);
+      setSkuTier(aksValues.skuTier)
     }
   }, [props.selectedClusterVersion]);
 
@@ -317,11 +334,11 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
     if (!props.clusterId) {
       return (
         <>
-          <Text size={16}>Select an Azure location</Text>
+          <Text size={16}>Select an Azure location and tier</Text>
           <Spacer y={1} />
           <Text color="helper">
-            Porter will automatically provision your infrastructure in the
-            specified location.
+            Porter will automatically provision your infrastructure with the
+            specified configuration.
           </Text>
           <Spacer height="10px" />
           <SelectRow
@@ -334,6 +351,22 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
             setActiveValue={setAzureLocation}
             label="📍 Azure location"
           />
+          <Spacer y={.75} />
+          <div style={{display: "flex", alignItems: "center"}}>
+            <Spacer inline x={.05}/>
+            <Icon src={dotVertical} height={"15px"}/>
+            <Spacer inline x={.1}/>
+            <Label>Azure Tier</Label>
+          </div>
+          <SelectRow
+              options={skuTierOptions}
+              width="350px"
+              disabled={isReadOnly}
+              value={skuTier}
+              scrollBuffer={true}
+              dropdownMaxHeight="240px"
+              setActiveValue={setSkuTier}
+          />
         </>
       );
     }
@@ -342,6 +375,7 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
     return (
       <>
         <Heading isAtTop>AKS configuration</Heading>
+        <Spacer y={0.75} />
         <SelectRow
           options={locationOptions}
           width="350px"
@@ -352,6 +386,22 @@ const AzureProvisionerSettings: React.FC<Props> = (props) => {
           setActiveValue={setAzureLocation}
           label="📍 Azure location"
         />
+        <Spacer y={.75} />
+        <div style={{display: "flex", alignItems: "center"}}>
+          <Spacer inline x={.05}/>
+          <Icon src={dotVertical} height={"15px"}/>
+          <Spacer inline x={.1}/>
+          <Label>Tier</Label>
+        </div>
+        <SelectRow
+            options={skuTierOptions}
+            width="350px"
+            disabled={isReadOnly}
+            value={skuTier}
+            scrollBuffer={true}
+            dropdownMaxHeight="240px"
+            setActiveValue={setSkuTier}
+        />
         {user?.isPorterUser && (
           <Heading>
             <ExpandHeader
@@ -590,4 +640,4 @@ const errorMessageToModal = (errorMessage: string) => {
     default:
       return null;
   }
-};
+};

+ 1 - 1
go.mod

@@ -83,7 +83,7 @@ require (
 	github.com/matryer/is v1.4.0
 	github.com/nats-io/nats.go v1.24.0
 	github.com/open-policy-agent/opa v0.44.0
-	github.com/porter-dev/api-contracts v0.2.58
+	github.com/porter-dev/api-contracts v0.2.59
 	github.com/riandyrn/otelchi v0.5.1
 	github.com/santhosh-tekuri/jsonschema/v5 v5.0.1
 	github.com/stefanmcshane/helm v0.0.0-20221213002717-88a4a2c6e77d

+ 2 - 6
go.sum

@@ -1520,12 +1520,8 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw=
-github.com/porter-dev/api-contracts v0.2.55 h1:H8RvD004mX4uWrlRVcL8kzo7ZtFQyZDN+X9j+2bW7fc=
-github.com/porter-dev/api-contracts v0.2.55/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
-github.com/porter-dev/api-contracts v0.2.56 h1:zym8eomipCj7BVQVlnCY4RjNv1tkduY68gsmwVJIfaQ=
-github.com/porter-dev/api-contracts v0.2.56/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
-github.com/porter-dev/api-contracts v0.2.58 h1:8h5ORZtaq2f1vyEdYD88ZOcHQmYJb77zs+lQXY82yrU=
-github.com/porter-dev/api-contracts v0.2.58/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
+github.com/porter-dev/api-contracts v0.2.59 h1:EV2xr9a5FpPHnTsz77W3dV/qWC8MnE0kOD+tBZuwhvE=
+github.com/porter-dev/api-contracts v0.2.59/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
 github.com/porter-dev/switchboard v0.0.3 h1:dBuYkiVLa5Ce7059d6qTe9a1C2XEORFEanhbtV92R+M=
 github.com/porter-dev/switchboard v0.0.3/go.mod h1:xSPzqSFMQ6OSbp42fhCi4AbGbQbsm6nRvOkrblFeXU4=
 github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=