feat:db modify deployment env (#4345)

Signed-off-by: jingyang <3161362058@qq.com>
This commit is contained in:
zhujingyang
2023-11-27 11:38:46 +08:00
committed by GitHub
parent d2e6d78b4f
commit 9bb66ebdfc
6 changed files with 35 additions and 17 deletions
+6 -3
View File
@@ -4,6 +4,9 @@ FASTGPT_KEY=
STORAGE_CLASSNAME=choosable
MONITOR_URL=""
MINIO_URL=""
MINIO_ACCESS_KEY=""
MINIO_SECRET_KEY=""
MINIO_URL=
MINIO_ACCESS_KEY=
MINIO_SECRET_KEY=
MINIO_PORT=
MIGRATE_FILE_IMAGE=
MINIO_BUCKET_NAME=
@@ -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"]
@@ -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
@@ -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<ApiResp>) {
@@ -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 || ''
}
});
}
@@ -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
@@ -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