Skip to content

Commit

Permalink
Merge pull request #40 from MZC-CSC/develop
Browse files Browse the repository at this point in the history
docker command deleted and added infra and update command
  • Loading branch information
MZC-CSC authored Oct 16, 2024
2 parents 66b7239 + 7fccfb6 commit 32ed414
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 44 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Usage:
Available Commands:
api Call the Cloud-Migrator system's Open APIs as services and actions
docker Installing and managing cloud-migrator's infrastructure
help Help about any command
infra Installing and managing cloud-migrator's infrastructure
rest rest api call
Flags:
Expand All @@ -79,15 +79,15 @@ Use "mayfly [command] --help" for more information about a command.
```

For more detailed explanations, see the articles below.
- [docker sub-command guide](https://github.com/cloud-barista/cm-mayfly/blob/main/docs/cb-mayfly-docker-compose-mode.md)
- [infra sub-command guide](https://github.com/cloud-barista/cm-mayfly/blob/main/docs/cb-mayfly-docker-compose-mode.md)
- [rest sub-command guide](https://github.com/cloud-barista/cm-mayfly/blob/main/docs/cb-mayfly-rest.md)
- [api sub-command guide](https://github.com/cloud-barista/cm-mayfly/blob/main/docs/cb-mayfly-api.md)


# How to Build a Cloud-Migrator Infrastructure
A quick guide on how to easily build a Cloud-Migrator infrastructure.
If you need a more detailed explanation, check out the article below.
- [docker sub-command guide](https://github.com/cloud-barista/cm-mayfly/blob/main/docs/cb-mayfly-docker-compose-mode.md)
- [infra sub-command guide](https://github.com/cloud-barista/cm-mayfly/blob/main/docs/cb-mayfly-docker-compose-mode.md)


## 1. Download cm-mayfly
Expand All @@ -107,12 +107,12 @@ If necessary, you can also modify the contents of the profile.json file after th

## 3. Building a Docker-based infrastructure
```
$ ./cm-mayfly docker run
$ ./cm-mayfly infra run
```

## 4. Checking the subsystem running status
```
$ ./cm-mayfly docker info
$ ./cm-mayfly infra info
```


Expand All @@ -130,8 +130,8 @@ Use the -h option at the end of the sub-command requiring assistance, or executi
```
Usage:
mayfly docker [flags]
mayfly docker [command]
mayfly infra [flags]
mayfly infra [command]
Available Commands:
info Get information of Cloud-Migrator System
Expand All @@ -143,17 +143,17 @@ Available Commands:
Flags:
-h, --help help for docker
Use "mayfly docker [command] --help" for more information about a command.
Use "mayfly infra [command] --help" for more information about a command.
```
## docker subcommand examples
Simple usage examples for docker subcommand
```
./mayfly docker pull [-f ./conf/docker/docker-compose.yaml]
./mayfly docker run [-f ./conf/docker/docker-compose.yaml]
./mayfly docker info
./mayfly docker stop [-f ./conf/docker/docker-compose.yaml]
./mayfly docker remove [-f ./conf/docker/docker-compose.yaml] -v -i
./mayfly infra pull [-f ./conf/docker/docker-compose.yaml]
./mayfly infra run [-f ./conf/docker/docker-compose.yaml]
./mayfly infra info
./mayfly infra stop [-f ./conf/docker/docker-compose.yaml]
./mayfly infra remove [-f ./conf/docker/docker-compose.yaml] -v -i
```
Expand Down
8 changes: 4 additions & 4 deletions cmd/docker/pull.go → cmd/docker/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

// pullCmd represents the pull command
var pullCmd = &cobra.Command{
Use: "pull",
Short: "Pull images of Cloud-Migrator System containers",
Long: `Pull images of Cloud-Migrator System containers`,
Use: "install",
Short: "Install the Docker images of the subsystems that make up the Cloud-Migrator system.",
Long: `Install the Docker images of the subsystems that make up the Cloud-Migrator system.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("\n[Pull images of Cloud-Migrator System containers]")
fmt.Println("\n[Install the Docker images of the subsystems that make up the Cloud-Migrator system.]")
fmt.Println()

cmdStr := fmt.Sprintf("COMPOSE_PROJECT_NAME=%s docker compose -f %s pull %s", ProjectName, DockerFilePath, ServiceName)
Expand Down
20 changes: 11 additions & 9 deletions cmd/docker/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ var ServiceName string

// restCmd represents the rest command
var dockerCmd = &cobra.Command{
Use: "docker",
Use: "infra",
Short: "Installing and managing cloud-migrator's infrastructure",
Long: `Build the environment of the infrastructure required for cloud-migrator and monitor the running status of the infrastructure.
For example, you can setup and run, stop, and ... Cloud-Migrator runtimes.
- ./mayfly docker pull [-f ./conf/docker/docker-compose.yaml]
- ./mayfly docker run [-f ./conf/docker/docker-compose.yaml]
- ./mayfly docker info
- ./mayfly docker stop [-f ./conf/docker/docker-compose.yaml]
- ./mayfly docker remove [-f ./conf/docker/docker-compose.yaml] -v -i
For example, you can install and run, stop, update and ... Cloud-Migrator runtimes.
- ./mayfly infra install
- ./mayfly infra run
- ./mayfly infra run -d
- ./mayfly infra run -d -s cb-tumblebug
- ./mayfly infra info
- ./mayfly infra stop
- ./mayfly infra update
- ./mayfly infra remove -v -i
`,
Run: func(cmd *cobra.Command, args []string) {
//fmt.Println(cmd.UsageString())
Expand Down
6 changes: 3 additions & 3 deletions cmd/docker/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
// runCmd represents the run command
var runCmd = &cobra.Command{
Use: "run",
Short: "Setup and Run Cloud-Migrator System",
Long: `Setup and Run Cloud-Migrator System`,
Short: "Install and Run Cloud-Migrator System",
Long: `Install and Run Cloud-Migrator System`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("\n[Setup and Run Cloud-Migrator]")
fmt.Println("\n[Install and Run Cloud-Migrator System]")
fmt.Println()

detachModeOption := ""
Expand Down
47 changes: 47 additions & 0 deletions cmd/docker/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package docker

import (
"fmt"

"github.com/cm-mayfly/cm-mayfly/common"
"github.com/spf13/cobra"
)

// pullCmd represents the pull command
var updateCmd = &cobra.Command{
Use: "update",
Short: "Update the latest Docker images of the subsystems that make up the Cloud-Migrator system.",
Long: `Update the latest Docker images of the subsystems that make up the Cloud-Migrator system.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("\n[Update the Docker images of the subsystems that make up the Cloud-Migrator system.]")
//============================
// Pull
//============================
fmt.Println("[Install the latest Docker images of the Cloud-Migrator subsystems.]")
fmt.Println()

cmdStr := fmt.Sprintf("COMPOSE_PROJECT_NAME=%s docker compose -f %s pull %s", ProjectName, DockerFilePath, ServiceName)
//fmt.Println(cmdStr)
common.SysCall(cmdStr)

//============================
// RUN
//============================
fmt.Println("\n\n[Restart based on the installed latest Docker images.]")
fmt.Println()

detachModeOption := ""
if DetachMode {
detachModeOption = "-d"
}
cmdStr = fmt.Sprintf("COMPOSE_PROJECT_NAME=%s docker compose -f %s up %s %s", ProjectName, DockerFilePath, detachModeOption, ServiceName)

//fmt.Println(cmdStr)
common.SysCall(cmdStr)

},
}

func init() {
dockerCmd.AddCommand(updateCmd)
}
Binary file modified conf/docker/tool/mayfly
Binary file not shown.
45 changes: 30 additions & 15 deletions docs/cb-mayfly-docker-compose-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. [환경설정 확인 및 변경](#환경설정-확인-및-변경)
1. [Cloud-Migrator 인프라 구축](#cloud-migrator-인프라-구축)
1. [Cloud-Migrator 실행상태 확인](#cloud-migrator-실행상태-확인)
1. [Cloud-Migrator 업데이트](#cloud-migrator-업데이트)
1. [Cloud-Migrator 삭제(인프라 구축 환경 정리)](#cloud-migrator-삭제인프라-구축-환경-정리)
1. [Docker 전체 환경 정리](#docker-전체-환경-정리)

Expand Down Expand Up @@ -82,24 +83,30 @@ mc-data-manger 서브 시스템은 `CSP를 이용하기 위한 인증 정보가


## Cloud-Migrator 인프라 구축
아래 명령을 실행하면 도커 기반 인프라가 자동으로 구축됩니다.
아래 명령을 실행하면 도커 기반 인프라가 자동으로 구축되며 실행 과정이 화면에 출력됩니다.
```bash
$ ./mayfly docker run
$ ./mayfly infra run
```

만약, Cloud-Migrator 시스템을 구축하려는 시스템 환경이 Clean한 환경이 아니라 `./mayfly docker run` 명령만으로는 충돌로 인해 설치 문제가 발생할 경우에는 [Docker 전체 환경 정리](#docker-전체-환경-정리) 섹션의 내용을 확인해서 시스템 환경을 먼저 깔끔하게 정리 후 실행하는 것을 추천드립니다.
만약, Cloud-Migrator 시스템을 구축하려는 시스템 환경이 Clean한 환경이 아니라서 `./mayfly infra run` 명령만으로는 제대로 실행되지 않는 설치 문제가 발생할 경우에는 [Docker 전체 환경 정리](#docker-전체-환경-정리) 섹션의 내용을 확인해서 시스템 환경을 먼저 깔끔하게 정리 후 실행하는 것을 추천드립니다.


설치 과정을 보고 싶지 않다면 -d 옵션이나 --detach 플래그를 사용해서 설치 과정을 백그라운드로 실행할 수 있습니다.
```bash
$ ./mayfly infra run -d
```


특정 프레임워크만 실행하고 싶으면 아래처럼 실행합니다.
예를 들어, cb-tumbleug을 실행하고 싶은 경우..
```bash
$ ./mayfly docker run cb-tumblebug
$ ./mayfly infra run cb-tumblebug
```

## Cloud-Migrator 실행상태 확인
설치된 인프라 및 서브 프레임워크들의 상태를 확인할 수 있습니다.
```bash
$ ./mayfly docker info
$ ./mayfly infra info
```

실행 결과 예시
Expand Down Expand Up @@ -145,17 +152,25 @@ etcd gcr.io/etcd-development/etcd v3.5.14 13b1359
```


## Cloud-Migrator 업데이트
Cloud-Migrator 서브 시스템들의 최신 버전으로 업데이트하고 싶은 경우 update 명령으로 현재 환경을 최신 버전으로 재구축할 수 있습니다.
```bash
$ ./mayfly infra update
```



## Cloud-Migrator 중지
일부 또는 전체 프레임워크를 잠시 중지할 때 사용합니다.
```bash
$ ./mayfly docker stop
$ ./mayfly infra stop
```


특정 프레임워크만 중지하고 싶으면 아래처럼 실행합니다.
예를 들어, cb-tumbleug을 중지하고 싶은 경우..
```bash
$ ./mayfly docker stop cb-tumbleug
$ ./mayfly infra stop cb-tumbleug
```


Expand All @@ -164,32 +179,32 @@ $ ./mayfly docker stop cb-tumbleug

아래 명령으로 실행된 모든 컨테이너가 종료 및 삭제되며 생성된 네트워크도 삭제됩니다.
```bash
$ ./mayfly docker remove
$ ./mayfly infra remove
```

사용된 이미지도 함께 삭제합니다.
```bash
$ ./mayfly docker remove --images
$ ./mayfly infra remove --images
또는
$ ./mayfly docker remove -i
$ ./mayfly infra remove -i
```

생성된 볼륨된 함께 삭제합니다.
(주의) 볼륨이 삭제되면 저장된 데이터도 모두 삭제됩니다.
```bash
$ ./mayfly docker remove --volumes
$ ./mayfly infra remove --volumes
또는
$ ./mayfly docker remove -v
$ ./mayfly infra remove -v
```

컨테이너를 비롯하여 네트워크 및 이미지와 볼륨 등 모든 자원을 삭제합니다.
완전히 최초 상태로 재구축하고 싶거나 더 이상 필요 없을 때 사용하세요.
```bash
./mayfly docker remove --images --volumes
./mayfly infra remove --images --volumes
또는
./mayfly docker remove -i -v
./mayfly infra remove -i -v
또는
./mayfly docker remove --all
./mayfly infra remove --all
```

## Docker 전체 환경 정리
Expand Down
Binary file modified mayfly
Binary file not shown.

0 comments on commit 32ed414

Please sign in to comment.