본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

decK로 태그 관리

원문 보기 위키 갱신

decK로 태그 관리 (Manage tags with decK)

decK의 deck file 태그 명령어를 사용하면 애플리케이션 팀이 절차를 이해하거나 태그를 일관되게 붙이는 걸 기억할 필요 없이, 설정 계보를 식별하는 태그를 자동으로 추가할 수 있어요. add-tags로 엔티티에 태그를 붙이고, remove-tags로 태그를 지우거나 특정 태그만 남길 수 있으며, list-tags로 태그 목록을 확인할 수 있어요. 태그는 각 팀이 자기 설정을 따로 관리할 수 있게 해 주는 연합 구성 관리(federated configuration)의 핵심 요소이기도 해요

출처: 문서

본문

deck file 태그 명령어를 사용하면 애플리케이션 팀이 프로세스를 이해하고 태그를 일관되게 적용하는 걸 기억하는 데 의존하지 않고도, 설정 계보를 식별하는 태그를 자동으로 추가할 수 있어요.

add-tags

add-tags 명령어는 모든 엔티티에 태그를 추가할 수 있어요. 다음은 제공된 파일의 모든 엔티티에 team-one 태그를 추가하는 예제예요:

deck file add-tags -s ./config.yaml team-one

deck file merge 명령어를 사용해 동기화할 단일 설정을 만들 때 엔티티 소유권을 추적하는 데 유용해요.

특정 엔티티에만 태그를 추가하려면 --selector 플래그를 사용하세요. 제공된 태그는 셀렉터와 일치하는 엔티티에만 추가돼요.

태그를 추가 인자로 제공하면 한 번에 여러 태그를 추가할 수 있어요. 예를 들면: team-one another-tag and-another.

명령어 사용법

Usage:
  deck file add-tags [flags] tag [...tag]

Examples:
# adds tags 'tag1' and 'tag2' to all services in file 'kong.yml'
cat kong.yml | deck file add-tags --selector='services[*]' tag1 tag2

Flags:
      --format string          Output format: json or yaml (default "yaml")
  -h, --help                   help for add-tags
  -o, --output-file string     Output file to write to. Use - to write to stdout. (default "-")
      --selector stringArray   JSON path expression to select objects to add tags to.
                               Defaults to all Kong entities. Repeat for multiple selectors.
  -s, --state string           decK file to process. Use - to read from stdin. (default "-")

remove-tags

add-tags의 반대인 remove-tags는 설정 파일에서 태그를 삭제할 수 있게 해줘요. 기본적으로는 제공된 태그만 제거해요:

deck file remove-tags -s ./config.yaml tag_to_remove

특정 태그를 유지하고 나머지는 모두 제거하려면 --keep-only 플래그를 사용하세요:

deck file remove-tags -s ./config.yaml --keep-only env-prod team-one

마지막으로, 특정 엔티티에서 태그를 제거하려면 --selector를 전달하면 돼요. 필요에 따라 --keep-only와 조합할 수도 있어요:

deck file remove-tags -s ./config.yaml \
  --selector "$..services[*]" \
  --keep-only env-prod team-one

명령어 사용법

Usage:
  deck file remove-tags [flags] tag [...tag]

Examples:
# clear tags 'tag1' and 'tag2' from all services in file 'kong.yml'
cat kong.yml | deck file remove-tags --selector='services[*]' tag1 tag2

# clear all tags except 'tag1' and 'tag2' from the file 'kong.yml'
cat kong.yml | deck file remove-tags --keep-only tag1 tag2

Flags:
      --format string          Output format: json or yaml (default "yaml")
  -h, --help                   help for remove-tags
      --keep-empty-array       Keep empty tag arrays in output.
      --keep-only              Setting this flag will remove all tags except the ones listed.
                               If none are listed, all tags will be removed.
  -o, --output-file string     Output file to write. Use - to write to stdout. (default "-")
      --selector stringArray   JSON path expression to select objects to remove tags from.
                               Defaults to all Kong entities. Repeat for multiple selectors.
  -s, --state string           decK file to process. Use - to read from stdin. (default "-")

list-tags

list-tags 명령어는 파일에서 발견된 모든 태그를 출력해요. 최소 하나의 엔티티에 적용된 태그는 모두 반환돼요.

deck file list-tags -s ./config.yaml

명령어 사용법

Usage:
  deck file list-tags [flags]

Examples:
# list all tags used on services
cat kong.yml | deck file list-tags --selector='services[*]'

Flags:
      --format string          Output format: json, yaml, or PLAIN (default "PLAIN")
  -h, --help                   help for list-tags
  -o, --output-file string     Output file to write to. Use - to write to stdout. (default "-")
      --selector stringArray   JSON path expression to select objects to scan for tags.
                               Defaults to all Kong entities. Repeat for multiple selectors.
  -s, --state string           decK file to process. Use - to read from stdin. (default "-")

관련 리소스

더 알아보기 (Learn more)

  • 태그가 연합 구성 관리의 중심에 있는 이유를 설명해 주는 문서예요 — federated configuration management
  • 여러 설정을 하나로 합칠 때 태그로 엔티티 소유를 추적하는 방법을 보여주는 문서예요 — deck file merge
  • Kong Gateway에서 태그가 어떻게 동작하는지 넓게 이해하고 싶을 때 좋은 문서예요 — Gateway tags