From eabdb3e147436868f3e5fa15ec322d096d6391ed Mon Sep 17 00:00:00 2001 From: pbccc Date: Fri, 30 Aug 2024 16:47:50 +0900 Subject: [PATCH] yaml generate editing~(temp) --- .../mcmp/manifest/K8SDeployYamlGenerator.java | 19 +++++++++- .../java/kr/co/mcmp/manifest/K8SPodDTO.java | 35 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/main/java/kr/co/mcmp/manifest/K8SDeployYamlGenerator.java b/src/main/java/kr/co/mcmp/manifest/K8SDeployYamlGenerator.java index 53298a7..ed58a77 100644 --- a/src/main/java/kr/co/mcmp/manifest/K8SDeployYamlGenerator.java +++ b/src/main/java/kr/co/mcmp/manifest/K8SDeployYamlGenerator.java @@ -41,7 +41,24 @@ private V1Pod getPod(K8SPodDTO podDto) { private V1PodSpec getPodSpec(K8SPodDTO podDto){ V1PodSpec podSpec = new V1PodSpec(); - List containerList = podDto.getContainers(); + List containerList = new ArrayList<>(); //podDto.getContainers(); + for(K8SPodDTO.Container cont: podDto.getContainers()){ + V1Container container = new V1Container(); + container.setName(cont.getContainerName()); + container.setImage(cont.getContainerImage()); + List portList = new ArrayList<>(); + for(K8SPodDTO.Port pt: cont.getPorts()) { + V1ContainerPort port = new V1ContainerPort(); + port.setProtocol(pt.getProtocol()); + port.setProtocol(pt.getName()); + port.setContainerPort(pt.getContainerPort()); + portList.add(port); + } + //V1ResourceRequirements resourceReq = new V1ResourceRequirements(); + //resourceReq.setLimits(); + container.setPorts(portList); + containerList.add(container); + } podSpec.setContainers(containerList); podSpec.setRestartPolicy(podDto.getRestartPolicy()); return podSpec; diff --git a/src/main/java/kr/co/mcmp/manifest/K8SPodDTO.java b/src/main/java/kr/co/mcmp/manifest/K8SPodDTO.java index 3fc0531..c1c9b48 100644 --- a/src/main/java/kr/co/mcmp/manifest/K8SPodDTO.java +++ b/src/main/java/kr/co/mcmp/manifest/K8SPodDTO.java @@ -16,7 +16,40 @@ public class K8SPodDTO { public String podName; public String namespace; - public List containers; + //public List containers; + + public List containers; + + @Getter + @Setter + public class Container{ + public String containerImage; + public String containerName; + public List ports; + //public Resource resource; + + } + + @Getter + @Setter + public class Port{ + public int containerPort; + public int hostPort; + public String name; + public String protocol; + } + + @Getter + @Setter + public class Resource{ + public String limitCpu; + public String LimitMemory; + public String reqCpu; + public String reqMemory; + } + + + public Map labels; public String restartPolicy;