Skip to content

Commit

Permalink
Merge pull request #90 from hyun357123/main
Browse files Browse the repository at this point in the history
update docker-compose
  • Loading branch information
hyun357123 authored Nov 6, 2024
2 parents 57be4ba + 42ba190 commit 5cddc19
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 33 deletions.
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ services:
- DB_USER=application # Please CHANGE ME
- DB_PASS=application!23 # Please CHANGE ME
- SQL_DATA_INIT=always # or never
- TUMBLEBUG_URL=http://mc-infra-manager
- TUMBLEBUG_PORT=1323
- TUMBLEBUG_ID=default
- TUMBLEBUG_PASSWORD=default
healthcheck: # for cb-application-manager
test: ["CMD", "nc", "-vz", "localhost", "1324"]
interval: 1m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ private HttpHeaders createCommonHeaders() {
}

private String createApiUrl(String endpoint) {
return String.format("http://%s:%s%s", cbtumblebugUrl, cbtumblebugPort, endpoint);
String apiUrl = String.format("http://%s:%s%s", cbtumblebugUrl, cbtumblebugPort, endpoint);
log.info("apiUrl : {}", apiUrl);
return apiUrl;
}

public boolean checkTumblebug() {
Expand Down
28 changes: 26 additions & 2 deletions src/main/java/kr/co/mcmp/ape/dto/reqDto/JenkinsJobDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,29 @@ public static class HelmChartInstall extends JenkinsJobDto {
@Schema(description = "K8s 클러스터 이름", example = "cluster01", required = true)
private String clusterName;

@Schema(description = "설치할 Helm 차트 목록", example = "[\"nginx\", \"grafana\"]")
@Schema(description = "설치할 Helm 차트 목록", example = "[\"nginx\"]")
private List<String> helmCharts;
// @Schema(description = "설치할 Helm 차트", example = "nginx")
// private String helmCharts;
private String version;


@Schema(description = "HPA(Horizontal Pod AutoScaler) 활성화 여부", example = "false")
private boolean enableHpa;

@Schema(description = "HPA 최소 레플리카 수", example = "1", minimum = "1")
private int hpaMinReplicas;

@Schema(description = "HPA 최대 레플리카 수", example = "10", minimum = "1")
private int hpaMaxReplicas;

@Schema(description = "HPA CPU 사용률 목표 (퍼센트)", example = "80", minimum = "1", maximum = "100")
private int hpaCpuUtilization;

@Schema(description = "HPA 메모리 사용률 목표 (퍼센트)", example = "80", minimum = "1", maximum = "100")
private int hpaMemoryUtilization;



@Override
@JsonIgnore
Expand All @@ -124,6 +142,11 @@ public Map<String, List<String>> convertToSpecificParams() {
Map<String, List<String>> params = new HashMap<>();
params.put("CLUSTERNAME", List.of(this.clusterName));
params.put("HELM_CHARTS", List.of(String.join(",", this.helmCharts)));
params.put("ENABLE_HPA", List.of(String.valueOf(this.enableHpa)));
params.put("HPA_MIN_REPLICAS", List.of(String.valueOf(this.hpaMinReplicas)));
params.put("HPA_MAX_REPLICAS", List.of(String.valueOf(this.hpaMaxReplicas)));
params.put("HPA_CPU_UTILIZATION", List.of(String.valueOf(this.hpaCpuUtilization)));
params.put("HPA_MEMORY_UTILIZATION", List.of(String.valueOf(this.hpaMemoryUtilization)));
// params.put("HELM_CHARTS", List.of(this.helmCharts));
return params;
}
Expand All @@ -136,11 +159,12 @@ public static class HelmChartUninstall extends JenkinsJobDto {
@Schema(description = "K8s 클러스터 이름", example = "cluster01", required = true)
private String clusterName;

@Schema(description = "제거할 Helm 차트 목록", example = "[\"nginx\", \"grafana\"]")
@Schema(description = "제거할 Helm 차트 목록", example = "[\"nginx\"]")
private List<String> helmCharts;
// @Schema(description = "제거할 Helm 차트 목록", example = "nginx")
// private String helmCharts;


private String version;

@Override
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/kr/co/mcmp/catalog/CatalogDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import java.util.List;

import javax.persistence.Column;

import kr.co.mcmp.catalog.Ref.CatalogRefDTO;

@Getter
Expand All @@ -21,9 +23,15 @@ public class CatalogDTO {
private String catalogCategory;
private List<CatalogRefDTO> catalogRefData;

private int recommendedCpu;
private int recommendedMemory;
private int recommendedDisk;
private Integer recommendedCpu;
private Integer recommendedMemory;
private Integer recommendedDisk;

private Boolean enableHpa;
private Integer hpaMinReplicas;
private Integer hpaMaxReplicas;
private Integer hpaCpuUtilization;
private Integer hpaMemoryUtilization;

public CatalogDTO(CatalogEntity cEntity){
if(cEntity.getId() != null){ this.catalogIdx = cEntity.getId(); }
Expand All @@ -35,6 +43,11 @@ public CatalogDTO(CatalogEntity cEntity){
this.recommendedCpu = cEntity.getRecommendedCpu();
this.recommendedMemory = cEntity.getRecommendedMemory();
this.recommendedDisk = cEntity.getRecommendedDisk();
this.enableHpa = cEntity.getEnableHpa();
this.hpaMinReplicas = cEntity.getHpaMinReplicas();
this.hpaMaxReplicas = cEntity.getHpaMaxReplicas();
this.hpaCpuUtilization = cEntity.getHpaCpuUtilization();
this.hpaMemoryUtilization = cEntity.getHpaMemoryUtilization();
}


Expand Down
32 changes: 26 additions & 6 deletions src/main/java/kr/co/mcmp/catalog/CatalogEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,29 @@ public class CatalogEntity {
@Column(columnDefinition="VARCHAR(15) NOT NULL DEFAULT ''", name="CATEGORY")
private String category;

@Column(name = "RECOMMENDED_CPU", nullable = false)
private int recommendedCpu;
@Column(columnDefinition="INT", name = "RECOMMENDED_CPU", nullable = false)
private Integer recommendedCpu;

@Column(name = "RECOMMENDED_MEMORY", nullable = false)
private int recommendedMemory;
@Column(columnDefinition="INT", name = "RECOMMENDED_MEMORY", nullable = false)
private Integer recommendedMemory;

@Column(name = "RECOMMENDED_DISK", nullable = false)
private int recommendedDisk;
@Column(columnDefinition="INT", name = "RECOMMENDED_DISK", nullable = false)
private Integer recommendedDisk;

@Column(columnDefinition="BOOLEAN", name = "ENABLE_HPA", nullable = false)
private Boolean enableHpa;

@Column(columnDefinition="INT", name="HPA_MIN_REPLICAS", nullable = true)
private Integer hpaMinReplicas;

@Column(columnDefinition="INT", name="HPA_MAX_REPLICAS", nullable = true)
private Integer hpaMaxReplicas;

@Column(columnDefinition="INT", name="HPA_CPU_UTILIZATION", nullable = true)
private Integer hpaCpuUtilization;

@Column(columnDefinition="INT", name="HPA_MEMORY_UTILIZATION", nullable = true)
private Integer hpaMemoryUtilization;

public CatalogEntity(CatalogDTO cDto){
if(cDto.getCatalogIdx() != null) { this.id = cDto.getCatalogIdx(); }
Expand All @@ -59,6 +74,11 @@ public CatalogEntity(CatalogDTO cDto){
this.recommendedCpu = cDto.getRecommendedCpu();
this.recommendedMemory = cDto.getRecommendedMemory();
this.recommendedDisk = cDto.getRecommendedDisk();
this.enableHpa = cDto.getEnableHpa();
this.hpaMinReplicas = cDto.getHpaMinReplicas();
this.hpaMaxReplicas = cDto.getHpaMaxReplicas();
this.hpaCpuUtilization = cDto.getHpaCpuUtilization();
this.hpaMemoryUtilization = cDto.getHpaMemoryUtilization();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ public class K8sApplicationHistory {
@Column(name = "status", nullable = false)
private ApplicationStatus status;

@Column(name = "hpa_enabled", nullable = false)
private boolean hpaEnabled;

@Column(name = "hpa_min_replicas", nullable = true)
private Integer hpaMinReplicas;

@Column(name = "hpa_max_replicas", nullable = true)
private Integer hpaMaxReplicas;

@Column(name = "hpa_target_cpu_utilization_percentage", nullable = true)
private Integer hpaTargetCpuUtilizationPercentage;

@Column(name = "hpa_target_memory_utilization_percentage", nullable = true)
private Integer hpaTargetMemoryUtilizationPercentage;

@Column(name = "installed_at")
private LocalDateTime installedAt;
@Column(name = "uninstalled_at")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ private K8sApplicationHistory createK8sApplicationHistory(JenkinsJobDto.HelmChar
.clusterName(jobDto.getClusterName())
.catalog(new CatalogEntity(catalogDto))
.status(status)
.hpaEnabled(jobDto.isEnableHpa())
.hpaMaxReplicas(jobDto.isEnableHpa() ? jobDto.getHpaMaxReplicas() : null)
.hpaMinReplicas(jobDto.isEnableHpa() ? jobDto.getHpaMinReplicas() : null)
.hpaTargetCpuUtilizationPercentage(jobDto.isEnableHpa() ? jobDto.getHpaCpuUtilization() : null)
.hpaTargetMemoryUtilizationPercentage(jobDto.isEnableHpa() ? jobDto.getHpaMemoryUtilization() : null)
.installedAt(LocalDateTime.now())
.build();
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spring:
defer-datasopurce-initalization: true
generate-ddl: true
hibernate:
ddl-auto: ${DDL_AUTO:update} # ${DDL_AUTO:none}
ddl-auto: ${DDL_AUTO:create-drop} # ${DDL_AUTO:none}
# ddl-auto: create # 실행할 때에 테이블을 자동으로 생성시킬것인지 #create-drop, update, validate, none
# create : SessionFactory 시작시 스키마를 삭제하고 다시 생성
# create-drop : SessionFactory 종료 시 스키마를 삭제
Expand All @@ -49,7 +49,7 @@ spring:
sql:
init:
data-locations: classpath:./import.sql
mode: ${SQL_DATA_INIT:never} #${SQL_DATA_INIT:always} # ${SQL_DATA_INIT:never}
mode: ${SQL_DATA_INIT:always} #${SQL_DATA_INIT:always} # ${SQL_DATA_INIT:never}
platform: h2
#schema-locations: classpath:ddl.sql

Expand All @@ -65,10 +65,10 @@ aes:
key: fb1755281b0ca6184a0ee644e6477ee7

cbtumblebug:
url: 13.124.226.58
port: 1323
id: default
pass: default
url: ${TUMBLEBUG_URL}
port: ${TUMBLEBUG_PORT:1323}
id: ${TUMBLEBUG_ID:default}
pass: ${TUMBLEBUG_PASSWORD:default}

file:
upload:
Expand Down
Loading

0 comments on commit 5cddc19

Please sign in to comment.