Browse Source

1、修改文件上传路径

2、修改pod挂载方式为hostpath
dev-restore_mount
chenzhihang 1 year ago
parent
commit
05f1a9880d
5 changed files with 30 additions and 10 deletions
  1. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/GitService.java
  2. +1
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java
  3. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
  4. +5
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MinioServiceImpl.java
  5. +20
    -5
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java

+ 2
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/GitService.java View File

@@ -10,6 +10,8 @@ public interface GitService {
//登录方法,返回token //登录方法,返回token
String login(String username, String password); String login(String username, String password);


String checkoutToken();

//输入token,项目名,tag,创建新项目,返回项目地址 //输入token,项目名,tag,创建新项目,返回项目地址
Map createProject(GitProjectVo gitProjectVo) throws Exception; Map createProject(GitProjectVo gitProjectVo) throws Exception;




+ 1
- 3
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java View File

@@ -165,9 +165,7 @@ public class DatasetVersionServiceImpl implements DatasetVersionService {
.findFirst() .findFirst()
.ifPresent(datasetVersion -> { .ifPresent(datasetVersion -> {
String url = datasetVersion.getUrl(); String url = datasetVersion.getUrl();
String path = bucketName + '/' + url.substring(0, url.lastIndexOf('/'));
response.put("path", path);

response.put("path", url);
}); });


response.put("content", datasetVersionList); response.put("content", datasetVersionList);


+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java View File

@@ -61,7 +61,7 @@ public class ImageServiceImpl implements ImageService {


@Resource @Resource
private MinioService minioService; private MinioService minioService;
@Value("${harbor.bucketName}")
@Value("${minio.dataReleaseBucketName}")
private String bucketName; private String bucketName;
@Value("${harbor.repository}") @Value("${harbor.repository}")
private String repository; private String repository;
@@ -362,7 +362,7 @@ public class ImageServiceImpl implements ImageService {
@Override @Override
public Map<String, String> uploadImageFiles(MultipartFile file) throws Exception { public Map<String, String> uploadImageFiles(MultipartFile file) throws Exception {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String path = loginUser.getUsername() + "/" + file.getOriginalFilename();
String path = "images/" + loginUser.getUsername() + "/" + file.getOriginalFilename();
return minioService.uploadFile(bucketName, path, file); return minioService.uploadFile(bucketName, path, file);
} }




+ 5
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MinioServiceImpl.java View File

@@ -4,6 +4,7 @@ import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.service.MinioService; import com.ruoyi.platform.service.MinioService;
import com.ruoyi.platform.utils.FileUtil; import com.ruoyi.platform.utils.FileUtil;
import com.ruoyi.platform.utils.MinioUtil; import com.ruoyi.platform.utils.MinioUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -25,6 +26,9 @@ import java.util.Map;
@Service("MinioService") @Service("MinioService")
public class MinioServiceImpl implements MinioService { public class MinioServiceImpl implements MinioService {


@Value("${jupyter.hostPath}")
private String hostPath;

private final MinioUtil minioUtil; private final MinioUtil minioUtil;


public MinioServiceImpl(MinioUtil minioUtil) { public MinioServiceImpl(MinioUtil minioUtil) {
@@ -62,6 +66,7 @@ public class MinioServiceImpl implements MinioService {
try (InputStream inputStream = file.getInputStream()){ try (InputStream inputStream = file.getInputStream()){
minioUtil.uploadObject(bucketName, objectName, inputStream); minioUtil.uploadObject(bucketName, objectName, inputStream);
result.put("fileName", file.getOriginalFilename()); result.put("fileName", file.getOriginalFilename());
objectName = hostPath + "/" + objectName;
result.put("url", objectName); // objectName根据实际情况定义 result.put("url", objectName); // objectName根据实际情况定义
result.put("fileSize", formattedSize); result.put("fileSize", formattedSize);
} catch (Exception e) { } catch (Exception e) {


+ 20
- 5
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java View File

@@ -33,6 +33,10 @@ import java.util.*;
@Slf4j @Slf4j
@Component @Component
public class K8sClientUtil { public class K8sClientUtil {

@Value("${jupyter.hostPath}")
private String hostPath;

private String http; private String http;
private String token; private String token;
/** /**
@@ -446,13 +450,24 @@ public class K8sClientUtil {


// 配置卷和卷挂载 // 配置卷和卷挂载
List<V1VolumeMount> volumeMounts = new ArrayList<>(); List<V1VolumeMount> volumeMounts = new ArrayList<>();
volumeMounts.add(new V1VolumeMount().name("workspace").mountPath(mountPath));
volumeMounts.add(new V1VolumeMount().name("minio-pvc").mountPath("/opt/data").subPath(datasetPath).readOnly(true));
volumeMounts.add(new V1VolumeMount().name("minio-pvc").mountPath("/opt/model").subPath(modelPath).readOnly(true));
volumeMounts.add(new V1VolumeMount().name("workspace").mountPath("/opt/notebooks"));
volumeMounts.add(new V1VolumeMount().name("dataset").mountPath("/opt/dataset").readOnly(true));
volumeMounts.add(new V1VolumeMount().name("model").mountPath("/opt/model").readOnly(true));


List<V1Volume> volumes = new ArrayList<>(); List<V1Volume> volumes = new ArrayList<>();
volumes.add(new V1Volume().name("workspace").persistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName(pvc.getMetadata().getName())));
volumes.add(new V1Volume().name("minio-pvc").persistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName(dataPvcName)));
volumes.add(new V1Volume().name("workspace").hostPath(new V1HostPathVolumeSource().path(hostPath + "/notebooks").type("DirectoryOrCreate")));
volumes.add(new V1Volume().name("dataset").hostPath(new V1HostPathVolumeSource().path(hostPath + "/dataset").type("DirectoryOrCreate")));
volumes.add(new V1Volume().name("model").hostPath(new V1HostPathVolumeSource().path(hostPath + "/model").type("DirectoryOrCreate")));

// 配置卷和卷挂载
// List<V1VolumeMount> volumeMounts = new ArrayList<>();
// volumeMounts.add(new V1VolumeMount().name("workspace").mountPath(mountPath));
// volumeMounts.add(new V1VolumeMount().name("minio-pvc").mountPath("/opt/data").subPath(datasetPath).readOnly(true));
// volumeMounts.add(new V1VolumeMount().name("minio-pvc").mountPath("/opt/model").subPath(modelPath).readOnly(true));
//
// List<V1Volume> volumes = new ArrayList<>();
// volumes.add(new V1Volume().name("workspace").persistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName(pvc.getMetadata().getName())));
// volumes.add(new V1Volume().name("minio-pvc").persistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName(dataPvcName)));




//配置资源 //配置资源


Loading…
Cancel
Save