diff --git a/frontend/providers/dbprovider/.env.template b/frontend/providers/dbprovider/.env.template index ce10fedef..7af6123b1 100644 --- a/frontend/providers/dbprovider/.env.template +++ b/frontend/providers/dbprovider/.env.template @@ -4,6 +4,9 @@ FASTGPT_KEY= STORAGE_CLASSNAME=choosable MONITOR_URL="" -MINIO_URL="" -MINIO_ACCESS_KEY="" -MINIO_SECRET_KEY="" \ No newline at end of file +MINIO_URL= +MINIO_ACCESS_KEY= +MINIO_SECRET_KEY= +MINIO_PORT= +MIGRATE_FILE_IMAGE= +MINIO_BUCKET_NAME= \ No newline at end of file diff --git a/frontend/providers/dbprovider/deploy/Kubefile b/frontend/providers/dbprovider/deploy/Kubefile index cd85b1092..d7e06cb05 100644 --- a/frontend/providers/dbprovider/deploy/Kubefile +++ b/frontend/providers/dbprovider/deploy/Kubefile @@ -9,6 +9,11 @@ ENV cloudDomain="127.0.0.1.nip.io" ENV cloudPort="" ENV certSecretName="wildcard-cert" ENV monitorUrl="" - +ENV minioUrl="" +ENV minioAccessKey="" +ENV minioSecretKey="" +ENV minioPort="" +ENV migrateFileImage="" +ENV minioBucketName="" CMD ["kubectl apply -f manifests"] diff --git a/frontend/providers/dbprovider/deploy/manifests/deploy.yaml.tmpl b/frontend/providers/dbprovider/deploy/manifests/deploy.yaml.tmpl index ba85f0ac6..54d734456 100644 --- a/frontend/providers/dbprovider/deploy/manifests/deploy.yaml.tmpl +++ b/frontend/providers/dbprovider/deploy/manifests/deploy.yaml.tmpl @@ -44,6 +44,16 @@ spec: value: "{{ if .cloudPort }}:{{ .cloudPort }}{{ end }}" - name: MONITOR_URL value: {{ .monitorUrl }} + - name: MINIO_ACCESS_KEY + value: {{ .minioAccessKey }} + - name: MINIO_SECRET_KEY + value: {{ .minioSecretKey }} + - name: MIGRATE_FILE_IMAGE + value: {{ .migrateFileImage }} + - name: MINIO_PORT + value: {{ .minioPort }} + - name: MINIO_BUCKET_NAME + value: {{ .minioBucketName }} securityContext: runAsNonRoot: true runAsUser: 1001 diff --git a/frontend/providers/dbprovider/src/pages/api/getEnv.ts b/frontend/providers/dbprovider/src/pages/api/getEnv.ts index 447bcc0d3..a53bb5f82 100644 --- a/frontend/providers/dbprovider/src/pages/api/getEnv.ts +++ b/frontend/providers/dbprovider/src/pages/api/getEnv.ts @@ -6,6 +6,7 @@ export type Response = { domain: string; env_storage_className: string; migrate_file_image: string; + minio_url: string; }; export default async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -13,7 +14,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< data: { domain: process.env.SEALOS_DOMAIN || 'cloud.sealos.io', env_storage_className: process.env.STORAGE_CLASSNAME || 'openebs-backup', - migrate_file_image: process.env.MIGRATE_FILE_IMAGE || 'ghcr.io/wallyxjh/test:7.1' + migrate_file_image: process.env.MIGRATE_FILE_IMAGE || 'ghcr.io/wallyxjh/test:7.1', + minio_url: process.env.MINIO_URL || '' } }); } diff --git a/frontend/providers/dbprovider/src/pages/api/minio/upload.ts b/frontend/providers/dbprovider/src/pages/api/minio/upload.ts index 4410b90ff..caf351b91 100644 --- a/frontend/providers/dbprovider/src/pages/api/minio/upload.ts +++ b/frontend/providers/dbprovider/src/pages/api/minio/upload.ts @@ -65,7 +65,7 @@ const upload = new UploadModel(); const minioClient = new Minio.Client({ endPoint: process.env?.MINIO_URL || 'minioapi.dev.sealos.top', - port: 80, + port: Number(process.env?.MINIO_PORT) || 80, useSSL: false, accessKey: process.env?.MINIO_ACCESS_KEY || 'database', secretKey: process.env?.MINIO_SECRET_KEY || 'database' @@ -84,26 +84,20 @@ export default async function handler(req: any, res: NextApiResponse) { kubeconfig: await authSession(req) }); const { files } = await upload.doUpload(req, res); - console.log(files, '===files==='); - const bucketName = process.env?.BUCKET_NAME || 'database-test'; + const bucketName = process.env?.MINIO_BUCKET_NAME || 'database-test'; const startTime = performance.now(); const upLoadResults = await Promise.all( files.map(async (file) => { const fileName = `${namespace}-${Date.now()}-${file.filename}`; - return minioClient - .fPutObject(bucketName, fileName, file.path) - .then((res) => { - return fileName; - }) - .catch((err) => { - return null; - }); + await minioClient.fPutObject(bucketName, fileName, file.path); + return fileName; }) ); const endTime = performance.now(); const duration = endTime - startTime; - console.log(`代码块运行时间:${duration} 毫秒`); + console.log(upLoadResults); + console.log(`file:${files} time:${duration}`); jsonRes(res, { data: upLoadResults diff --git a/frontend/providers/dbprovider/src/utils/json2Yaml.ts b/frontend/providers/dbprovider/src/utils/json2Yaml.ts index 71abb0bbb..25207389b 100644 --- a/frontend/providers/dbprovider/src/utils/json2Yaml.ts +++ b/frontend/providers/dbprovider/src/utils/json2Yaml.ts @@ -947,6 +947,10 @@ export const json2DumpCR = async (data: DumpForm) => { name: `${userNS}-${time}-${data.dbName}-file`, image: systemEnvs?.migrate_file_image, env: [ + { + name: 'MINIO_URL', + value: `https://${systemEnvs?.minio_url}` + }, { name: 'DATABASE_USER', value: data.databaseUser