-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [LKEAPIFW-428] LKE clusters should have IP ACL integration on C…
…M (part 1) (#10968) * [LKEAPIFW-428] LKE clusters now have IP ACLs * [LKEAPIFW-428] Migration of non-ipacl'd clusters now working * [LKEAPIFW-428] Ongoing UI tweaks * [LKEAPIFW-428] Additional UI tweaks * [LKEAPIFW-428] Substituition of UI components * [LKEAPIFW-428] Another round of UI tweaks: multiline IP default values; IPACL drawer showing enabled only when enabled wip * fix multiple ip css issues * [LKEAPIFW-428] Copy text adjustment * add changeset * Added changeset: ACL related endpoints and types for LKE clusters * fix small eslint warnings + update spacing/design review with Daniel * get rid of extra divider, will need to make a few more design updates * updates as per Daniel's feedback * margin fixes * height issues * quick initial cleanup * refactor some styling, initial transition to react-hook-form? * adding some code description around the update cluster calls * move button file to Kube summary panel * invalidate query after installing ipacl * additional cleanup * new UX changes, remove refresh * make function async * some bit more cleanup * use shape of payload?? need to cleanup * make more generic * cleanup * fix validation schema * allow empty addresses * update copies to most recent, add enabled to query * add footer, address feedback, tag bug * address feedback + quick design feedback * design feedback quick change * notice style update * address feedback * update copies --------- Co-authored-by: Talmai Oliveira <toliveir@akamai.com> Co-authored-by: Hana Xu <hxu@akamai.com> Co-authored-by: Connie Liu <coliu@akamai.com>
- Loading branch information
1 parent
b64a39d
commit 8b9d956
Showing
22 changed files
with
1,034 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/api-v4": Added | ||
--- | ||
|
||
ACL related endpoints and types for LKE clusters ([#10968](https://github.com/linode/manager/pull/10968)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
IP ACL integration to LKE clusters ([#10968](https://github.com/linode/manager/pull/10968)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/manager/src/components/MultipleIPInput/MultipleNonExtendedIPInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as React from 'react'; | ||
|
||
import { MultipleIPInput } from './MultipleIPInput'; | ||
|
||
import type { MultipeIPInputProps } from './MultipleIPInput'; | ||
import type { FieldError, Merge } from 'react-hook-form'; | ||
import type { ExtendedIP } from 'src/utilities/ipUtils'; | ||
|
||
interface Props extends Omit<MultipeIPInputProps, 'ips' | 'onChange'> { | ||
ipErrors?: Merge<FieldError, (FieldError | undefined)[]>; | ||
nonExtendedIPs: string[]; | ||
onNonExtendedIPChange: (ips: string[]) => void; | ||
} | ||
|
||
/** | ||
* Quick wrapper for MultipleIPInput so that we do not have to directly use the type ExtendedIP (which has its own error field) | ||
* | ||
* I wanted to avoid touching MultipleIPInput too much, since a lot of other flows use that component. This component was | ||
* made with 'react-hook-form' in mind, taking in 'react-hook-form' errors and mapping them to the given (non | ||
* extended) IPs. We might eventually try to completely remove the ExtendedIP type - see | ||
* https://github.com/linode/manager/pull/10968#discussion_r1800089369 for context | ||
*/ | ||
export const MultipleNonExtendedIPInput = (props: Props) => { | ||
const { ipErrors, nonExtendedIPs, onNonExtendedIPChange, ...rest } = props; | ||
|
||
const extendedIPs: ExtendedIP[] = | ||
nonExtendedIPs.map((ip, idx) => { | ||
return { | ||
address: ip, | ||
error: ipErrors ? ipErrors[idx]?.message : '', | ||
}; | ||
}) ?? []; | ||
|
||
return ( | ||
<MultipleIPInput | ||
{...rest} | ||
onChange={(ips) => { | ||
const _ips = ips.map((ip) => { | ||
return ip.address; | ||
}); | ||
onNonExtendedIPChange(_ips); | ||
}} | ||
ips={extendedIPs} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
packages/manager/src/features/Kubernetes/CreateCluster/ControlPlaneACLPane.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { FormLabel } from '@mui/material'; | ||
import * as React from 'react'; | ||
|
||
import { Box } from 'src/components/Box'; | ||
import { ErrorMessage } from 'src/components/ErrorMessage'; | ||
import { FormControl } from 'src/components/FormControl'; | ||
import { FormControlLabel } from 'src/components/FormControlLabel'; | ||
import { MultipleIPInput } from 'src/components/MultipleIPInput/MultipleIPInput'; | ||
import { Notice } from 'src/components/Notice/Notice'; | ||
import { Toggle } from 'src/components/Toggle/Toggle'; | ||
import { Typography } from 'src/components/Typography'; | ||
import { validateIPs } from 'src/utilities/ipUtils'; | ||
|
||
import type { ExtendedIP } from 'src/utilities/ipUtils'; | ||
|
||
export interface ControlPlaneACLProps { | ||
enableControlPlaneACL: boolean; | ||
errorText: string | undefined; | ||
handleIPv4Change: (ips: ExtendedIP[]) => void; | ||
handleIPv6Change: (ips: ExtendedIP[]) => void; | ||
ipV4Addr: ExtendedIP[]; | ||
ipV6Addr: ExtendedIP[]; | ||
setControlPlaneACL: (enabled: boolean) => void; | ||
} | ||
|
||
export const ControlPlaneACLPane = (props: ControlPlaneACLProps) => { | ||
const { | ||
enableControlPlaneACL, | ||
errorText, | ||
handleIPv4Change, | ||
handleIPv6Change, | ||
ipV4Addr, | ||
ipV6Addr, | ||
setControlPlaneACL, | ||
} = props; | ||
|
||
return ( | ||
<> | ||
<FormControl data-testid="control-plane-ipacl-form"> | ||
<FormLabel id="ipacl-radio-buttons-group-label"> | ||
<Typography variant="inherit">Control Plane ACL</Typography> | ||
</FormLabel> | ||
{errorText && ( | ||
<Notice spacingTop={8} variant="error"> | ||
<ErrorMessage message={errorText} />{' '} | ||
</Notice> | ||
)} | ||
<Typography mb={1} sx={{ width: '85%' }}> | ||
Enable an access control list (ACL) on your LKE cluster to restrict | ||
access to your cluster’s control plane. When enabled, only the IP | ||
addresses and ranges specified by you can connect to the control | ||
plane. | ||
</Typography> | ||
<FormControlLabel | ||
control={ | ||
<Toggle | ||
checked={enableControlPlaneACL} | ||
name="ipacl-checkbox" | ||
onChange={() => setControlPlaneACL(!enableControlPlaneACL)} | ||
/> | ||
} | ||
label="Enable Control Plane ACL" | ||
/> | ||
</FormControl> | ||
{enableControlPlaneACL && ( | ||
<Box sx={{ marginBottom: 3, maxWidth: 450 }}> | ||
<MultipleIPInput | ||
onBlur={(_ips: ExtendedIP[]) => { | ||
const validatedIPs = validateIPs(_ips, { | ||
allowEmptyAddress: true, | ||
errorMessage: 'Must be a valid IPv4 address.', | ||
}); | ||
handleIPv4Change(validatedIPs); | ||
}} | ||
buttonText="Add IPv4 Address" | ||
ips={ipV4Addr} | ||
isLinkStyled | ||
onChange={handleIPv4Change} | ||
placeholder="0.0.0.0/0" | ||
title="IPv4 Addresses or CIDRs" | ||
/> | ||
<Box marginTop={2}> | ||
<MultipleIPInput | ||
onBlur={(_ips: ExtendedIP[]) => { | ||
const validatedIPs = validateIPs(_ips, { | ||
allowEmptyAddress: true, | ||
errorMessage: 'Must be a valid IPv6 address.', | ||
}); | ||
handleIPv6Change(validatedIPs); | ||
}} | ||
buttonText="Add IPv6 Address" | ||
ips={ipV6Addr} | ||
isLinkStyled | ||
onChange={handleIPv6Change} | ||
placeholder="::/0" | ||
title="IPv6 Addresses or CIDRs" | ||
/> | ||
</Box> | ||
</Box> | ||
)} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.