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