From 198a52e23004ba9aef6b3f899be3b6ec512a88ac Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 9 Feb 2026 15:54:54 +0800 Subject: [PATCH] chore: add runtime in register k8s command --- src/components/copy-button/index.tsx | 13 +++++++++---- .../components/add-worker/k8s-run-command.tsx | 8 ++++++-- .../components/register-cluster-inner.tsx | 15 ++++++++++----- src/pages/cluster-management/config/index.ts | 9 ++++++--- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/components/copy-button/index.tsx b/src/components/copy-button/index.tsx index 21ef2a3d..0ddabfa0 100644 --- a/src/components/copy-button/index.tsx +++ b/src/components/copy-button/index.tsx @@ -31,25 +31,30 @@ const CopyButton: React.FC = ({ ]; }, [intl]); + const onCopy = () => { + console.log('copied'); + }; + return ( - , ] }} > {children} - + ); }; diff --git a/src/pages/cluster-management/components/add-worker/k8s-run-command.tsx b/src/pages/cluster-management/components/add-worker/k8s-run-command.tsx index 18d4da9c..f6af580c 100644 --- a/src/pages/cluster-management/components/add-worker/k8s-run-command.tsx +++ b/src/pages/cluster-management/components/add-worker/k8s-run-command.tsx @@ -7,10 +7,11 @@ import { Title } from './constainers'; import StepCollapse from './step-collapse'; const K8sRunCommand: React.FC = ({ 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 ( = ({ disabled }) => { id: 'clusters.create.addCommand.tips' })} - + ); }; diff --git a/src/pages/cluster-management/components/register-cluster-inner.tsx b/src/pages/cluster-management/components/register-cluster-inner.tsx index 4a19bd26..0f8cf15f 100644 --- a/src/pages/cluster-management/components/register-cluster-inner.tsx +++ b/src/pages/cluster-management/components/register-cluster-inner.tsx @@ -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 = ({ registrationInfo }) => { +const AddCluster: React.FC = ({ + 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 (
diff --git a/src/pages/cluster-management/config/index.ts b/src/pages/cluster-management/config/index.ts index 6d2aeb67..542c4f6d 100644 --- a/src/pages/cluster-management/config/index.ts +++ b/src/pages/cluster-management/config/index.ts @@ -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 -`; };