Skip to content

Commit

Permalink
support kubernetes services vpc (#3673)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmcshane authored Sep 28, 2023
1 parent 9289bdc commit cff68bb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 19 deletions.
14 changes: 7 additions & 7 deletions dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@loadable/component": "^5.15.2",
"@material-ui/core": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
"@porter-dev/api-contracts": "^0.1.7",
"@porter-dev/api-contracts": "^0.2.1",
"@react-spring/web": "^9.6.1",
"@sentry/react": "^6.13.2",
"@sentry/tracing": "^6.13.2",
Expand Down
37 changes: 30 additions & 7 deletions dashboard/src/components/ProvisionerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import {
EKSLogging,
EKSPreflightValues,
PreflightCheckRequest,
GKE
AWSClusterNetwork,
} from "@porter-dev/api-contracts";

import { ClusterType } from "shared/types";
import Button from "./porter/Button";
import Error from "./porter/Error";
Expand Down Expand Up @@ -94,6 +95,9 @@ const clusterVersionOptions = [
{ value: "v1.24.0", label: "1.24.0" },
];

const defaultCidrVpc = "10.78.0.0/16"
const defaultCidrServices = "172.20.0.0/16"

type Props = RouteComponentProps & {
selectedClusterVersion?: Contract;
provisionerError?: string;
Expand Down Expand Up @@ -134,7 +138,8 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
const [additionalNodePolicies, setAdditionalNodePolicies] = useState<
string[]
>([]);
const [cidrRange, setCidrRange] = useState("10.78.0.0/16");
const [cidrRangeVPC, setCidrRangeVPC] = useState(defaultCidrVpc);
const [cidrRangeServices, setCidrRangeServices] = useState(defaultCidrServices);
const [clusterVersion, setClusterVersion] = useState("v1.24.0");
const [isReadOnly, setIsReadOnly] = useState(false);
const [errorMessage, setErrorMessage] = useState<string>(undefined);
Expand Down Expand Up @@ -295,12 +300,16 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
value: new EKS({
clusterName,
clusterVersion: clusterVersion || "v1.24.0",
cidrRange: cidrRange || "10.78.0.0/16",
cidrRange: cidrRangeVPC || defaultCidrVpc, // deprecated in favour of network.cidrRangeVPC: can be removed after december 2023
region: awsRegion,
loadBalancer: loadBalancerObj,
logging: controlPlaneLogs,
enableGuardDuty: guardDutyEnabled,
enableKmsEncryption: kmsEncryptionEnabled,
network: new AWSClusterNetwork({
vpcCidr: cidrRangeVPC || defaultCidrVpc,
serviceCidr: cidrRangeServices || defaultCidrServices,
}),
nodeGroups: [
new EKSNodeGroup({
instanceType: "t3.medium",
Expand Down Expand Up @@ -450,7 +459,11 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
setClusterName(eksValues.clusterName);
setAwsRegion(eksValues.region);
setClusterVersion(eksValues.clusterVersion);
setCidrRange(eksValues.cidrRange);
setCidrRangeVPC(eksValues.cidrRange);
if (eksValues.network != null) {
setCidrRangeVPC(eksValues.network?.vpcCidr || defaultCidrVpc);
setCidrRangeServices(eksValues.network?.serviceCidr || defaultCidrServices);
}
if (eksValues.loadBalancer != null) {
setIPAllowList(eksValues.loadBalancer.allowlistIpRanges);
setWildCardDomain(eksValues.loadBalancer.wildcardDomain);
Expand Down Expand Up @@ -618,12 +631,22 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
<Input
width="350px"
type="string"
value={cidrRange}
value={cidrRangeVPC}
disabled={!user.isPorterUser}
setValue={(x: string) => setCidrRange(x)}
label="VPC CIDR range"
setValue={(x: string) => setCidrRangeVPC(x)}
label="CIDR range for AWS VPC"
placeholder="ex: 10.78.0.0/16"
/>
<Spacer y={1} />
<Input
width="350px"
type="string"
value={cidrRangeServices}
disabled={!user.isPorterUser}
setValue={(x: string) => setCidrRangeServices(x)}
label="CIDR range for Kubernetes internal services"
placeholder="ex: 172.20.0.0/16"
/>
{!currentProject.simplified_view_enabled && (
<>
<Spacer y={1} />
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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.1.9
github.com/porter-dev/api-contracts v0.2.1
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
Expand Down Expand Up @@ -230,7 +230,7 @@ require (
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gdamore/tcell/v2 v2.5.1 // indirect
github.com/ghodss/yaml v1.0.0
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,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.1.9 h1:EGNZjVjBKPIP+w7fcMhi3njWEt1V1kiK8cd2h87vFQk=
github.com/porter-dev/api-contracts v0.1.9/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
github.com/porter-dev/api-contracts v0.2.1 h1:Xb1ngCQuLJIa38OY/K+fE6uvCTEiJCSzcSnh7EFLHZ0=
github.com/porter-dev/api-contracts v0.2.1/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=
Expand Down

0 comments on commit cff68bb

Please sign in to comment.