Skip to content

Commit

Permalink
add volumeMounts
Browse files Browse the repository at this point in the history
  • Loading branch information
zjy365 committed Jan 9, 2025
1 parent 64a8c12 commit 96005d0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions frontend/providers/applaunchpad/src/constants/editApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const defaultEditVal: AppEditType = {
},
storeList: [],
volumes: [],
volumeMounts: [],
gpu: {
manufacturers: 'nvidia',
type: '',
Expand Down
1 change: 1 addition & 0 deletions frontend/providers/applaunchpad/src/mock/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export const MOCK_PODS: PodDetailType[] = [
export const MOCK_APP_DETAIL: AppDetailType = {
kind: 'deployment',
volumes: [],
volumeMounts: [],
crYamlList: [],
id: '4bd50c41-149e-4da5-89d5-0308b9dd75c6',
createTime: '2022/1/22',
Expand Down
4 changes: 3 additions & 1 deletion frontend/providers/applaunchpad/src/types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import type {
V1Pod,
SinglePodMetrics,
V1StatefulSet,
V1Volume
V1Volume,
V1VolumeMount
} from '@kubernetes/client-node';
import { MonitorDataResult } from './monitor';

Expand Down Expand Up @@ -110,6 +111,7 @@ export interface AppEditType {
}[];
labels: { [key: string]: string };
volumes: V1Volume[];
volumeMounts: V1VolumeMount[];
kind: 'deployment' | 'statefulset';
}

Expand Down
17 changes: 16 additions & 1 deletion frontend/providers/applaunchpad/src/utils/adapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ export const adaptAppDetail = async (configs: DeployKindsType[]): Promise<AppDet
);
const gpuNodeSelector = useGpu ? appDeploy?.spec?.template?.spec?.nodeSelector : null;

const getFilteredVolumeMounts = () => {
const volumeMounts = appDeploy?.spec?.template?.spec?.containers?.[0]?.volumeMounts || [];
const configMapKeys = Object.keys(deployKindsMap.ConfigMap?.data || {});
const storeNames =
deployKindsMap.StatefulSet?.spec?.volumeClaimTemplates?.map(
(template) => template.metadata?.name
) || [];

return volumeMounts.filter(
(mount) => !configMapKeys.includes(mount.name) && !storeNames.includes(mount.name)
);
};

return {
labels: appDeploy?.metadata?.labels || {},
crYamlList: configs,
Expand Down Expand Up @@ -373,6 +386,7 @@ export const adaptAppDetail = async (configs: DeployKindsType[]): Promise<AppDet
value: Number(item.metadata?.annotations?.value || 0)
}))
: [],
volumeMounts: getFilteredVolumeMounts(),
// keep original non-configMap type volumes
volumes: appDeploy?.spec?.template?.spec?.volumes?.filter((volume) => !volume.configMap) || [],
kind: appDeploy?.kind?.toLowerCase() as 'deployment' | 'statefulset',
Expand All @@ -398,7 +412,8 @@ export const adaptEditAppData = (app: AppDetailType): AppEditType => {
'gpu',
'labels',
'kind',
'volumes'
'volumes',
'volumeMounts'
];

const res: Record<string, any> = {};
Expand Down
3 changes: 2 additions & 1 deletion frontend/providers/applaunchpad/src/utils/deployYaml2Json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const json2DeployCr = (data: AppEditType, type: 'deployment' | 'statefuls
containers: [
{
...commonContainer,
volumeMounts: [...configMapVolumeMounts]
volumeMounts: [...(data?.volumeMounts || []), ...configMapVolumeMounts]
}
],
...gpuMap,
Expand Down Expand Up @@ -202,6 +202,7 @@ export const json2DeployCr = (data: AppEditType, type: 'deployment' | 'statefuls
{
...commonContainer,
volumeMounts: [
...(data?.volumeMounts || []),
...configMapVolumeMounts,
...data.storeList.map((item) => ({
name: item.name,
Expand Down

0 comments on commit 96005d0

Please sign in to comment.