시나리오 생성

Prev Next

Classic/VPC 환경에서 이용 가능합니다.

배포 시나리오를 생성합니다.

요청

요청 형식을 설명합니다. 요청 형식은 다음과 같습니다.

메서드 URI
POST /api/v1/project/{projectId}/stage/{stageId}/scenario

요청 헤더

SourceDeploy API에서 공통으로 사용하는 헤더에 대한 정보는 SourceDeploy 요청 헤더를 참조해 주십시오.

요청 경로 파라미터

요청 경로 파라미터에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
projectId String Required 프로젝트 아이디
stageId String Required 배포 스테이지 아이디

요청 바디

요청 바디에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
name String Required 배포 시나리오 이름
  • 영문자, 숫자, 특수 문자 '-', '_'를 조합하여 1~100자 이내로 입력
description String Optional 배포 시나리오 설명
config Object Required 배포 타깃 설정

TScenarioServer

TScenarioServer에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
strategy String Required 배포 전략
  • normal: 기본 (유효값)
sequence Boolean Optional 순차 배포 여부
  • true (기본값) | false
    • true: 순차 배포
    • false: 동시 배포
file Object Required 배포 파일 정보
file.type String Required 배포 파일 위치
  • ObjectStorage | SourceBuild | later
    • ObjectStorage: Object Storage
    • SourceBuild: SourceBuild
    • later: 나중에 설정
file.ObjectStorage Object Conditional Object Storage 정보
  • file.typeObjectStorage인 경우, 하위 정보 포함하여 필수 입력
file.ObjectStorage.bucket String Conditional 버킷 이름
file.ObjectStorage.object String Conditional 파일 이름
file.SourceBuild Object Conditional SourceBuild 정보
  • file.typeSourceBuild인 경우, 하위 정보 포함하여 필수 입력
file.SourceBuild.id Number Conditional 빌드 프로젝트 아이디
rollback Boolean Required 배포 실패 시 롤백 사용 여부
  • true | false
    • true: 사용
    • false: 사용 안 함
cmd.pre Array Optional 배포 전 실행 명령어 목록
cmd.deploy Array Optional 파일 배포 경로 목록
cmd.post Array Optional 배포 후 실행 명령어 목록

pre

pre에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
user String Optional 실행 계정
cmd String Optional 실행 명령

deploy

deploy에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
sourcePath String Optional 소스 파일 경로
deployPath String Optional 배포 경로

post

post에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
user String Optional 실행 계정
cmd String Optional 실행 명령

TScenarioAutoScalingGroup

TScenarioAutoScalingGroup에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
strategy String Required 배포 전략
  • normal | blueGreen
    • normal: 기본
    • blueGreen: 블루/그린
sequence Boolean Optional 순차 배포 여부
  • true (기본값) | false
    • true: 순차 배포
    • false: 동시 배포
file Object Required 배포 파일 정보
file.type String Required 배포 파일 위치
  • ObjectStorage | SourceBuild | later
    • ObjectStorage: Object Storage
    • SourceBuild: SourceBuild
    • later: 나중에 설정
file.ObjectStorage Object Conditional Object Storage 정보
  • file.typeObjectStorage인 경우, 하위 정보 포함하여 필수 입력
file.ObjectStorage.bucket String Conditional 버킷 이름
file.ObjectStorage.object String Conditional 파일 이름
file.SourceBuild Object Conditional SourceBuild 정보
  • file.typeSourceBuild인 경우, 하위 정보 포함하여 필수 입력
file.SourceBuild.id Number Conditional 빌드 프로젝트 아이디
rollback Boolean Required 배포 실패 시 롤백 사용 여부
  • true | false
    • true: 사용
    • false: 사용 안 함
cmd.pre Array Optional 배포 전 실행 명령어 목록
cmd.deploy Array Optional 파일 배포 경로 목록
cmd.post Array Optional 배포 후 실행 명령어 목록
loadBalancer Object Conditional 로드 밸런서 정보
  • strategyblueGreen인 경우, 하위 정보 포함하여 필수 입력
loadBalancer.loadBalancerTargetGroupNo Number Conditional 로드 밸런서 Target Group 아이디
loadBalancer.deleteAsg Boolean Conditional 기존 Auto Scaling 그룹 삭제 여부
  • true | false
    • true: 삭제 및 반납
    • false: 유지
loadBalancer.deleteServer Boolean Conditional 기존 Auto Scaling 그룹 내 서버 반납 여부
  • true | false
    • true: 반납
    • false: 유지
  • loadBalancer.deleteAsgtrue인 경우, true로만 입력

pre

pre에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
user String Optional 실행 계정
cmd String Optional 실행 명령

deploy

deploy에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
sourcePath String Optional 소스 파일 경로
deployPath String Optional 배포 경로

post

post에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
user String Optional 실행 계정
cmd String Optional 실행 명령

TScenarioKubernetesService

TScenarioKubernetesService에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
strategy String Required 배포 전략
  • rolling | blueGreen | canary
    • rolling: Rolling
    • blueGreen: 블루/그린
    • canary: Canary
manifest Object Required 매니페스트 정보
manifest.type String Required 매니페스트 파일 저장소
  • SourceCommit (유효값)
manifest.repository String Required 리포지토리 이름
manifest.branch String Required 브랜치 이름
manifest.path Array Required 파일 위치 목록
canaryConfig Object Conditional Canary 분석 설정
  • strategycanary인 경우, 하위 정보 포함하여 필수 입력
canaryConfig.analysisType String Conditional Canary 분석 방법
  • manual | auto
    • manual: 수동
    • auto: 자동
canaryConfig.canaryCount Number Conditional Baseline, Canary Pod 수
  • 1~10
canaryConfig.timeout Number Conditional 타임아웃(분)
  • 1~360
  • Canary 배포/취소 여부의 최대 결정 시간
  • canaryConfig.analysisTypemanual인 경우, 필수 입력
canaryConfig.prometheus String Conditional Prometheus Url
  • canaryConfig.analysisTypeauto인 경우, 필수 입력
canaryConfig.env Object Conditional 분석 환경 변수
  • canaryConfig.analysisTypeauto인 경우, 하위 정보 포함하여 필수 입력
canaryConfig.env.baseline String Conditional 분석 환경 변수: Baseline 이름
  • 영문자, 숫자, 특수 문자 '-', '_'를 조합하여 62자 이내로 입력
canaryConfig.env.canary String Conditional 분석 환경 변수: Canary 이름
  • 영문자, 숫자, 특수 문자 '-', '_'를 조합하여 62자 이내로 입력
canaryConfig.metrics Array Conditional Metric 설정 목록
  • canaryConfig.analysisTypeauto인 경우, 하위 정보 포함하여 필수 입력
canaryConfig.analysisConfig Object Conditional 분석 설정
  • canaryConfig.analysisTypeauto인 경우, 하위 정보 포함하여 필수 입력
canaryConfig.analysisConfig.duration Number Conditional 분석 시간(분)
  • 10~360
canaryConfig.analysisConfig.delay Number Conditional 분석 지연 시간(분)
  • 0~60
canaryConfig.analysisConfig.interval Number Conditional 분석 주기(분)
  • 1~360
  • 분석 시간 미만이어야 함
canaryConfig.analysisConfig.step Number Conditional Metric 수집 주기(초)
  • 10~360
canaryConfig.passScore Number Conditional 분석 성공 점수
  • 1~100
  • canaryConfig.analysisTypeauto인 경우, 필수 입력

metrics

metrics에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
name String Conditional Metric 이름
  • 영문자, 숫자, 특수 문자 '-', '_'를 조합하여 1~100자 이내로 입력
successCriteria String Conditional 성공 기준
  • base | canary
    • base: Baseline > Canary
    • canary: Baseline < Canary
queryType String Conditional 쿼리 타입
  • default | promQL
weight Number Conditional Metric 가중치
  • 1~100
  • 입력한 Metric의 가중치 총합이 100이어야 함
metric String Conditional Metric 값
  • Prometheus에 설정한 Metric 입력
  • queryTypedefault인 경우, 필수 입력
filter String Conditional Filter 값
  • 라벨 조건 입력
  • queryTypedefault인 경우, 필수 입력
query String Conditional 쿼리
  • queryTypepromQL인 경우, 필수 입력

TScenarioObjectStorage

TScenarioObjectStorage에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
file Object Required 배포 파일 정보
file.type String Required 배포 파일 위치
  • ObjectStorage | SourceBuild | later
    • ObjectStorage: Object Storage
    • SourceBuild: SourceBuild
    • later: 나중에 설정
file.ObjectStorage Object Conditional Object Storage 정보
  • file.typeObjectStorage인 경우, 하위 정보 포함하여 필수 입력
file.ObjectStorage.bucket String Conditional 버킷 이름
file.ObjectStorage.object String Conditional 파일 이름
file.SourceBuild Object Conditional SourceBuild 정보
  • file.typeSourceBuild인 경우, 하위 정보 포함하여 필수 입력
file.SourceBuild.id Number Conditional 빌드 프로젝트 아이디
path Array Optional 파일 배포 경로 목록

path

path에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
sourcePath String Optional 소스 파일 경로
deployPath String Optional 배포 경로

요청 예시

요청 예시는 다음과 같습니다.

curl --location --request POST 'https://vpcsourcedeploy.apigw.gov-ntruss.com/api/v1/project/2***/stage/3***/scenario' \
--header 'x-ncp-apigw-timestamp: {Timestamp}' \
--header 'x-ncp-iam-access-key: {Access Key}' \
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \
--header 'Content-Type: application/json' \
--data '{
    "name": "testScenario2",
    "description": "test Scenario 2",
    "config": {
        "strategy": "normal",
        "sequence": true,
        "file": {
            "type": "ObjectStorage",
            "ObjectStorage": {
                "bucket": "devtool",
                "object": "/result/build-sample.zip"
            }
        },
        "rollback": true,
        "cmd": {
            "pre": [
                {
                    "user": "root",
                    "cmd": "mv logs/app.log logs/app_$(date +%s).log"
                }
            ],
            "deploy": [
                {
                    "sourcePath": "/main.py",
                    "deployPath": "/home/root/"
                }
            ],
            "post": [
                {
                    "user": "root",
                    "cmd": "nohup python3 main.py > logs/app.log 2>&1 &"
                }
            ]
        }
    }
}'

응답

응답 형식을 설명합니다.

응답 바디

응답 바디에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
result Object - 응답 결과
result.id Number - 배포 시나리오 아이디
result.name String - 배포 시나리오 이름

응답 상태 코드

SourceDeploy API에서 공통으로 사용하는 응답 상태 코드에 대한 정보는 SourceDeploy 응답 상태 코드를 참조해 주십시오.

응답 예시

응답 예시는 다음과 같습니다.

{
    "result": {
        "id": 2***,
        "name": "testScenario2"
    }
}