chore: add runtime in register k8s command
This commit is contained in:
@@ -31,25 +31,30 @@ const CopyButton: React.FC<CopyButtonProps & TextProps> = ({
|
|||||||
];
|
];
|
||||||
}, [intl]);
|
}, [intl]);
|
||||||
|
|
||||||
|
const onCopy = () => {
|
||||||
|
console.log('copied');
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Typography.Text
|
<Typography.Paragraph
|
||||||
style={{ ...btnStyle }}
|
style={{ ...btnStyle, marginBottom: 0 }}
|
||||||
{...rest}
|
{...rest}
|
||||||
copyable={{
|
copyable={{
|
||||||
text: text,
|
text: text,
|
||||||
format: format,
|
format: format,
|
||||||
tooltips: tooltips,
|
tooltips: tooltips,
|
||||||
|
onCopy: onCopy,
|
||||||
icon: [
|
icon: [
|
||||||
<CopyOutlined style={{ fontSize: fontSize, ...style }} key="copy" />,
|
<CopyOutlined style={{ fontSize: fontSize, ...style }} key="copy" />,
|
||||||
<CheckCircleFilled
|
<CheckCircleFilled
|
||||||
style={{ color: 'var(--ant-color-success)', fontSize: fontSize }}
|
style={{ color: 'var(--ant-color-success)', fontSize: fontSize }}
|
||||||
key="check"
|
key="copied"
|
||||||
/>
|
/>
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Typography.Text>
|
</Typography.Paragraph>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import { Title } from './constainers';
|
|||||||
import StepCollapse from './step-collapse';
|
import StepCollapse from './step-collapse';
|
||||||
|
|
||||||
const K8sRunCommand: React.FC<AddWorkerStepProps> = ({ disabled }) => {
|
const K8sRunCommand: React.FC<AddWorkerStepProps> = ({ disabled }) => {
|
||||||
const { registrationInfo, stepList } = useAddWorkerContext();
|
const { registrationInfo, stepList, summary } = useAddWorkerContext();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const stepIndex = stepList.indexOf(StepNamesMap.RunCommand) + 1;
|
const stepIndex = stepList.indexOf(StepNamesMap.RunCommand) + 1;
|
||||||
|
const currentGPU = summary.get('currentGPU') || '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StepCollapse
|
<StepCollapse
|
||||||
@@ -32,7 +33,10 @@ const K8sRunCommand: React.FC<AddWorkerStepProps> = ({ disabled }) => {
|
|||||||
id: 'clusters.create.addCommand.tips'
|
id: 'clusters.create.addCommand.tips'
|
||||||
})}
|
})}
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
<RegisterClusterInner registrationInfo={registrationInfo} />
|
<RegisterClusterInner
|
||||||
|
registrationInfo={registrationInfo}
|
||||||
|
currentGPU={currentGPU}
|
||||||
|
/>
|
||||||
</StepCollapse>
|
</StepCollapse>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import HighlightCode from '@/components/highlight-code';
|
import HighlightCode from '@/components/highlight-code';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { generateRegisterCommand } from '../config';
|
import { generateK8sRegisterCommand } from '../config';
|
||||||
|
|
||||||
type AddModalProps = {
|
type AddModalProps = {
|
||||||
|
currentGPU?: string;
|
||||||
registrationInfo: {
|
registrationInfo: {
|
||||||
token: string;
|
token: string;
|
||||||
image: string;
|
image: string;
|
||||||
@@ -10,14 +11,18 @@ type AddModalProps = {
|
|||||||
cluster_id: number | null;
|
cluster_id: number | null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const AddCluster: React.FC<AddModalProps> = ({ registrationInfo }) => {
|
const AddCluster: React.FC<AddModalProps> = ({
|
||||||
|
registrationInfo,
|
||||||
|
currentGPU
|
||||||
|
}) => {
|
||||||
const code = useMemo(() => {
|
const code = useMemo(() => {
|
||||||
return generateRegisterCommand({
|
return generateK8sRegisterCommand({
|
||||||
server: registrationInfo?.server_url || window.location.origin,
|
server: registrationInfo?.server_url || window.location.origin,
|
||||||
clusterId: registrationInfo?.cluster_id,
|
clusterId: registrationInfo?.cluster_id,
|
||||||
registrationToken: registrationInfo?.token
|
registrationToken: registrationInfo?.token,
|
||||||
|
currentGPU
|
||||||
});
|
});
|
||||||
}, [registrationInfo]);
|
}, [registrationInfo, currentGPU]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import icons from '@/components/icon-font/icons';
|
|||||||
import { StatusMaps } from '@/config';
|
import { StatusMaps } from '@/config';
|
||||||
import { GPUSTACK_API_BASE_URL } from '@/config/settings';
|
import { GPUSTACK_API_BASE_URL } from '@/config/settings';
|
||||||
import { StatusType } from '@/config/types';
|
import { StatusType } from '@/config/types';
|
||||||
|
import { GPUsConfigs } from '@/pages/resources/config/gpu-driver';
|
||||||
|
|
||||||
export const ClusterStatusValueMap = {
|
export const ClusterStatusValueMap = {
|
||||||
Provisioning: 'provisioning',
|
Provisioning: 'provisioning',
|
||||||
@@ -42,12 +43,14 @@ export const ProviderLabelMap = {
|
|||||||
[ProviderValueMap.Docker]: 'Docker'
|
[ProviderValueMap.Docker]: 'Docker'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generateRegisterCommand = (params: {
|
export const generateK8sRegisterCommand = (params: {
|
||||||
|
currentGPU?: string;
|
||||||
server: string;
|
server: string;
|
||||||
clusterId: number;
|
clusterId: number | null;
|
||||||
registrationToken: string;
|
registrationToken: string;
|
||||||
}) => {
|
}) => {
|
||||||
return `curl -k -L '${params.server}/${GPUSTACK_API_BASE_URL}/clusters/${params.clusterId}/manifests' \\
|
const runtime = GPUsConfigs[params.currentGPU || '']?.runtime || '';
|
||||||
|
return `curl -k -L '${params.server}/${GPUSTACK_API_BASE_URL}/clusters/${params.clusterId}/manifests${runtime ? `?runtime=${runtime}` : ''}' \\
|
||||||
--header 'Authorization: Bearer ${params.registrationToken}' | kubectl apply -f -`;
|
--header 'Authorization: Bearer ${params.registrationToken}' | kubectl apply -f -`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user