Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k8s dto 수정 #29

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/main/java/kr/co/mcmp/api/manifest/YamlManifestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,40 @@ public class YamlManifestController {
@Operation(summary = "Deployments Yaml 생성")
@PostMapping("/yaml/deployments")
public ResponseEntity<ResponseWrapper<String>> generateYamlDeployments(
@RequestBody K8SDeploymentsDto deployments) {
manifestService.generateYamlDeployments(deployments);
return ResponseEntity.ok(new ResponseWrapper<>("Deployments Yaml Generated Successfully"));
@RequestBody K8SDeploymentDto deployments) {
String yaml = manifestService.generateYamlDeployments(deployments);
return ResponseEntity.ok(new ResponseWrapper<>(yaml));
}

@Operation(summary = "Service Yaml 생성")
@PostMapping("/yaml/service")
public ResponseEntity<ResponseWrapper<String>> generateYamlService(
@RequestBody K8SServiceDto service) {
manifestService.generateYamlService(service);
return ResponseEntity.ok(new ResponseWrapper<>("Service Yaml Generated Successfully"));
String yaml = manifestService.generateYamlService(service);
return ResponseEntity.ok(new ResponseWrapper<>(yaml));
}

@Operation(summary = "ConfigMap Yaml 생성")
@PostMapping("/yaml/configmap")
public ResponseEntity<ResponseWrapper<String>> generateYamlConfigMap(
@RequestBody K8SConfigMapDto configMap) {
manifestService.generateYamlConfigMap(configMap);
return ResponseEntity.ok(new ResponseWrapper<>("ConfigMap Yaml Generated Successfully"));
String yaml = manifestService.generateYamlConfigMap(configMap);
return ResponseEntity.ok(new ResponseWrapper<>(yaml));
}

@Operation(summary = "Pod Yaml 생성")
@PostMapping("/yaml/pod")
public ResponseEntity<ResponseWrapper<String>> generateYamlPod(
@RequestBody K8SPodDto pod) {
manifestService.generateYamlPod(pod);
return ResponseEntity.ok(new ResponseWrapper<>("Pod Yaml Generated Successfully"));
String yaml = manifestService.generateYamlPod(pod);
return ResponseEntity.ok(new ResponseWrapper<>(yaml));
}

@Operation(summary = "Hpa Yaml 생성")
@PostMapping("/yaml/hpa")
public ResponseEntity<ResponseWrapper<String>> generateYamlHpa(
@RequestBody K8SHpaDto hpa) {
manifestService.generateYamlHpa(hpa);
return ResponseEntity.ok(new ResponseWrapper<>("Hpa Yaml Generated Successfully"));
String yaml = manifestService.generateYamlHpa(hpa);
return ResponseEntity.ok(new ResponseWrapper<>(yaml));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class YamlManifestService {
private final ObjectMapper mapper = new ObjectMapper(new YAMLFactory())
.setSerializationInclusion(JsonInclude.Include.NON_NULL);

public String generateYamlDeployments(K8SDeploymentsDto deployments) {
public String generateYamlDeployments(K8SDeploymentDto deployments) {
return generateYaml(deployments);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class K8SConfigMapDto {

private final String apiVersion = "v1";
private final String kind = "ConfigMap";
private MetadataDto metadata;
private ConfigMapMetadataDto metadata;
private Map<String, String> data = null;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class MetadataDto {
public static class ConfigMapMetadataDto {
private String name;
private String namespace;
private Map<String, String> labels = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class K8SDeploymentsDto {
public class K8SDeploymentDto {

private final String apiVersion = "apps/v1";
private final String kind = "Deployment";
private MetadataDto metadata;
private SpecDto spec;
private DeploymentMetadataDto metadata;
private DeploymentSpecDto spec;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class MetadataDto {
public static class DeploymentMetadataDto {
private String name;
private String namespace;
private Map<String, String> labels = null;
Expand All @@ -33,49 +33,49 @@ public static class MetadataDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class SpecDto {
public static class DeploymentSpecDto {
private Integer replicas;
private SelectorDto selector;
private TemplateDto template;
private DeploymentSelectorDto selector;
private DeploymentTemplateDto template;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class SelectorDto {
public static class DeploymentSelectorDto {
private Map<String, String> matchLabels = null;
}

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class TemplateDto {
private MetadataDto metadata;
private PodSpecDto spec;
public static class DeploymentTemplateDto {
private DeploymentMetadataDto metadata;
private DeploymentPodSpecDto spec;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class PodSpecDto {
private List<ContainerDto> containers = null;
public static class DeploymentPodSpecDto {
private List<DeploymentPodContainerDto> containers = null;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ContainerDto {
public static class DeploymentPodContainerDto {
private String name;
private String image;
private List<EnvDto> env = null;
private List<PortDto> ports = null;
private List<DeploymentPodEnvDto> env = null;
private List<DeploymentPodPortDto> ports = null;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class EnvDto {
public static class DeploymentPodEnvDto {
private String name;
private String value;
}
Expand All @@ -84,7 +84,7 @@ public static class EnvDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class PortDto {
public static class DeploymentPodPortDto {
private Integer containerPort;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/kr/co/mcmp/api/manifest/k8s/K8SHpaDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class K8SHpaDto {

private final String apiVersion = "autoscaling/v1";
private final String kind = "HorizontalPodAutoscaler";
private MetadataDto metadata;
private SpecDto spec;
private HpaMetadataDto metadata;
private HpaSpecDto spec;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class MetadataDto {
public static class HpaMetadataDto {
private String name;
private String namespace;
private Map<String, String> labels = null;
Expand All @@ -32,8 +32,8 @@ public static class MetadataDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class SpecDto {
private ScaleTargetRefDto scaleTargetRef;
public static class HpaSpecDto {
private HpaScaleTargetRefDto scaleTargetRef;
private Integer minReplicas;
private Integer maxReplicas;
private Integer targetCPUUtilizationPercentage;
Expand All @@ -42,7 +42,7 @@ public static class SpecDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ScaleTargetRefDto {
public static class HpaScaleTargetRefDto {
private String apiVersion;
private String kind;
private String name;
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/kr/co/mcmp/api/manifest/k8s/K8SPodDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class K8SPodDto {

private final String apiVersion = "v1";
private final String kind = "Pod";
private MetadataDto metadata;
private SpecDto spec;
private PodMetadataDto metadata;
private PodSpecDto spec;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class MetadataDto {
public static class PodMetadataDto {
private String name;
private String namespace;
private Map<String, String> labels = null;
Expand All @@ -33,26 +33,26 @@ public static class MetadataDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class SpecDto {
private List<ContainerDto> containers = null;
public static class PodSpecDto {
private List<PodContainerDto> containers = null;
private String restartPolicy;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ContainerDto {
public static class PodContainerDto {
private String name;
private String image;
private List<EnvDto> env = null;
private List<PortDto> ports = null;
private ResourceDto resources;
private List<PodEnvDto> env = null;
private List<PodPortDto> ports = null;
private PodResourceDto resources;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class EnvDto {
public static class PodEnvDto {
private String name;
private String value;
}
Expand All @@ -61,7 +61,7 @@ public static class EnvDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class PortDto {
public static class PodPortDto {
private String name;
private Integer containerPort;
private Integer hostPort;
Expand All @@ -72,7 +72,7 @@ public static class PortDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ResourceDto {
public static class PodResourceDto {
private Map<String, String> limits = null;
private Map<String, String> requests = null;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/kr/co/mcmp/api/manifest/k8s/K8SServiceDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class K8SServiceDto {

private final String apiVersion = "v1";
private final String kind = "Service";
private MetadataDto metadata;
private SpecDto spec;
private ServiceMetadataDto metadata;
private ServiceSpecDto spec;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class MetadataDto {
public static class ServiceMetadataDto {
private String name;
private String namespace;
private Map<String, String> labels = null;
Expand All @@ -33,16 +33,16 @@ public static class MetadataDto {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class SpecDto {
public static class ServiceSpecDto {
private Map<String, String> selector = null;
private List<PortsDto> ports = null;
private List<ServicePortsDto> ports = null;
private String type;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class PortsDto {
public static class ServicePortsDto {
private String protocol;
private Integer port;
private Integer targetPort;
Expand Down