Skip to content

Commit 2f35c4a

Browse files
bnussman-akamaibnussmanmjac0bs
authored
feat: [M3-10039M, M3-10382] - Configure Kubernetes Node Pool Drawer (linode#12710)
* setup initial drawer and form components * add more fields to the new drawer * handle nodepool label properly throughout LKE * add feature flag and cluster tier logic * begin unit testing * add an e2e-like unit test * support tags * fix typo in the unit test comment * fix up ResizeNodePoolDrawer unit test to account for node pool label change in drawer title * fix unit test after adding tag support * change tags select label to just be `Tags` * ensure error is surfaced * keep the word `Plan` in drawer headers * update unit test to account for re-adding the `Plan` suffix to drawer titles * update version select logic to only include valid versions * improve unit test * use v4beta PUT endpoint so new fields actually work * Added changeset: Configure Node Pool Drawer to Kubernetes Cluster details page * Added changeset: Support for Node Pool `label` field * Added changeset: Use `v4beta` API endpoint for `updateNodePool` * fix spelling in comment * hide label & tag fields becuasse they lack PDT commitment * finish up comments * one more comment * Apply suggestions from code review Co-authored-by: Mariah Jacobs <[email protected]> * change changeset to be an upcoming feature * use shared `NodePoolConfigOptions` component @mjac0bs * work on error surfacing * restore inline validation, hopefully it works * `firewall_id` validation is working, but could use some clean up * undo unnessesary validation change * Revert "undo unnessesary validation change" This reverts commit baa45ee. * fix double save issue * clean up * fix form label issues in theme * don't allow user to select default firewall once one has been set * improve validation message * fix label html issue * unit test `getNodePoolVersionOptions` * lint * address feedback regarding `useNodePoolDisplayLabel` * make node pool firewall_id bahavior more forwards compatible with upcoming api changes * add comments --------- Co-authored-by: Banks Nussman <[email protected]> Co-authored-by: Mariah Jacobs <[email protected]>
1 parent d07f7be commit 2f35c4a

31 files changed

+910
-149
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Added
3+
---
4+
5+
Support for Node Pool `label` field ([#12710](https://github.com/linode/manager/pull/12710))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Changed
3+
---
4+
5+
Use `v4beta` API endpoint for `updateNodePool` ([#12710](https://github.com/linode/manager/pull/12710))

packages/api-v4/src/kubernetes/nodePools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const updateNodePool = (
7777
Request<KubeNodePoolResponse>(
7878
setMethod('PUT'),
7979
setURL(
80-
`${API_ROOT}/lke/clusters/${encodeURIComponent(
80+
`${BETA_API_ROOT}/lke/clusters/${encodeURIComponent(
8181
clusterID,
8282
)}/pools/${encodeURIComponent(nodePoolID)}`,
8383
),

packages/api-v4/src/kubernetes/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ export interface KubeNodePoolResponse {
7070
* @note Only returned for LKE Enterprise clusters
7171
*/
7272
k8s_version?: string;
73+
/**
74+
* A label/name for the Node Pool
75+
*
76+
* @default ""
77+
*/
78+
label: string;
7379
labels: Label;
7480
nodes: PoolNodeResponse[];
7581
tags: string[];
@@ -112,6 +118,12 @@ export interface CreateNodePoolData {
112118
* @note This field may be required when creating a Node Pool on a LKE Enterprise cluster
113119
*/
114120
k8s_version?: string;
121+
/**
122+
* An optional label/name for the Node Pool.
123+
*
124+
* @default ""
125+
*/
126+
label?: string;
115127
/**
116128
* Key-value pairs added as labels to nodes in the node pool.
117129
*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Configure Node Pool Drawer to Kubernetes Cluster details page ([#12710](https://github.com/linode/manager/pull/12710))

packages/manager/src/factories/kubernetesCluster.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const kubeLinodeFactory = Factory.Sync.makeFactory<PoolNodeResponse>({
1919
});
2020

2121
export const nodePoolFactory = Factory.Sync.makeFactory<KubeNodePoolResponse>({
22+
label: '',
2223
autoscaler: {
2324
enabled: false,
2425
max: 1,

packages/manager/src/features/Kubernetes/KubernetesClusterDetail/KubernetesClusterDetail.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export const KubernetesClusterDetail = () => {
156156
clusterLabel={cluster.label}
157157
clusterRegionId={cluster.region}
158158
clusterTier={cluster.tier ?? 'standard'}
159+
clusterVersion={cluster.k8s_version}
159160
isLkeClusterRestricted={isClusterReadOnly}
160161
/>
161162
</Stack>

packages/manager/src/features/Kubernetes/KubernetesClusterDetail/NodePoolsDisplay/AddNodePoolDrawer.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ export const AddNodePoolDrawer = (props: Props) => {
207207
name="update_strategy"
208208
render={({ field }) => (
209209
<NodePoolUpdateStrategySelect
210-
label="Update Strategy"
211-
noMarginTop
212210
onChange={field.onChange}
213211
value={field.value!}
214212
/>

packages/manager/src/features/Kubernetes/KubernetesClusterDetail/NodePoolsDisplay/AutoscaleNodePoolDrawer.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useSpecificTypes } from '@linode/queries';
21
import {
32
ActionsPanel,
43
Box,
@@ -18,12 +17,12 @@ import { makeStyles } from 'tss-react/mui';
1817
import { EnhancedNumberInput } from 'src/components/EnhancedNumberInput/EnhancedNumberInput';
1918
import { Link } from 'src/components/Link';
2019
import { useUpdateNodePoolMutation } from 'src/queries/kubernetes';
21-
import { extendType } from 'src/utilities/extendType';
2220

2321
import {
2422
MAX_NODES_PER_POOL_ENTERPRISE_TIER,
2523
MAX_NODES_PER_POOL_STANDARD_TIER,
2624
} from '../../constants';
25+
import { useNodePoolDisplayLabel } from './utils';
2726

2827
import type {
2928
AutoscaleSettings,
@@ -88,6 +87,7 @@ export const AutoscaleNodePoolDrawer = (props: Props) => {
8887
open,
8988
} = props;
9089
const autoscaler = nodePool?.autoscaler;
90+
const nodePoolLabel = useNodePoolDisplayLabel(nodePool, { suffix: 'Plan' });
9191
const { classes, cx } = useStyles();
9292
const { enqueueSnackbar } = useSnackbar();
9393

@@ -96,12 +96,6 @@ export const AutoscaleNodePoolDrawer = (props: Props) => {
9696
nodePool?.id ?? -1
9797
);
9898

99-
const typesQuery = useSpecificTypes(nodePool?.type ? [nodePool.type] : []);
100-
101-
const planType = typesQuery[0]?.data
102-
? extendType(typesQuery[0].data)
103-
: undefined;
104-
10599
const {
106100
clearErrors,
107101
control,
@@ -189,7 +183,7 @@ export const AutoscaleNodePoolDrawer = (props: Props) => {
189183
<Drawer
190184
onClose={handleClose}
191185
open={open}
192-
title={`Autoscale Pool: ${planType?.formattedLabel ?? 'Unknown'} Plan`}
186+
title={`Autoscale Pool: ${nodePoolLabel}`}
193187
>
194188
{errors.root?.message ? (
195189
<Notice spacingBottom={16} text={errors.root.message} variant="error" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Drawer } from '@linode/ui';
2+
import React from 'react';
3+
4+
import { useNodePoolDisplayLabel } from '../utils';
5+
import { ConfigureNodePoolForm } from './ConfigureNodePoolForm';
6+
7+
import type { KubeNodePoolResponse, KubernetesCluster } from '@linode/api-v4';
8+
9+
interface Props {
10+
clusterId: KubernetesCluster['id'];
11+
clusterTier: KubernetesCluster['tier'];
12+
clusterVersion: KubernetesCluster['k8s_version'];
13+
nodePool: KubeNodePoolResponse | undefined;
14+
onClose: () => void;
15+
open: boolean;
16+
}
17+
18+
export const ConfigureNodePoolDrawer = (props: Props) => {
19+
const { nodePool, onClose, clusterId, open, clusterTier, clusterVersion } =
20+
props;
21+
const nodePoolLabel = useNodePoolDisplayLabel(nodePool, { suffix: 'Plan' });
22+
23+
return (
24+
<Drawer
25+
onClose={onClose}
26+
open={open}
27+
title={`Configure Node Pool: ${nodePoolLabel}`}
28+
>
29+
{nodePool && (
30+
<ConfigureNodePoolForm
31+
clusterId={clusterId}
32+
clusterTier={clusterTier}
33+
clusterVersion={clusterVersion}
34+
nodePool={nodePool}
35+
onDone={onClose}
36+
/>
37+
)}
38+
</Drawer>
39+
);
40+
};

0 commit comments

Comments
 (0)