YARN Service 빠른 시작
YARN Service 빠른 시작 (Quick Start)
이 문서는 YARN Service 프레임워크를 사용해 YARN에 서비스를 배포하는 빠른 시작 튜토리얼을 제공합니다. 간단한 JSON 스펙(Yarnfile)으로 서비스 하나를 만들어 YARN에 배포해 봅니다.
출처: 문서
본문
개요 (Overview)
이 튜토리얼에서는 YARN Service 프레임워크를 사용해 단일 컴포넌트 서비스를 YARN 클러스터에 배포하는 간단한 단계를 보여줍니다.
사전 준비 (Prerequisites)
- YARN 클러스터가 실행 중이어야 합니다.
- YARN Service 프레임워크(ApplicationMaster)와 API 서버가 활성화되어 있어야 합니다.
- 서비스가 사용할 도커 이미지 또는 실행 파일이 준비되어 있어야 합니다.
Yarnfile 만들기
YARN Service는 서비스 정의를 담은 JSON 스펙(Yarnfile)을 사용합니다. 예를 들어 간단한 단일 컴포넌트 서비스 정의는 다음과 같습니다.
{
"name": "my-service",
"components": [
{
"name": "hello",
"number_of_containers": 1,
"launch_command": "/bin/echo hello-world",
"resource": {
"cpus": 1,
"memory": "128"
}
}
]
}
name: 서비스 이름(사용자당 고유).components: 서비스의 컴포넌트 정의 배열.number_of_containers: 이 컴포넌트에 할당할 컨테이너 수.launch_command: 컨테이너에서 실행할 명령.resource: 컨테이너당 cpus/메모리 리소스.
서비스 배포 (Deployment)
REST API를 통해 배포합니다. 예를 들어 curl을 사용합니다.
curl -X POST -H "Content-Type: application/json" \
-d @my-service.json \
"http://<host>:8088/app/v1/services"
HTTP POST /app/v1/services로 서비스를 생성하고, GET /app/v1/services로 목록을, DELETE /app/v1/services/{name}으로 삭제할 수 있습니다.
서비스 상태 확인
curl "http://<host>:8088/app/v1/services" # 서비스 목록
curl "http://<host>:8088/app/v1/services/my-service" # 특정 서비스 상태
서비스가 RUNNING 상태가 되면 컨테이너가 실행 중임을 의미합니다.
컴포넌트 확장
실행 중인 서비스의 컴포넌트 컨테이너 수를 변경(flex)할 수 있습니다.
curl -X PUT -H "Content-Type: application/json" \
-d '{"components":[{"name":"hello","number_of_containers":3}]}' \
"http://<host>:8088/app/v1/services/my-service"
참고: 이 기능은 alpha 상태이므로 API와 명령줄은 변경될 수 있습니다.
더 알아보기 (Learn more)
- 원문: 문서