Skip to content

Commit

Permalink
Merge pull request #19 from pbcccBeatBoard/main
Browse files Browse the repository at this point in the history
edit docker-compose, etc yaml
  • Loading branch information
pbcccbeatboard-strato authored Sep 6, 2024
2 parents 0fd9d61 + 52dc73b commit a337534
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-delivery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
branches:
- main
- testcicd
#tags:
# - "v*.*.*"
tags:
- "v*.*.*"
paths-ignore:
- "**.md"
- ".gitignore"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
IMAGE_NAME: ${{ github.event.repository.name }}
run: docker build . --file Dockerfile --tag $IMAGE_NAME


- name: chk image
run: docker ps -a


12 changes: 6 additions & 6 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ networks:
# jenkins - for workflow manager
jenkins:
image: jenkins/jenkins:jdk17
container_name: jenkins
container_name: ape-jenkins
platform: linux/amd64
networks:
- internal_network
Expand Down Expand Up @@ -58,11 +58,11 @@ networks:

# application-manager
mc-application-manager:
image: m-cmp/mc-application-manager
image: m-cmp/mc-application-manager:latest
container_name: application-manager
build:
context: ./
dockerfile: Dockerfile
#build:
#context: ./
#dockerfile: Dockerfile
networks:
- external_network
- external_network
Expand All @@ -76,7 +76,7 @@ networks:
- DDL_AUTO=create-drop
- DB_USER=application
- DB_PASS=application!23
- SQL_DATA_INIT=always
- SQL_DATA_INIT=always # or never
healthcheck: # for cb-application-manager
test: ["CMD", "nc", "-vz", "localhost", "1324"]
interval: 1m
Expand Down
28 changes: 17 additions & 11 deletions src/main/java/kr/co/mcmp/manifest/K8SDeployYamlGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@Component
public class K8SDeployYamlGenerator {

/*
private V1Pod getPod(K8SPodDTO podDto) {
V1Pod pod = new V1Pod();
Expand Down Expand Up @@ -72,6 +72,12 @@ public String getPodYaml(K8SPodDTO podDto) {
String yaml = buffer.toString();
return yaml;
}
*/







private V1Deployment getDeployment(K8SDeploymentDTO deploy) {
Expand Down Expand Up @@ -118,7 +124,7 @@ private V1PodTemplateSpec getPodTemplateSpec(K8SDeploymentDTO deploy){
podTemplateSpec.setMetadata(metadata);

K8SPodDTO podDto = deploy.getPodDto();
V1PodSpec podSpec = getPodSpec(podDto);
//V1PodSpec podSpec = getPodSpec(podDto);
/*
// add imagepullsecrets
if (StringUtils.isNotEmpty(deploy.getImagePullSecret())) {
Expand All @@ -129,7 +135,7 @@ private V1PodTemplateSpec getPodTemplateSpec(K8SDeploymentDTO deploy){
podSpec.setImagePullSecrets(imagePullSecretsList);
}
*/
podTemplateSpec.setSpec(podSpec);
//podTemplateSpec.setSpec(podSpec);


/*
Expand All @@ -152,7 +158,7 @@ private V1PodTemplateSpec getPodTemplateSpec(K8SDeploymentDTO deploy){
*/

// template.spec.container.volumeMounts
setVolumeMounts(podSpec.getContainers().get(0), deploy.getVolumes());
//setVolumeMounts(podSpec.getContainers().get(0), deploy.getVolumes());

// template.spec.container.resources
//setResource(container, deploy.getResource());
Expand Down Expand Up @@ -262,13 +268,13 @@ public String getHpaYaml(K8SHPADTO hpaDto){
}


private V1Service getSvc(K8SServiceDTO svcDto){
return null;
}

public String getSvcYaml(K8SServiceDTO svcDto){
return "";
}
// private V1Service getSvc(K8SServiceDTO svcDto){
// return null;
// }
//
// public String getSvcYaml(K8SServiceDTO svcDto){
// return "";
// }


private V1ObjectMeta getMetadata(String name, String namespace) {
Expand Down
56 changes: 0 additions & 56 deletions src/main/java/kr/co/mcmp/manifest/K8SDeployYamlService.java

This file was deleted.

14 changes: 0 additions & 14 deletions src/main/java/kr/co/mcmp/manifest/K8SServiceDTO.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public class YamlGenerateController {
@Operation(summary = "yaml generate for pod")
@PostMapping("/pod")
public String generatePodYaml(K8SPodDTO k8sPodDto){
return yamlGenSvc.generatePodYaml(k8sPodDto);
//System.out.println("==================================" + k8sPodDto.toString());
System.out.println("==================================");
return "";
//return yamlGenSvc.generatePodYaml(k8sPodDto);
}

@Operation(summary = "yaml generate for deployment")
Expand Down
77 changes: 71 additions & 6 deletions src/main/java/kr/co/mcmp/manifest/YamlGenerateService.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,104 @@
package kr.co.mcmp.manifest;

import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.*;
import io.kubernetes.client.util.Yaml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class YamlGenerateService {

Logger logger = LoggerFactory.getLogger(YamlGenerateService.class);

@Autowired
K8SDeployYamlGenerator yamlGen;
// @Autowired
// K8SDeployYamlGenerator yamlGen;


public String generatePodYaml(K8SPodDTO podContents){
return yamlGen.getPodYaml(podContents);
//return yamlGen.getPodYaml(podContents);
return getPodYaml(podContents);
}

public String generateDeploymentYaml(K8SDeploymentDTO deploy){
return yamlGen.getDeploymentYaml(deploy);
//return yamlGen.getDeploymentYaml(deploy);
return "";
}

public String generateConfigmapYaml(){
return "";
}

public String generateHPAYaml(K8SHPADTO hpaDto){
return yamlGen.getHpaYaml(hpaDto);
//return yamlGen.getHpaYaml(hpaDto);
return "";
}

public String generateServiceYaml(){
return "";
}





private V1Pod getPod(K8SPodDTO podDto) {

V1Pod pod = new V1Pod();
pod.setApiVersion(K8S.Controller.Pod.getApiVersion());
pod.setKind("Pod");

V1ObjectMeta metadata = new V1ObjectMeta();
metadata.setName(podDto.getPodName());
metadata.setNamespace(podDto.getNamespace());
metadata.setLabels(podDto.getLabels());
pod.setMetadata(metadata);

V1PodSpec podSpec = getPodSpec(podDto);
pod.setSpec(podSpec);

return pod;
}

private V1PodSpec getPodSpec(K8SPodDTO podDto){
V1PodSpec podSpec = new V1PodSpec();
List<V1Container> containerList = new ArrayList<>(); //podDto.getContainers();
for(K8SPodDTO.Container cont: podDto.getContainers()){
V1Container container = new V1Container();
container.setName(cont.getContainerName());
container.setImage(cont.getContainerImage());
List<V1ContainerPort> 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;
}


public String getPodYaml(K8SPodDTO podDto) {
V1Pod pod = getPod(podDto);
StringBuffer buffer = new StringBuffer();
buffer.append(Yaml.dump(pod));
String yaml = buffer.toString();
return yaml;
}




}
4 changes: 2 additions & 2 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:create-drop} # ${DDL_AUTO:none}
ddl-auto: ${DDL_AUTO:update} # ${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:always} # ${SQL_DATA_INIT:never}
mode: ${SQL_DATA_INIT:never} #${SQL_DATA_INIT:always} # ${SQL_DATA_INIT:never}
platform: h2
#schema-locations: classpath:ddl.sql

Expand Down

0 comments on commit a337534

Please sign in to comment.