kongctl sync
kongctl sync는 설정 파일을 원하는 상태 그대로 적용하는 명령으로, 리소스를 생성하고 업데이트할 뿐만 아니라 명시적으로 범위가 지정된 컬렉션에서 빠진 관리 리소스는 삭제까지 처리해요. 삭제 없이 생성과 업데이트만 하고 싶다면 kongctl apply를 사용하면 돼요. 이 문서에서는 YAML 키 존재 여부로 동기화 범위가 정해지는 규칙과 외부 부모 리소스 패턴, dry-run 같은 실전 예시를 함께 살펴봐요
출처: 문서
본문
리소스를 삭제하지 않고 구성을 적용하고 싶다면(생성과 업데이트만), 대신 kongctl apply를 사용하세요.
kongctl sync의 작동 방식
동기화 범위는 YAML 키의 존재 여부를 기준으로 결정돼요:
- 생략된 리소스 컬렉션은 무시돼요.
- 루트 레벨에서 명시적으로 빈 리스트를 지정하면 원하는 개수가 0이라는 뜻이에요. 예를 들어,
apis: []는 선택된 네임스페이스에서 관리되는 API를 삭제해요. - 부모 컬렉션과 자식 컬렉션은 각각 별도로 범위가 지정돼요.
pages가 없는portal블록은 Dev Portal 페이지를 삭제하지 않아요. Dev Portal에 페이지가 없어야 한다는 것을 선언하려면 해당portal블록 아래에pages: []를 사용하세요. - 맵 형태의 자식 컬렉션은 빈 객체를 빈 컬렉션으로 사용해요. 예를 들어,
email_templates: {}는 Dev Portal에 사용자 지정 이메일 템플릿이 없어야 한다는 뜻이에요. - 싱글턴 자식 섹션도 동일한 키 존재 여부 규칙을 따르지만,
{}와null은 의도적으로 다르게 취급돼요. 해당 자식을 무시하려면 싱글턴 키를 생략하세요. 관리하거나 업데이트하려면 필드가 포함된 객체를 제공하세요.custom_domain,email_config,audit_log_webhook같은 선택적이며 삭제 가능한 Dev Portal 싱글턴의 경우, 빈 객체는 원하는 개수가 0인 상태로 자식의 범위를 지정해요. 즉,custom_domain: {}는 동기화 중에 해당 Dev Portal의 기존 관리형 사용자 지정 도메인을 삭제해요.null은 동기화가 null로부터 리셋 또는 삭제 의미를 추론하지 않기 때문에 거부돼요.customization같은 업데이트 전용 싱글턴 섹션은{}를 선언한다고 해서 삭제할 수 없어요. - 빈 자식 컬렉션은 반드시 부모 리소스 아래에 중첩돼야 해요. 루트 레벨의
api_documents: []는 원하는 개수가 0이라는 것이 어떤 API에 해당하는지 식별하지 못하기 때문에 거부돼요.
연합 소유(federated ownership)의 경우, 팀 구성에 부모 리소스 항목을 포함하고 해당 팀이
소유한 자식 컬렉션만 범위로 지정하세요. 부모가 다른 곳에서 관리되고 리소스 타입이
_external을 지원한다면, 부모를 external로 선언하고 그 부모 아래에 자식 컬렉션을
중첩하세요. 이렇게 하면 sync가 팀의 네임스페이스에 있는 관리형 부모 컬렉션을
원하는 상태로 취급하지 않으면서 자식 컬렉션에 대한 계획을 세울 수 있어요.
apis:
- ref: orders-api
name: Orders API
documents: []
portals:
- ref: shared-docs-portal
_external:
selector:
matchFields:
name: "Shared Docs Portal"
pages: []
external 부모 패턴은 팀이 해당 네임스페이스에서 관리형 부모 리소스의 범위까지 지정하려는 의도가 없다면 네임스페이스 기본값과 함께 사용하면 안 돼요.
예제
동기화 변경 사항 미리 보기:
kongctl sync -f config.yaml --dry-run
확인 프롬프트와 함께 구성 동기화:
kongctl sync -f team-config.yaml
확인 프롬프트를 건너뛰고 승인 없이 변경 사항 동기화:
--auto-approve플래그를 사용할 때는 주의하세요. 이 명령은 미리 보기나 확인 없이 엔티티를 생성, 업데이트, 삭제해요.
kongctl sync -f config.yaml --auto-approve
플랜 아티팩트에서 동기화:
kongctl sync --plan plan.json
하위 명령어
kongctl은 구성을 동기화하기 위한 다음 도구를 제공해요:
kongctl sync konnect
설명: Konnect와 동기화해요.
명령어 사용법
Usage:
kongctl sync [flags]
kongctl sync [command]
Examples:
# Synchronize Konnect resources from declarative configuration
kongctl sync -f api.yaml
# Synchronize using the explicit Konnect target form
kongctl sync konnect -f api.yaml
# Generate and execute a reviewed sync plan without prompting
kongctl plan --mode sync -f config.yaml --output-file plan.json
kongctl sync --plan plan.json --auto-approve
Available Commands:
konnect Synchronize declarative configuration to Konnect
Flags:
--auto-approve Skip confirmation prompt
--base-dir string Base directory boundary for !file resolution.
Defaults to each -f source root (file: its parent dir, dir: the directory itself). For stdin and URLs, defaults to CWD.
- Config path: [ konnect.declarative.base-dir ]
--base-url string Base URL for Konnect API requests.
- Config path: [ konnect.base-url ]
- Default : [ https://us.api.konghq.com ]
--color-theme string Configures the CLI UI/theme (prompt, tables, TUI elements).
- Config path: [ color-theme ]
- Examples : [ auto, 3024_day, 3024_night, aardvark_blue, abernathy ]
- Reference : [ https://github.com/lrstanley/bubbletint/blob/master/DEFAULT_TINTS.md ] (default "auto")
--config-file string Path to the configuration file to load.
- Environment variable: KONGCTL_CONFIG_FILE (overridden by this flag)
- Default: [ $XDG_CONFIG_HOME/kongctl/config.yaml ]
--dry-run Preview changes without applying them
--execution-report-file string Save execution report as JSON to file
-f, --filename strings File, directory, URL, or '-' to use to create the resource (can specify multiple)
-h, --help help for sync
--http-retry-backoff-factor float Exponential backoff growth factor for retries (for example: 2.0).
- Config path: [ konnect.http-retry-backoff-factor ]
--http-retry-initial-interval int Initial retry backoff interval in milliseconds (0 = use default).
- Config path: [ konnect.http-retry-initial-interval ]
--http-retry-max-attempts int Maximum total attempts for retryable HTTP requests (0 = use default, 1 disables retries).
- Config path: [ konnect.http-retry-max-attempts ]
--http-retry-max-interval int Maximum retry backoff interval in milliseconds (0 = use default).
- Config path: [ konnect.http-retry-max-interval ]
--http-retry-on-connection-errors Retry selected retryable connection-level errors.
- Config path: [ konnect.http-retry-on-connection-errors ]
--log-file string Write execution logs to the specified file instead of STDERR.
- Config path: [ log-file ]
--log-level string Configures the logging level. Execution logs are written to STDERR.
- Config path: [ log-level ]
- Allowed : [ trace|debug|info|warn|error ] (default "error")
--max-concurrency int Maximum number of concurrent API operations during execution (min 1, max 200).
When the plan contains execution_groups, operations within each group run
concurrently up to this limit. Use 1 for sequential execution.
- Config path: [ konnect.declarative.max-concurrency ] (default 5)
--no-telemetry Disable telemetry for this command invocation. Overrides config and env.
- Config path: [ telemetry.enabled ]
- Env var : [ KONGCTL_NO_TELEMETRY ]
- Default : [ false ]
--no-trunc Preserve full cell widths in static text tables beyond terminal width.
Does not change column selection, UUID formatting, or explicit string slices.
- Config path: [ text.no-trunc ]
- Default : [ false ]
-o, --output string Configures the format of data written to STDOUT.
- Config path: [ output ]
- Allowed : [ json|yaml|text ] (default "text")
--pat string Konnect Personal Access Token (PAT) used to authenticate the CLI.
Setting this value overrides tokens obtained from the login command.
- Config path: [ konnect.pat ]
--plan string Path to existing sync-mode plan file
-p, --profile string Specify the profile to use for this command. (default "default")
-R, --recursive Process the directory used in -f, --filename recursively
--region string Konnect region identifier (for example "eu"). Used to construct the base URL when --base-url is not provided.
- Config path: [ konnect.region ]
--remote-file-auth string Authentication mode for remote -f URL sources (auto|none).
In auto mode, kongctl sends the current Konnect bearer token only to HTTPS Konnect hosts.
- Config path: [ konnect.declarative.remote-file-auth ] (default "auto")
-s, --remote-file-save-dir string Save remote -f URL sources into this local directory before loading
-F, --remote-file-save-force Overwrite existing files when saving remote -f URL sources with --remote-file-save-dir
--require-any-namespace Require explicit namespace on all resources (via kongctl.namespace or _defaults.kongctl.namespace).
Cannot be used with --require-namespace.
- Config path: [ konnect.declarative.require-any-namespace ]
--require-namespace strings Require specific namespaces. Accepts comma-separated list or repeated flags.
Cannot be used with --require-any-namespace.
Examples:
--require-namespace=foo # Allow only 'foo' namespace
--require-namespace=foo,bar # Allow 'foo' or 'bar' (comma-separated)
--require-namespace=foo --require-namespace=bar # Allow 'foo' or 'bar' (repeated flags)
- Config path: [ konnect.declarative.require-namespace ]
--text-id-format string Configure UUID rendering in static text-table ID columns.
- Config path: [ text.id-format ]
- Allowed : [ compact|full ]
- Default : [ compact ]
--text-layout string Configure static text-table column selection.
- Config path: [ text.layout ]
- Allowed : [ compact|auto|wide ]
- Default : [ compact ]
--write-secret stringArray Write configured secrets selected by [resource-type:]resource-ref[#field] (repeatable)
--write-secrets Write all eligible configured write-only secrets, warning when fields are skipped
Use "kongctl sync [command] --help" for more information about a command.
관련 리소스
더 알아보기 (Learn more)
- 삭제 없이 생성과 업데이트만 적용하는 대안 명령 —
kongctl apply - Konnect 대상으로 sync를 실행하는 하위 명령 — kongctl sync konnect
- sync로 적용할 선언형 설정 파일을 작성하는 방법 — Declarative configuration with kongctl
- kongctl 설치부터 기본 사용법까지 다루는 입문 가이드 — Get started with kongctl