@bifos/nhncloud-cli 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,134 @@
1
+ # Common Reference
2
+
3
+ 설치, configure, profile, 출력 모드, 에러 코드를 다룬다.
4
+ 서비스별 세부 명령은 각 reference를 읽는다.
5
+
6
+ ## 설치
7
+
8
+ ```bash
9
+ npm install -g @bifos/nhncloud-cli
10
+ ```
11
+
12
+ ## 초기 설정
13
+
14
+ 첫 설정은 `nhncloud configure`로 한다.
15
+ 대화형 마법사가 profile, UAK, 서비스별 자격증명을 묻고 저장 전 연결을 테스트한다.
16
+
17
+ ```bash
18
+ nhncloud configure
19
+ nhncloud configure --profile staging
20
+ ```
21
+
22
+ CI나 자동화에서는 flag로 비대화형 저장을 한다.
23
+
24
+ ```bash
25
+ nhncloud configure \
26
+ --uak-id <uak-id> --uak-secret <uak-secret> \
27
+ --logncrash-appkey <appkey> --logncrash-secret <secret> \
28
+ --ncr-appkey <appkey> \
29
+ --no-verify
30
+ ```
31
+
32
+ 주요 옵션:
33
+
34
+ | 옵션 | 설명 |
35
+ |------|------|
36
+ | `--profile <name>` | 대상 profile. 기본값은 `default` |
37
+ | `--uak-id <id>` / `--uak-secret <secret>` | 공통 User Access Key |
38
+ | `--logncrash-appkey <key>` / `--logncrash-secret <secret>` | Log & Crash 검색 자격증명 |
39
+ | `--ncr-appkey <key>` | NCR appkey |
40
+ | `--iaas-tenant-id <id>` / `--iaas-username <name>` / `--iaas-password <password>` | IaaS/NKS 자격증명 |
41
+ | `--iaas-region <region>` | IaaS 기본 region |
42
+ | `--no-verify` | 연결 테스트 생략 |
43
+
44
+ 저장 파일은 `~/.nhncloud/credentials.json`이고 mode 0600으로 관리된다.
45
+ 기본 profile은 선택적으로 `~/.nhncloud/config.json`의 `defaultProfile`로 지정한다.
46
+
47
+ ## Profile 우선순위
48
+
49
+ profile 해석 순서:
50
+
51
+ 1. `--profile <name>`
52
+ 2. `NHNCLOUD_PROFILE`
53
+ 3. `config.defaultProfile`
54
+ 4. `"default"`
55
+
56
+ 자동화에서는 `--profile`을 명시해 실행 환경 차이를 줄인다.
57
+
58
+ ## 출력 모드
59
+
60
+ | 플래그 | 출력 | 용도 |
61
+ |--------|------|------|
62
+ | 없음 | 사람이 읽기 좋은 table | 터미널 확인 |
63
+ | `--json` | JSON stdout | 파싱, 자동화, AI 에이전트 |
64
+ | `--quiet` | 핵심 식별자만 stdout | 단순 체이닝 |
65
+
66
+ `--json`은 CLI 출력 계약이다.
67
+ API 원본 wrapper를 항상 보존하지 않는다.
68
+ 예를 들어 `nhncloud instance get <instance-id> --json`은 `.server.status`가 아니라 `.status`를 읽는다.
69
+
70
+ ## Command catalog
71
+
72
+ `nhncloud commands`는 Commander tree에서 command path, argument, option, description을 출력한다.
73
+ 외부 API를 호출하지 않는 read-only metadata 명령이다.
74
+
75
+ ```bash
76
+ nhncloud commands
77
+ nhncloud commands --json
78
+ nhncloud commands --json | jq '.commands[] | select(.path=="nks cluster list")'
79
+ ```
80
+
81
+ AI 에이전트는 먼저 `commands --json`으로 실제 command path와 option 이름을 확인하고, 그다음 서비스 reference를 읽는다.
82
+
83
+ ## JSON shape 요약
84
+
85
+ | 명령 | `--json` 출력 shape |
86
+ |------|---------------------|
87
+ | `commands` | `{ commands: [{ path, description, arguments, options, subcommands }] }` |
88
+ | `logncrash search` | `{ totalItems, pageNumber, pageSize, data }` |
89
+ | `deploy binary-groups` | `binaryGroups` wrapper를 언랩한 배열 |
90
+ | `deploy binaries` | `{ totalCount, binaries }` |
91
+ | `instance list` | `servers` wrapper를 언랩한 server 배열 |
92
+ | `instance get` | `server` wrapper를 언랩한 단일 server |
93
+ | `instance flavors` | `flavors` wrapper를 언랩한 flavor 배열 |
94
+ | `instance images` | `images` wrapper를 언랩한 image 배열 |
95
+ | `instance availability-zones` | `availabilityZoneInfo` wrapper를 언랩한 배열 |
96
+ | `instance keypairs` | `keypairs[].keypair`를 flatten한 keypair 배열 |
97
+ | `network list` | VPC 배열 |
98
+ | `network subnet list` | subnet 배열 |
99
+ | `volume list` | volume 배열 |
100
+ | `volume get` | 단일 volume 객체 |
101
+ | `floatingip list` | Floating IP 배열 |
102
+ | `ncr list` | `registries` wrapper를 언랩한 registry 배열 |
103
+ | `ncr get` | `registry` wrapper를 언랩한 단일 registry |
104
+ | `ncr images` | repository 배열 |
105
+ | `ncr tags` | tag 배열 |
106
+ | `nks supports` | 지원 Kubernetes version / event type 객체 |
107
+ | `nks cluster list` | cluster 배열 |
108
+ | `nks cluster events` | event 배열 |
109
+ | `nks nodegroup list` | nodegroup 배열 |
110
+ | `nks addon-type list` | addon type 배열 |
111
+ | `nks addon list` | addon 배열 |
112
+ | `nks cluster addon list` | cluster addon 배열 |
113
+
114
+ NKS 단건 조회와 일부 설정 조회는 table 출력용 최소 컬럼을 만들고 `--json`에서는 raw 객체를 보존한다.
115
+ NKS 쓰기 명령 중 생성, resize, 설정 변경, 노드 action, 애드온 변경은 `{ uuid }` 응답을 반환한다.
116
+ 삭제 명령은 성공 메시지를 stderr에 쓰고 stdout은 비운다.
117
+ `nks cluster kubeconfig`는 kubeconfig 문자열을 stdout 또는 파일로 저장한다.
118
+
119
+ ## 에러 코드
120
+
121
+ | 상황 | exit code |
122
+ |------|-----------|
123
+ | API 오류 / 봉투 실패 | 1 |
124
+ | 인증 실패 | 2 |
125
+ | 입력 오류 / 필수 옵션 누락 / confirm 누락 | 3 |
126
+ | 자격증명 또는 config 오류 | 4 |
127
+
128
+ ## Agent 기본 규칙
129
+
130
+ - 조회는 먼저 `--json`으로 실행하고 필요한 id를 추출한다.
131
+ - 쓰기 명령 전에 `--profile`, `--region`, 대상 id를 명시한다.
132
+ - `--quiet`는 해당 명령이 식별자 출력을 문서화한 경우에만 사용한다.
133
+ - 삭제 명령은 비대화형 환경에서 `--yes`를 명시한다.
134
+ - stdout은 데이터로만 취급하고, 진행 메시지는 stderr로 분리된다고 가정한다.
@@ -0,0 +1,112 @@
1
+ # Deploy Reference
2
+
3
+ `deploy` 명령군은 NHN Cloud Deploy v2.1 API를 호출한다.
4
+ UAK를 OAuth `client_credentials`로 교환한 Bearer token으로 인증하고, token은 만료 전까지 캐시한다.
5
+
6
+ ## 설정
7
+
8
+ `~/.nhncloud/credentials.json`에 profile 공통 `userAccessKey`가 필요하다.
9
+ `nhncloud configure` 사용을 권장한다.
10
+
11
+ `~/.nhncloud/config.json`에는 named deploy target을 둔다.
12
+
13
+ Discovery:
14
+
15
+ ```bash
16
+ nhncloud commands --json | jq '.commands[] | select(.path|startswith("deploy"))'
17
+ ```
18
+
19
+ ```json
20
+ {
21
+ "version": 1,
22
+ "defaultProfile": "default",
23
+ "deploy": {
24
+ "targets": {
25
+ "my-service": {
26
+ "appKey": "<appKey>",
27
+ "artifactId": "<artifactId>",
28
+ "serverGroupId": "<serverGroupId>",
29
+ "scenarioIds": "<id1,id2>"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ## 배포 실행
37
+
38
+ ```bash
39
+ nhncloud deploy run my-service
40
+ nhncloud deploy run my-service --async
41
+ nhncloud deploy run my-service --target-hosts <host1,host2>
42
+ ```
43
+
44
+ `<target>`은 config의 deploy target 이름이다.
45
+
46
+ | 옵션 | 설명 |
47
+ |------|------|
48
+ | `--app-key <k>` | target의 appKey override |
49
+ | `--artifact-id <id>` | target의 artifactId override |
50
+ | `--server-group-id <id>` | target의 serverGroupId override |
51
+ | `--scenario-ids <csv>` | target의 scenarioIds override |
52
+ | `--target-hosts <csv>` | 대상 호스트. 생략 시 서버그룹 전체 |
53
+ | `--concurrent <n>` | 병렬 배포 수. 기본 1 |
54
+ | `--next-when-fail` | 시나리오 실패 시에도 진행 |
55
+ | `--note <s>` | 배포 메모 |
56
+ | `--async` | 즉시 반환. 기본은 완료 대기 |
57
+ | `--profile <name>` | 사용할 profile |
58
+
59
+ 동기 모드는 서버가 배포 완료까지 응답을 보류한다.
60
+ 비동기 모드는 `deploying` 상태를 즉시 반환하고, 완료 확인은 `deploy histories`로 한다.
61
+
62
+ ## 조회 명령
63
+
64
+ ```bash
65
+ nhncloud deploy artifacts my-service --json
66
+ nhncloud deploy server-groups my-service --json
67
+ nhncloud deploy histories my-service --json
68
+ nhncloud deploy binary-groups my-service --json
69
+ nhncloud deploy binaries my-service --binary-group <key> --json
70
+ ```
71
+
72
+ 의도별 명령:
73
+
74
+ | 의도 | 명령 |
75
+ |------|------|
76
+ | 아티팩트 목록 | `deploy artifacts <target>` |
77
+ | 서버그룹 목록 | `deploy server-groups <target>` |
78
+ | 배포 이력 | `deploy histories <target>` |
79
+ | 바이너리 그룹 목록 | `deploy binary-groups <target>` |
80
+ | 바이너리 목록 | `deploy binaries <target> --binary-group <key>` |
81
+
82
+ `deploy binary-groups --json`은 `binaryGroups` wrapper를 언랩한 배열이다.
83
+ `deploy binaries --json`은 `{ totalCount, binaries }` 객체다.
84
+
85
+ ## 바이너리 전송
86
+
87
+ ```bash
88
+ nhncloud deploy upload <target> --file ./app.tgz --binary-group <key>
89
+ nhncloud deploy download <target> --binary-group <key> --binary-key <key> -o ./app.tgz
90
+ ```
91
+
92
+ `upload`는 multipart로 로컬 파일을 업로드한다.
93
+ `--quiet`이면 `binaryKey`만 출력한다.
94
+
95
+ `download`는 바이너리를 파일로 저장한다.
96
+ 대상 파일이 이미 있으면 기본 거부하고, `--force`가 있을 때만 덮어쓴다.
97
+
98
+ ## 체이닝 예시
99
+
100
+ ```bash
101
+ nhncloud deploy artifacts my-service --json | jq -r '.[0].artifactId'
102
+ nhncloud deploy run my-service --artifact-id <artifactId>
103
+ nhncloud deploy histories my-service --json | jq '.[0] | {deployKey, deployStatus}'
104
+ ```
105
+
106
+ ## 에러 코드
107
+
108
+ | 상황 | exit code |
109
+ |------|-----------|
110
+ | UAK 누락 또는 config target 없음 | 4 또는 3 |
111
+ | OAuth 인증 실패 | 2 |
112
+ | Deploy API 오류 또는 봉투 실패 | 1 |
@@ -0,0 +1,126 @@
1
+ # IaaS Reference
2
+
3
+ `instance`, `network`, `volume`, `floatingip`은 IaaS 자격증명과 Keystone token을 공유한다.
4
+ region이 중요하면 `--region <region>`을 명시한다.
5
+
6
+ ## IaaS 설정
7
+
8
+ `nhncloud configure`에서 IaaS 자격증명을 저장하거나 flag로 입력한다.
9
+
10
+ ```bash
11
+ NHNCLOUD_IAAS_PASSWORD=<password> nhncloud configure \
12
+ --iaas-tenant-id <tenant-id> \
13
+ --iaas-username <username> \
14
+ --iaas-region kr1 \
15
+ --no-verify
16
+ ```
17
+
18
+ `--iaas-password`는 NHN Cloud 로그인 비밀번호가 아니라 IAM API 비밀번호다.
19
+ `--iaas-username`은 계정 이메일 또는 IAM 계정 ID다.
20
+
21
+ ## Discovery 순서
22
+
23
+ 인스턴스 생성 전에는 조회 명령으로 id를 확인한다.
24
+
25
+ ```bash
26
+ nhncloud commands --json | jq '.commands[] | select(.path|test("^(instance|network|volume|floatingip)"))'
27
+ nhncloud instance images --json
28
+ nhncloud instance flavors --detail --json
29
+ nhncloud network list --json
30
+ nhncloud instance keypairs --json
31
+ nhncloud instance availability-zones --json
32
+ ```
33
+
34
+ 생성/삭제/attach 전에는 profile과 region을 명시한다.
35
+
36
+ ## Instance 조회와 생성
37
+
38
+ ```bash
39
+ nhncloud instance list --json
40
+ nhncloud instance get <instance-id> --json
41
+ nhncloud instance create \
42
+ --name web \
43
+ --flavor <flavor-id> \
44
+ --image <image-id> \
45
+ --network <network-uuid> \
46
+ --wait --json
47
+ ```
48
+
49
+ `instance create --wait --quiet`는 ACTIVE 상태와 IP 할당을 기다린 뒤 IP를 출력한다.
50
+ GPU flavor 등 일부 flavor는 `--boot-volume-size <gb>`가 필요할 수 있다.
51
+ `--user-data <path>`는 cloud-init user-data를 base64로 인코딩해 주입하며, 인코딩 후 65535 byte 한도가 있다.
52
+
53
+ ## Instance 작업
54
+
55
+ ```bash
56
+ nhncloud instance delete <instance-id> --yes
57
+ nhncloud instance start <instance-id>
58
+ nhncloud instance stop <instance-id>
59
+ nhncloud instance reboot <instance-id> --hard
60
+ nhncloud instance resize <instance-id> --flavor <flavor-id>
61
+ nhncloud instance resize-confirm <instance-id>
62
+ nhncloud instance resize-revert <instance-id>
63
+ ```
64
+
65
+ `resize` 후에는 `VERIFY_RESIZE`에서 멈춘다.
66
+ `resize-confirm`으로 확정하거나 `resize-revert`로 롤백한다.
67
+
68
+ ## Keypair
69
+
70
+ ```bash
71
+ nhncloud instance keypairs --json
72
+ nhncloud instance keypair get <name> --json
73
+ nhncloud instance keypair create <name> --output ./key.pem
74
+ nhncloud instance keypair delete <name>
75
+ ```
76
+
77
+ `--public-key` 없이 생성하면 private key는 생성 시 한 번만 반환된다.
78
+ 자동화에서는 `--output`으로 mode 0600 파일 저장을 권장한다.
79
+
80
+ ## Network
81
+
82
+ ```bash
83
+ nhncloud network list --json
84
+ nhncloud network subnet list --json
85
+ ```
86
+
87
+ `instance create --network <uuid>`에는 `network list`의 VPC id를 사용한다.
88
+ subnet id가 아니다.
89
+
90
+ ## Volume
91
+
92
+ ```bash
93
+ nhncloud volume list --json
94
+ nhncloud volume get <volume-id> --json
95
+ nhncloud volume create --size 50 --name my-volume
96
+ nhncloud volume create --size 50 --volume-type "General SSD" --availability-zone kr-pub-a
97
+ nhncloud instance volumes <instance-id> --json
98
+ nhncloud instance volume attach <instance-id> --volume <volume-id>
99
+ nhncloud instance volume detach <instance-id> <volume-id>
100
+ ```
101
+
102
+ `volume create`, `attach`, `detach`는 쓰기 작업이다.
103
+ `--availability-zone <az>`에는 `instance availability-zones`의 `zoneName`을 지정한다.
104
+ 인스턴스와 같은 AZ에 볼륨을 만들어 attach 시 AZ 불일치 400을 피할 수 있다.
105
+ `attach`는 `--volume <id>` 플래그를 쓰고, `detach`는 `<instanceId> <volumeId>` 위치 인수를 쓴다.
106
+
107
+ ## Floating IP
108
+
109
+ ```bash
110
+ nhncloud floatingip list --json
111
+ nhncloud floatingip create --json
112
+ nhncloud floatingip create --network <network-uuid> --json
113
+ nhncloud floatingip delete <floatingip-id> --yes
114
+ ```
115
+
116
+ `floatingip create --quiet`는 발급된 Floating IP id를 출력한다.
117
+ `floatingip associate`는 instance→port_id 매핑 경로 미확정으로 아직 제공하지 않는다.
118
+
119
+ ## 에러 코드
120
+
121
+ | 상황 | exit code |
122
+ |------|-----------|
123
+ | IaaS 자격증명 누락 또는 불완전 | 4 |
124
+ | Keystone 인증 실패 | 2 |
125
+ | 미등록 region, 필수 옵션 누락, `--yes` 누락 | 3 |
126
+ | API 오류 또는 wait timeout | 1 |
@@ -0,0 +1,126 @@
1
+ # Log & Crash Reference
2
+
3
+ `logncrash` 명령군은 Log & Crash Search 검색, scroll export, collector 전송을 다룬다.
4
+
5
+ ## 검색
6
+
7
+ Discovery:
8
+
9
+ ```bash
10
+ nhncloud commands --json | jq '.commands[] | select(.path|startswith("logncrash"))'
11
+ ```
12
+
13
+ ```bash
14
+ nhncloud logncrash search \
15
+ --query 'logType:"ERROR"' \
16
+ --from 1h \
17
+ --to now \
18
+ --json
19
+ ```
20
+
21
+ 옵션:
22
+
23
+ | 옵션 | 필수 | 설명 |
24
+ |------|:---:|------|
25
+ | `--query <lucene>` | 예 | Lucene 질의 문자열. API에 그대로 전달 |
26
+ | `--from <time>` | 예 | 검색 시작. ISO8601 또는 상대시간 |
27
+ | `--to <time>` | 예 | 검색 끝. ISO8601, 상대시간, `now` |
28
+ | `--page <n>` | 아니오 | pageNumber. 기본 0 |
29
+ | `--size <n>` | 아니오 | pageSize. 기본 10, 최대 100 |
30
+ | `--profile <name>` | 아니오 | 사용할 profile |
31
+
32
+ Lucene 예시:
33
+
34
+ | 의도 | 쿼리 |
35
+ |------|------|
36
+ | 전체 검색 | `*` |
37
+ | body 단어 검색 | `body:request_received` |
38
+ | body 부분 문자열 검색 | `body:*request_received*` |
39
+ | logType 검색 | `logType:"ERROR"` |
40
+
41
+ 시간 입력:
42
+
43
+ - `1h`, `30m`, `2d`, `now`
44
+ - `2024-01-01T00:00:00+09:00` 같은 ISO8601 직접 입력
45
+
46
+ API 제약:
47
+
48
+ - 검색 시작은 최근 90일 이내여야 한다.
49
+ - 검색 범위는 31일 이하여야 한다.
50
+
51
+ ## 검색 출력
52
+
53
+ `--json` 출력은 `{ totalItems, pageNumber, pageSize, data }` 객체다.
54
+
55
+ ```bash
56
+ nhncloud logncrash search \
57
+ --query '*' \
58
+ --from 1h --to now \
59
+ --json | jq '.totalItems'
60
+ ```
61
+
62
+ 전송 직후에는 인덱싱 지연으로 잠시 0건이 나올 수 있다.
63
+ 반복 검색이나 넓은 wildcard 검색은 시간 범위를 좁혀 확인한다.
64
+
65
+ ## 대량 export
66
+
67
+ `logncrash export`는 검색 결과 전체를 scroll로 순회해 파일로 저장한다.
68
+ 데이터는 stdout이 아니라 파일에 쓰고, 진행 상황은 stderr에 출력한다.
69
+
70
+ ```bash
71
+ nhncloud logncrash export \
72
+ --query '<lucene>' \
73
+ --from 1h \
74
+ --to now \
75
+ --output logs.jsonl
76
+ ```
77
+
78
+ 옵션:
79
+
80
+ | 옵션 | 설명 |
81
+ |------|------|
82
+ | `--output <file>` | 필수. 출력 파일 |
83
+ | `--format json` | JSON 배열로 저장. 기본은 JSON Lines |
84
+ | `--force` | 기존 파일 덮어쓰기 |
85
+ | `--size <n>` | scroll pageSize. 10~100 |
86
+
87
+ scrollKey는 1분 만료다.
88
+ 데이터가 많아 다음 호출까지 1분을 넘기면 만료될 수 있다.
89
+ 이 경우 검색 범위를 좁히거나 `--size`를 키워 페이지 수를 줄인다.
90
+
91
+ ## 로그 전송
92
+
93
+ `logncrash send`는 collector host로 로그 한 건을 전송한다.
94
+ 검색과 달리 secret 헤더를 쓰지 않고, body의 `projectName`에 appkey를 넣는다.
95
+
96
+ ```bash
97
+ nhncloud logncrash send --body "batch finished" --level INFO
98
+ echo "batch finished" | nhncloud logncrash send --level INFO
99
+ nhncloud logncrash send --file ./error.log --level ERROR
100
+ ```
101
+
102
+ 입력 우선순위는 `--body` > `--file` > stdin이다.
103
+ 본문이 없거나 비어 있으면 입력 오류다.
104
+ 단일 로그 본문은 8MB 한도이며 초과 시 전송 전 차단된다.
105
+
106
+ 옵션:
107
+
108
+ | 옵션 | 설명 |
109
+ |------|------|
110
+ | `--body <text>` | 로그 본문 |
111
+ | `--file <path>` | 본문 파일 |
112
+ | `--level <level>` | DEBUG, INFO, WARN, ERROR, FATAL |
113
+ | `--app-version <ver>` | projectVersion |
114
+ | `--source <s>` / `--type <t>` / `--host <h>` | 부가 필드 |
115
+ | `--profile <name>` | 사용할 profile |
116
+
117
+ `--json`이면 `{ ok: true, bytes }`를 stdout에 출력한다.
118
+
119
+ ## 에러 코드
120
+
121
+ | 상황 | exit code |
122
+ |------|-----------|
123
+ | appkey 또는 secret 누락 | 4 |
124
+ | 인증 실패 | 2 |
125
+ | 시간 범위 초과, 본문 없음, 8MB 초과 | 3 |
126
+ | API 오류 또는 봉투 실패 | 1 |
@@ -0,0 +1,73 @@
1
+ # NCR Reference
2
+
3
+ `ncr` 명령군은 NHN Container Registry 레지스트리, 이미지, 태그를 조회한다.
4
+ Management API는 공통 UAK 정적 헤더를 사용한다.
5
+ 이미지와 태그 조회는 Harbor REST `/api/v2.0` 데이터플레인을 직접 호출하고 UAK Basic Auth를 사용한다.
6
+
7
+ ## 설정
8
+
9
+ 공통 UAK와 NCR appkey가 필요하다.
10
+
11
+ ```bash
12
+ nhncloud configure --uak-id <uak-id> --uak-secret <uak-secret> --ncr-appkey <appkey>
13
+ ```
14
+
15
+ `--app-key <key>`는 profile의 `ncr.appkey`보다 우선한다.
16
+ 기본 region은 `kr1`이고, `kr1`, `kr2`, `kr3`를 지원한다.
17
+
18
+ ## Registry 조회
19
+
20
+ ```bash
21
+ nhncloud commands --json | jq '.commands[] | select(.path|startswith("ncr"))'
22
+ nhncloud ncr list --app-key <appkey> --json
23
+ nhncloud ncr list --region kr2 --app-key <appkey> --json
24
+ nhncloud ncr get <registry> --app-key <appkey> --json
25
+ ```
26
+
27
+ `ncr list --json`은 `registries` wrapper를 언랩한 registry 배열이다.
28
+ `ncr get --json`은 `registry` wrapper를 언랩한 단일 registry 객체다.
29
+
30
+ ## Image와 tag 조회
31
+
32
+ ```bash
33
+ nhncloud ncr images <registry> --json
34
+ nhncloud ncr tags <registry> <repository> --json
35
+ ```
36
+
37
+ `ncr images --json`은 repository 배열이다.
38
+ `ncr tags --json`은 tag 배열이다.
39
+
40
+ ## 체이닝 예시
41
+
42
+ ```bash
43
+ nhncloud ncr list --app-key <appkey> --json | jq -r '.[].name'
44
+ nhncloud ncr get <registry> --app-key <appkey> --json
45
+ nhncloud ncr images <registry> --json | jq -r '.[].repository'
46
+ nhncloud ncr images <registry> --json | jq '.[] | {repository, artifact_count}'
47
+ nhncloud ncr tags <registry> <repository> --json | jq -r '.[].tag'
48
+ nhncloud ncr tags <registry> <repository> --json | jq 'sort_by(.push_time) | last | .tag'
49
+ ```
50
+
51
+ ## 옵션
52
+
53
+ | 옵션 | 설명 |
54
+ |------|------|
55
+ | `--region <region>` | NCR region. 기본 `kr1` |
56
+ | `--app-key <key>` | NCR appkey |
57
+ | `--profile <name>` | 사용할 profile |
58
+
59
+ ## 주의사항
60
+
61
+ - appkey는 NCR service appkey다.
62
+ - 인증 secret은 공통 UAK secret을 사용한다.
63
+ - Harbor REST 경로는 NHN 공통 봉투가 아니므로 wrapper unwrap을 기대하지 않는다.
64
+ - registry나 repository 인수는 공백 또는 빈값이면 입력 오류다.
65
+
66
+ ## 에러 코드
67
+
68
+ | 상황 | exit code |
69
+ |------|-----------|
70
+ | UAK 누락 또는 NCR appkey 미설정 | 4 |
71
+ | UAK 인증 실패 | 2 |
72
+ | 지원하지 않는 region, 빈 registry/repository 인수 | 3 |
73
+ | NCR API 또는 Harbor API 오류 | 1 |
@@ -0,0 +1,95 @@
1
+ # NKS Reference
2
+
3
+ `nks` 명령군은 NHN Kubernetes Service를 관리한다.
4
+ IaaS 자격증명으로 Keystone token을 발급하고 `container-infra` API를 호출한다.
5
+ 지원 region은 `kr1`, `kr2`, `kr3`이다.
6
+
7
+ ## Discovery 순서
8
+
9
+ ```bash
10
+ nhncloud commands --json | jq '.commands[] | select(.path|startswith("nks"))'
11
+ nhncloud nks supports --json
12
+ nhncloud nks cluster list --json
13
+ nhncloud nks cluster get <cluster> --json
14
+ nhncloud nks nodegroup list <cluster> --json
15
+ ```
16
+
17
+ 클러스터 생성이나 변경 전에는 지원 Kubernetes version, flavor, network, 기존 cluster/nodegroup 상태를 먼저 조회한다.
18
+
19
+ ## Cluster 조회
20
+
21
+ ```bash
22
+ nhncloud nks cluster list --json
23
+ nhncloud nks cluster get <cluster> --json
24
+ nhncloud nks cluster events <cluster> --json
25
+ nhncloud nks cluster event <cluster> <event> --json
26
+ nhncloud nks cluster ipacl <cluster> --json
27
+ nhncloud nks cluster kubeconfig <cluster>
28
+ nhncloud nks cluster kubeconfig <cluster> --output ./kubeconfig
29
+ ```
30
+
31
+ `kubeconfig`는 문자열을 stdout으로 출력하거나 `--output` 파일에 저장한다.
32
+
33
+ ## Nodegroup 조회와 변경
34
+
35
+ ```bash
36
+ nhncloud nks nodegroup list <cluster> --json
37
+ nhncloud nks nodegroup get <cluster> <nodegroup> --json
38
+ nhncloud nks nodegroup autoscale <cluster> <nodegroup> --json
39
+ nhncloud nks nodegroup create <cluster> --file ./nodegroup-create.json
40
+ nhncloud nks nodegroup delete <cluster> <nodegroup> --yes
41
+ nhncloud nks nodegroup stop-node <cluster> <nodegroup> --nodes node-1,node-2
42
+ nhncloud nks nodegroup start-node <cluster> <nodegroup> --nodes node-1,node-2
43
+ nhncloud nks nodegroup set-autoscale <cluster> <nodegroup> --file ./autoscale.json
44
+ nhncloud nks nodegroup set-metric-autoscale <cluster> <nodegroup> --file ./metric-autoscale.json
45
+ nhncloud nks nodegroup upgrade <cluster> <nodegroup> --version v1.30.1
46
+ nhncloud nks nodegroup set-userscript <cluster> <nodegroup> --file ./userscript.sh
47
+ nhncloud nks nodegroup update-flavor <cluster> <nodegroup> --flavor <flavor-uuid>
48
+ nhncloud nks nodegroup set-fip-auto-bind <cluster> <nodegroup> --file ./fip-auto-bind.json
49
+ nhncloud nks nodegroup set-labels <cluster> <nodegroup> --file ./labels.json
50
+ ```
51
+
52
+ ## Addon 조회와 변경
53
+
54
+ ```bash
55
+ nhncloud nks addon-type list --json
56
+ nhncloud nks addon-type get <addon-type> --json
57
+ nhncloud nks addon list --k8s-version v1.30.1 --json
58
+ nhncloud nks addon get <addon> --json
59
+ nhncloud nks cluster addon list <cluster> --json
60
+ nhncloud nks cluster addon get <cluster> <addon> --json
61
+ nhncloud nks cluster addon install <cluster> --name coredns --version 1.0.0 --resolve-conflicts overwrite
62
+ nhncloud nks cluster addon update <cluster> coredns --version 1.0.1 --resolve-conflicts preserve
63
+ nhncloud nks cluster addon remove <cluster> coredns --yes
64
+ ```
65
+
66
+ ## Cluster 생성과 변경
67
+
68
+ 복잡한 생성/설정 작업은 공식 API payload를 JSON 파일로 전달한다.
69
+ payload에는 민감값이 들어갈 수 있으므로 로그나 이슈에 그대로 붙이지 않는다.
70
+
71
+ ```bash
72
+ nhncloud nks cluster create --file ./cluster-create.json
73
+ nhncloud nks cluster delete <cluster> --yes
74
+ nhncloud nks cluster resize <cluster> --nodegroup worker --node-count 3
75
+ nhncloud nks cluster set-ipacl <cluster> --file ./ipacl.json
76
+ nhncloud nks cluster renew-certificate <cluster> --term-of-validity 3
77
+ nhncloud nks cluster update-sgw <cluster> --ncr-sgw <uuid> --obs-sgw <uuid>
78
+ nhncloud nks cluster set-control-plane-log <cluster> --file ./control-plane-log.json
79
+ ```
80
+
81
+ ## JSON 출력
82
+
83
+ 목록 조회는 배열 또는 목록 객체로 출력한다.
84
+ 단건 조회와 설정 조회는 API raw 객체를 보존하는 쪽을 우선한다.
85
+ 생성, resize, 설정 변경, 노드 action, 애드온 변경은 `{ uuid }` 응답을 반환한다.
86
+ 삭제 명령은 성공 메시지만 stderr에 쓰고 stdout은 비운다.
87
+
88
+ ## 에러 코드
89
+
90
+ | 상황 | exit code |
91
+ |------|-----------|
92
+ | IaaS 자격증명 누락 또는 불완전 | 4 |
93
+ | Keystone 또는 NKS 인증 실패 | 2 |
94
+ | 지원하지 않는 region, payload JSON 파싱 실패, `--yes` 누락 | 3 |
95
+ | NKS API 오류 또는 응답 형식 불일치 | 1 |