게이트웨이 구성 변경 사항 비교
게이트웨이 구성 변경 사항 비교 (deck gateway diff)
deck gateway diff 명령어는 라이브 Kong Gateway 구성과 상태 파일 사이의 차이를 보여줘요. deck gateway sync를 실행하기 전에 변경 내용을 미리 확인하는 드라이 런 용도로 활용하면 좋아요. 또는 상태 파일과 비교해 라이브 시스템에 예상치 못한 변경이 생겼는지 주기적으로 점검하는 드리프트 감지에도 쓸 수 있어요
출처: 문서
본문
deck gateway diff는 주로 예정된 변경 사항을 미리 확인하거나, 라이브 시스템에서 예상치 못한 변경을 감지할 때 사용해요.
드라이런
예정된 변경 사항을 미리 보려면 deck gateway sync를 실행하기 전에 항상 deck gateway diff를 실행하세요. decK는 실제로 sync를 수행하는 것처럼 모든 변경 사항을 처리하고, 마지막에 적용되었을 변경 사항을 보여줘요:
deck gateway diff /path/to/kong.yaml
updating service example-service {
"connect_timeout": 60000,
"enabled": true,
- "host": "httpbin.konghq.com",
+ "host": "httpbin.org",
"id": "c828da95-d684-42d3-8047-43d90552f6e2",
"name": "example-service",
"port": 80,
"protocol": "http",
"read_timeout": 60000,
"retries": 5,
"write_timeout": 60000
}
Summary:
Created: 0
Updated: 1
Deleted: 0
{:.no-copy-code}
diff에서 예상하지 못한 변경이 보이면, 상태 파일이 기대에 맞을 때까지 수정한 다음 deck gateway sync를 실행하기 전에 deck gateway diff를 다시 실행하세요.
드리프트 감지
알려진 상태 파일을 사용해 deck gateway diff를 주기적으로 실행하면 라이브 시스템에서 예상치 못한 변경을 감지할 수 있어요.
실행 중인 Kong Gateway가 기대한 상태와 일치하면 다음과 같은 출력이 표시돼요:
Summary:
Created: 0
Updated: 0
Deleted: 0
{:.no-copy-code}
상태 파일에는 변경이 없는데 라이브 시스템이 변경되었다면, deck gateway diff가 해당 변경을 표시해 주고 deck gateway sync를 실행해서 변경을 되돌릴 수 있어요.
명령어 사용법
Usage:
deck gateway diff [flags] [kong-state-files...]
Flags:
--consumer-group-policy-overrides allow deck to diff consumer-group policy overrides.
This allows policy overrides to work with Kong GW versions >= 3.4
Warning: do not mix with consumer-group scoped plugins
-W, --errors-as-warnings string Treat the given comma-separated diagnostic codes as warnings.
-h, --help help for diff
--include-plugin-definitions allow deck to diff plugin definitions.
Plugin definitions work with Konnect and Gateway versions >= 3.15.
--json-output generate command execution report in a JSON format
--no-mask-deck-env-vars-value do not mask DECK_ environment variable values at diff output.
--non-zero-exit-code return exit code 2 if there is a diff present,
exit code 0 if no diff is found,
and exit code 1 if an error occurs.
--parallelism int Maximum number of concurrent operations. (default 10)
--rbac-resources-only sync only the RBAC resources (Kong Enterprise only).
--select-tag strings only entities matching tags specified via this flag are diffed.
When this setting has multiple tag values, entities must match each of them.
--silence-events disable printing events to stdout
--skip-ca-certificates do not diff CA certificates.
--skip-consumers do not diff consumers or any plugins associated with consumers
--skip-consumers-with-consumer-groups do not show the association between consumer and consumer-group.
If set to true, deck skips listing consumers with consumer-groups,
thus gaining some performance with large configs.
Usage of this flag without apt select-tags and default-lookup-tags can be problematic.
-E, --warnings-as-errors string Treat the given comma-separated diagnostic codes as errors.
-w, --workspace string Diff configuration with a specific workspace (Kong Enterprise only).
This takes precedence over _workspace fields in state files.
--yes yes assume yes to prompts and run non-interactively.
상세한 구성 변경 내용 살펴보기
기본적으로 deck gateway diff는 변경 사항을 한 줄씩 강조하는 unified diff를 출력해요. 이 출력은 빠르게 훑어보기에 최적화되어 있지만, 구성 객체가 크거나 값을 더 자세히 살펴봐야 할 때는 해석하기 어려울 수 있어요.
--json-output 플래그를 사용하면 다음 내용이 포함된 JSON 리포트를 생성할 수 있어요:
- 변경 사항의
summary. 예를 들어 생성, 업데이트, 삭제, 전체 건수 - 작업 유형별로 그룹화된
changes객체 - 업데이트된 각 엔티티에 대한
old와new구성 객체
다음과 같은 경우에는 --json-output을 사용하세요:
- 문제 해결 중에 이전 구성 객체와 새 구성 객체를 각각 살펴봐야 할 때
- 스크립트나 CI 파이프라인에서 diff 출력을 파싱해야 할 때
- 순서 변경이나 큰 객체 때문에 unified diff를 읽기 어려운, 노이즈가 많은 diff를 조사해야 할 때
JSON 출력을 활성화한 상태로 deck gateway diff를 실행해 보세요:
deck gateway diff ./kong.yaml --json-output
--json-output 플래그로 생성된 변경 리포트의 예시예요:
{
"changes": {
"creating": [],
"updating": [
{
"kind": "plugin",
"name": "basic-auth (global)",
"body": {
"old": {
"config": {
"brute_force_protection": {
"redis": {
"timeout": 2000
}
}
}
},
"new": {
"config": {
"brute_force_protection": {
"redis": {
"timeout": 2001
}
}
}
}
}
}
],
"deleting": []
},
"summary": {
"creating": 0,
"updating": 1,
"deleting": 0,
"total": 1
},
"warnings": [],
"errors": []
}
관련 리소스
더 알아보기 (Learn more)
- diff로 확인한 변경 사항을 실제로 적용하는 sync 명령어의 사용 방법을 알아봐요 —
deck gateway sync - deck gateway에서 사용할 수 있는 다른 명령어들도 살펴봐요 — deck gateway commands