|
|
|
@@ -263,7 +263,7 @@ public class ImageServiceImpl implements ImageService { |
|
|
|
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName); |
|
|
|
if (pod == null) { |
|
|
|
String podName = deploymentName+"-"+ DateUtils.formatYMD10(new Date()); |
|
|
|
pod = createPod(serviceNS, podName); |
|
|
|
pod = k8sClientUtil.createPodWithEnv(podName,serviceNS,proxyUrl,mountPath,pvcName,image); |
|
|
|
} |
|
|
|
String loginCmd = "docker login -u " + harborUser +" -p "+harborpassword+" "+harborUrl; |
|
|
|
// 执行命令 docker login -u admin -p Harbor12345 172.20.32.187 |
|
|
|
@@ -274,9 +274,9 @@ public class ImageServiceImpl implements ImageService { |
|
|
|
String logs2 = k8sClientUtil.executeCommand(pod,"docker pull "+ netPath); |
|
|
|
// 在容器里执行 docker tag name:tag nexus3.kube-system.svc:8083/imageName:imageTag |
|
|
|
if (StringUtils.isNoneBlank(logs2)){ |
|
|
|
String substring = logs2.substring(logs2.lastIndexOf(harborUrl)); |
|
|
|
String cleanedString = substring.replaceAll("(\\r|\\n)", ""); |
|
|
|
String tagCmd = "docker tag " + cleanedString + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag; |
|
|
|
String[] lines = logs2.split("\n"); |
|
|
|
String lastLine = lines[lines.length - 1].trim(); |
|
|
|
String tagCmd = "docker tag " + lastLine + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag; |
|
|
|
String imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag; |
|
|
|
String pushCmd = "docker push " + imageUrl; |
|
|
|
String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl; |
|
|
|
@@ -305,7 +305,7 @@ public class ImageServiceImpl implements ImageService { |
|
|
|
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName); |
|
|
|
if (pod == null) { |
|
|
|
String podName = deploymentName+"-"+ DateUtils.formatYMD10(new Date()); |
|
|
|
pod = createPod(serviceNS, podName); |
|
|
|
pod = k8sClientUtil.createPodWithEnv(podName,serviceNS,proxyUrl,mountPath,pvcName,image); |
|
|
|
} |
|
|
|
String loginCmd = "docker login -u " + harborUser +" -p "+harborpassword+" "+harborUrl; |
|
|
|
// 执行命令 docker login -u admin -p Harbor12345 172.20.32.187 |
|
|
|
@@ -346,8 +346,4 @@ public class ImageServiceImpl implements ImageService { |
|
|
|
String path = loginUser.getUsername()+"/"+file.getOriginalFilename(); |
|
|
|
return minioService.uploadFile(bucketName, path, file); |
|
|
|
} |
|
|
|
|
|
|
|
private V1Pod createPod(String namespace, String podName){ |
|
|
|
return k8sClientUtil.createPodWithEnv(podName,namespace,proxyUrl,mountPath,pvcName,image); |
|
|
|
} |
|
|
|
} |