콘텐츠로 이동
AggregaAggrega
언어 선택: 한국어
이 페이지는 기계 번역되었습니다. 영어 원문 읽기.

Compose 프로젝트 가져오기

이 안내에서는 작은 Compose 프로젝트(API, 그 API가 메모를 보관하는 PostgreSQL 데이터베이스, Redis 캐시)를 가져와 그 결과를 Docker Compose용으로 빌드합니다. 가져오기는 빌드가 읽는 모든 파일의 초안을 작성하며, Compose 파일이 명시한 내용을 그대로 옮겨 옵니다. 즉, API에서 데이터베이스와 캐시로의 연결, 데이터베이스의 사용자와 이름, 변수 참조로서의 비밀번호, 그리고 각 이미지의 태그입니다. 아래의 모든 파일과 모든 출력 블록은 실제 실행에서 나온 것입니다. 프로젝트와 안내의 각 단계는 import-compose 예제에 있으며, 그곳의 검사 스크립트가 가져오기를 다시 실행하고, 그것이 쓰는 내용, 출력하는 내용, 이 페이지가 인용하는 블록을 그곳에 보관된 파일과 비교하며, 가져오기가 작성한 것을 검증하고 빌드합니다.

예제 생성하기

이 페이지의 명령으로 이 가져오기를 실행하거나, AI 어시스턴트가 대신 실행하게 할 수 있습니다.

예제 이름을 딴 새 폴더에 예제를 씁니다:

Terminal window
aggrega scaffold --example import-compose

그런 다음 이어서 실행할 명령을 출력합니다. 첫 번째 명령은 새 폴더로 이동합니다. 그 뒤의 명령은 아래와 같으며, 새 폴더 안의 source 폴더로 이동합니다. 이 폴더에는 이 페이지가 가져오는 내용이 들어 있으며, 가져오기는 여기서 실행됩니다:

Terminal window
cd import-compose

Visual Studio Code에서 연, 스캐폴드한 예제의 source 폴더. Compose 파일이 표시되어 있으며, 노트 서비스의 API, 그 PostgreSQL 데이터베이스, 그 Redis 캐시를 담고 있습니다.

프로젝트

compose.yaml:

# A small notes service: its API, the PostgreSQL database it keeps the notes in,
# and the Redis cache in front of it.
name: notes
services:
api:
image: ghcr.io/example/notes-api:2.3.0
ports:
- "8080:8080"
environment:
DATABASE_HOST: db
DATABASE_USER: notes
DATABASE_NAME: notes
DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
CACHE_HOST: cache
depends_on:
- db
- cache
db:
image: postgres:16
environment:
POSTGRES_USER: notes
POSTGRES_DB: notes
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- db-data:/var/lib/postgresql/data
cache:
image: redis:7
volumes:
db-data:

그 옆에 있는 .aggrega-config.yaml이 폴더를 작업 공간으로 만들므로, 가져오기는 초안을 그곳에 씁니다:

# The workspace key marks this directory as the workspace root, so an import run
# here writes its drafts beside compose.yaml.
workspace: {}
# The registry the importer is fetched from the first time an import needs it.
default_registry: hub.aggrega.ai

가져오기는 각 서비스를 작업 공간 카탈로그의 Components와 비교하고, --target은 카탈로그의 Recipes로부터 Manifest 초안을 작성합니다. 작업 공간이 카탈로그 폴더를 지정하지 않으므로, 가져오기는 임포터를 가져오는 레지스트리에서 표준 라이브러리 카탈로그를 읽습니다. 이는 게시된 카탈로그의 서명된 스냅샷으로, 첫 가져오기가 가져와 검증한 뒤 작업 공간의 콘텐츠 캐시에 보관하며, 가져오기가 초안 옆에 쓰는 기록에 다이제스트로 지정됩니다. 자체 카탈로그 폴더를 — AGGREGA_CATALOG_DIRS에서, 또는 workspace.catalog_dirs 아래에서 — 지정한 작업 공간은 대신 그 폴더들에 대해 가져옵니다.

응답 파일

Docker Compose용 빌드에는 Compose 파일에 명시되지 않은 것이 전혀 필요하지 않으므로, 이 가져오기는 아무것도 묻지 않습니다. 같은 프로젝트를 --target helm으로 Kubernetes용으로 빌드하려면 어떤 Compose 파일에도 없는 값 하나가 필요합니다. 데이터베이스 비밀번호를 읽어 오는 Kubernetes Secret의 이름입니다. Kubernetes 빌드는 비밀번호를 셸이 아니라 Secret에서 읽기 때문입니다. 이 예제는 그 응답을 compose.yaml 옆의 import-answers.yaml에 보관하며, 가져오기는 그곳에서 응답을 찾습니다:

# Values the import could not draft from the source, keyed by the drafted file and the key path inside
# it. Write each one beside its key; an import of the same source, and a sync, read them from here and
# ask nothing. A secret is never written here: its key asks where the secret comes from — a variable
# name, ${NAME}, or the name of a Kubernetes Secret.
release.yaml:
# The origin of the secret value, written by the operator in the Release. Read exactly as
# values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes
# from, never the value.
spec.components.db.features.password.infra.origin: "notes-db-password"

이 파일은 --target helm으로 처음 실행했을 때 가져오기가 직접 작성했습니다. 초안을 작성할 수 없었던 값을 키를 비워 둔 채 나열하고 멈추었습니다. 응답은 Secret의 이름이며, 비밀번호가 아닙니다. Docker Compose용 가져오기는 그런 값을 요구하지 않으며, 응답을 파일에 그대로 두고 사용하지 않습니다. 가져오기 응답 파일에서는 이 파일, 가져오기가 대신 터미널에서 묻는 질문, 그리고 둘 다 없을 때 가져오기가 하는 일을 설명합니다.

aggrega import에는 다른 곳에 보관된 응답 파일을 지정하는 --answers를 비롯하여 이 명령이 받는 모든 플래그가 나열되어 있습니다.

source로 이동합니다:

Terminal window
cd source

가져오기 실행

Terminal window
aggrega import compose.yaml --target compose

표준 출력에는 작성한 것을 나열합니다:

wrote aggregate.yaml
wrote release.yaml
wrote manifest.yaml
wrote .aggrega-import.json

표준 오류에는 다음과 같이 출력합니다. 여기서 <workspace>는 명령을 실행한 폴더를 나타냅니다:

[… omitted: a warning that the importer runs unverified, printed where its module is read from beside its Plugin entity in a catalog folder rather than fetched]
read as the compose format, with drafted paths relative to <workspace>
warn: the value of environment.POSTGRES_USER of node db is carried as written in the drafts: its format marks the field as no credential, though it can carry one, and setting empty_credentials to all writes it empty
warn: the value of environment.POSTGRES_DB of node db is carried as written in the drafts: its format marks the field as no credential, though it can carry one, and setting empty_credentials to all writes it empty
mapped api (ghcr.io/example/notes-api) to core/compute/server as a reference, NONE
mapped db (postgres) to core/datastore/postgres as a reference, HIGH at 0.9
mapped cache (redis) to core/datastore/redis as a reference, HIGH at 0.9
Pull complete: <workspace>/release.lock (entities=10, source_artifacts=0, external_inputs=0)

편집기에서 실행한 가져오기: 초안 Aggregate, Release, Manifest가 Compose 파일 옆에 나타나고, Aggrega 출력이 각 서비스가 매핑된 방식과 작성된 파일을 나열하며, 알림이 가져오기가 파일 3개를 초안으로 작성했고 compose로 인식했다고 알려 줍니다.

  • warn 줄은 초안이 작성된 그대로 담고 있는 각 값을 값이 아니라 서비스와 변수로 지목합니다. Compose는 어떤 값도 자격 증명으로 표시하지 않으며, 그중 어느 것이든 자격 증명을 담고 있을 수 있습니다. 여기서는 둘 다 담고 있지 않습니다. API가 다른 서비스에서 읽는 변수는 아예 값으로 담기지 않으며 — 연결이 이를 전달합니다 — ${POSTGRES_PASSWORD}로 되어 있는 두 변수는 변수 참조일 뿐이므로 어떤 경고도 이를 지목하지 않습니다.
  • mapped 줄은 각 서비스가 무엇이 되었는지를 알려 줍니다. api는 자체 이미지를 실행하므로 표준 라이브러리의 범용 서버인 core/compute/server의 인스턴스입니다. db와 cache는 표준 라이브러리의 Compose Recipes가 core/datastore/postgres와 core/datastore/redis를 위해 실행하는 이미지를 실행합니다. 각각 높은 등급에서 0.9로 해당 Component와 일치했으며, 초안은 그 Component를 참조합니다.
  • Pull complete 줄은 가져오기가 초안으로 작성된 Release가 의존하는 것을 aggrega pull처럼 release.lock으로 가져오는 것으로, 초안을 즉시 검증하고 빌드할 수 있게 합니다. --offline에서는 가져오기가 아무것도 가져오지 않고 실행할 aggrega pull을 알려 줍니다.

작성하는 내용

Aggregate, Release, Manifest의 이름은 imported/notes이며, Compose 프로젝트의 name:에서 따옵니다. name:이 없는 Compose 파일은 파일 이름인 compose를 따르고, 그 파일이 들어 있는 디렉터리를 디렉터리로 가져온 경우에는 그 디렉터리 이름을 따릅니다. 이는 Compose가 프로젝트에 이름을 붙이는 방식과 같습니다. 네임스페이스는 임포터의 target_namespace 설정이 정하며, 다른 값을 설정하지 않으면 imported입니다(설정).

aggregate.yaml — 서비스마다 하나의 항목, API의 환경이 값을 가져오는 연결, 그리고 Compose 파일이 설정하는 값과 비밀번호:

# Not carried, since the draft reads the services and the models alone: volumes.
apiVersion: aggrega.ai/v1beta1
kind: Aggregate
metadata:
name: imported/notes
version: 0.1.0
description: Draft Aggregate imported from a source in the compose format.
spec:
components:
api:
type: core/compute/server
features:
# For the compose target, the lines below declare database_password on api: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none.
database_password:
type: core/secret-value
values:
key: DATABASE_PASSWORD
uses:
cache:
cache:
target: cache
# The variables the source sets to what cache publishes, delivered from it under the names the source gives them.
inject:
env:
- in: "CACHE_HOST"
from: host
db:
db:
target: db
# The variables the source sets to what db publishes, delivered from it under the names the source gives them.
inject:
env:
- in: "DATABASE_HOST"
from: host
- in: "DATABASE_USER"
from: user
- in: "DATABASE_NAME"
from: database
db:
type: core/datastore/postgres
# The values of core/datastore/postgres the source sets as POSTGRES_USER, POSTGRES_DB, the variables its Compose Recipes set from them.
values:
user: "notes"
database: "notes"
features:
# For the compose target, the lines below declare password on db: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none.
password:
type: core/secret-value
values:
key: POSTGRES_PASSWORD
cache:
type: core/datastore/redis

다른 서비스를 가리키는 API의 각 변수는 해당 연결의 inject 블록이 됩니다. Compose 파일은 DATABASE_HOST를 db로 설정했고, 연결은 데이터베이스가 게시하는 host를 그 이름으로 전달하므로, 복사되는 대신 어떤 대상에서든 데이터베이스를 따릅니다. DATABASE_USER와 DATABASE_NAME은 PostgreSQL 서비스를 생성할 때 사용한 사용자 및 데이터베이스와 일치했으므로, 이들 역시 그 서비스가 게시하는 내용으로부터 전달되며, 이 두 값은 데이터베이스 자체의 values가 됩니다. 각 비밀번호는 core/secret-value 첨부가 되며, 해당 변수를 읽는 키로 선언됩니다.

release.yaml — 환경, API의 이미지와 포트, 각 데이터 저장소의 엔진 버전, 그리고 각 비밀번호의 출처:

apiVersion: aggrega.ai/v1beta1
kind: Release
metadata:
name: imported/notes
# environment is a drafted default, since no source names the environment this Release deploys to; change it to name the one it deploys to.
environment: development
version: 0.1.0
description: Draft Release imported from a source in the compose format.
spec:
aggregate: imported/notes
manifest: imported/notes
components:
# The source also states, for the Release to carry where core/compute/server takes it:
# ports:
# - "8080:8080"
api:
infra:
image: "ghcr.io/example/notes-api:2.3.0"
port: 8080
# Published on this machine's loopback address, 127.0.0.1: reachable from this machine only, by any process running on it. Delete this line to keep the service internal.
published_port: 8080
features:
database_password:
type: core/secret-value
infra:
# Attached by reference, never as a value: the value api reads as DATABASE_PASSWORD, read from the variable POSTGRES_PASSWORD, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value.
origin: "${POSTGRES_PASSWORD}"
# The source states, for the Release to carry where core/datastore/postgres takes it:
# volumes:
# - "db-data:/var/lib/postgresql/data"
db:
infra:
# The tag of the image the source runs, postgres:16, the engine_version of core/datastore/postgres its Compose Recipes run.
engine_version: "16"
features:
password:
type: core/secret-value
infra:
# Attached by reference, never as a value: the password of db, which the source sets as POSTGRES_PASSWORD, read from the variable POSTGRES_PASSWORD, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value.
origin: "${POSTGRES_PASSWORD}"
cache:
infra:
# The tag of the image the source runs, redis:7, the engine_version of core/datastore/redis its Compose Recipes run.
engine_version: "7"

환경 development는 어떤 Compose 파일도 환경을 지정하지 않기 때문에 가져오기가 작성하는 기본값입니다. Release를 다른 곳에 배포하는 경우 변경하십시오. 이미지 태그는 표준 라이브러리 Components가 받는 엔진 버전이 됩니다. API의 port는 그 컨테이너가 수신 대기하는 포트이고, published_port는 그 ports 항목이 게시하는 호스트 포트이며, 둘 다 Compose 파일에 적힌 대로 8080입니다. 주석에서 말하듯이, 이 머신의 모든 프로세스는 http://127.0.0.1:8080에서 API에 도달할 수 있고 그 밖의 어떤 것도 도달할 수 없으며, 이 줄을 삭제하면 API는 스택의 네트워크에만 남습니다. 어떤 키도 받지 않는 항목은 해당 항목 위에 주석으로 남습니다. port와 published_port가 이미 담고 있는 소스의 ports 항목과 데이터베이스의 명명된 볼륨입니다.

manifest.yaml — 각 컴포넌트 유형의 Compose Recipe, 그리고 비밀번호의 변수 참조를 작성된 그대로 Compose 파일에 쓰는 실현:

apiVersion: aggrega.ai/v1beta1
kind: Manifest
metadata:
name: imported/notes
version: 0.1.0
spec:
mappings:
components:
type:
core/compute/server: compose/server
core/datastore/postgres: compose/postgres
core/datastore/redis: compose/redis
features:
type:
core/secret-value: compose/dotenv-secret

release.lock은 Release가 해석된 카탈로그 엔터티를 다이제스트로 기록하며, .aggrega-import.json은 가져오기가 작성한 내용의 기록으로, 이후의 aggrega import --sync가 이를 읽습니다.

검증 및 빌드

Terminal window
aggrega validate --release release.yaml
aggrega build --release release.yaml

검증한 뒤 편집기에서 연 초안 Release. Aggrega 출력과 알림이 모두 문제가 발견되지 않았다고 보고합니다.

초안 Release의 빌드: 탐색기에 dist 폴더가 나타나고, Aggrega 출력이 작성된 Docker Compose 파일을 나열하며, 알림이 파일 1개가 작성되었다고 알려 줍니다.

검증 결과는 다음과 같습니다:

notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
release dependency validation passed: release.yaml (schema-pillar + dependency pillars)

그리고 빌드는 다음과 같습니다. 여기서 <workspace>는 실행한 폴더를 나타냅니다:

notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)
[… omitted: a total build time, which differs per run]
Build completed: 1 file written to <workspace>/dist

notice 줄은 참고용입니다. 비밀번호 Feature는 Aggregate의 values 또는 Release의 infra에서 origin을 받으며, 이 알림은 한 리프가 양쪽 모두에 선언되어 있음을 보고합니다. 판정은 바뀌지 않습니다.

dist/compose/docker-compose.yaml의 api 서비스는 Compose 프로젝트가 제공한 환경을 읽으며, 그 환경은 연결과 비밀번호 첨부를 통해 전달됩니다:

api:
image: ghcr.io/example/notes-api:2.3.0
environment:
CACHE_HOST: cache
DATABASE_HOST: db
DATABASE_NAME: notes
DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
DATABASE_USER: notes
ports:
- 127.0.0.1:8080:8080
[… omitted: the labels the build writes on every service, naming the Aggregate, the component, the environment and the compiler's version]
networks:
- compose
depends_on:
- cache
- db
[… omitted: the CPU and memory the server's defaults reserve]

그리고 데이터베이스와 캐시는 Compose 파일이 지정한 이미지를 실행합니다:

db:
image: postgres:16
environment:
POSTGRES_USER: notes
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: notes
[… omitted: the labels, the network and a health check running PostgreSQL's pg_isready]
cache:
image: redis:7
[… omitted: the labels, the network and a health check running redis-cli ping]

처음 시작한 프로젝트와의 차이 두 가지가 렌더링된 파일에 드러납니다. 포트는 범용 서버의 Compose Recipe가 게시하는 방식대로 루프백 주소에만 게시됩니다. 그리고 Compose 파일이 데이터베이스 데이터용으로 마운트한 명명된 볼륨은 어디에도 나타나지 않습니다. 초안은 이를 데이터베이스 항목 위의 주석에 나열하고, PostgreSQL Component의 어떤 키도 이를 받지 않으며, 렌더링된 데이터베이스 서비스는 볼륨을 마운트하지 않습니다.

AI 어시스턴트 사용

Aggrega의 도구로 설정된 AI 어시스턴트도 같은 일을 할 수 있습니다. 다음 프롬프트를 붙여 넣으십시오.

Aggrega 도구만 사용하고 폴더는 직접 만들지 마십시오. Workspace 폴더에 아직 `import-compose` 폴더가 없으면 `example`을 `import-compose`로 설정하고 `dir` 없이 `scaffold` 도구를 한 번 호출하십시오. 이 도구는 예제를 새 `import-compose` 폴더에 작성하며, 그 `source` 폴더에 이 페이지가 가져오는 내용이 들어 있습니다. 그런 다음 `workspace_root`를 `import-compose/source`로, `source`를 `compose.yaml`로, `target`을 `compose`로 설정하여 `import` 도구를 호출하십시오. 이 도구는 필요한 답변을 `compose.yaml` 옆의 `import-answers.yaml`에서 읽고, 초안을 `import-compose/source`에 작성하며, 초안에 필요한 것을 가져옵니다. 그런 다음 `workspace_root`를 `import-compose/source`로, `release`를 `release.yaml`로 설정하여 `validate` 도구를 호출하고, `workspace_root`를 `import-compose/source`로, `release`를 `release.yaml`로, `write`를 true로 설정하여 `build` 도구를 호출하십시오. 빌드가 작성한 파일이 무엇인지 알려 주십시오. 파일은 `import-compose/source/dist/` 아래에 있습니다.

VS Code에서 열기

Visual Studio Code용 Aggrega 확장을 설치한 상태에서, 가져오기가 초안을 작성한 폴더 import-compose/source를 VS Code에서 엽니다. 이 폴더에는 Release가 하나, 즉 초안 release.yaml만 있으므로 편집기가 이를 자동으로 선택하고, 초안을 편집하는 동안 그 Release에 대해 검사하여 발견한 내용을 파일과 문제 패널에 표시합니다. 명령 팔레트의 Aggrega: Show topology graph는 Release의 구성 요소와 그 사이의 연결을 그립니다. Aggrega: Build, Aggrega: Preview build, Aggrega: Pull은 같은 Release에 대해 작동하며, 각각은 작업 표시줄에 있는 Aggrega 뷰의 Commands 패널 버튼이기도 합니다. Build는 파일을 폴더의 dist/에 작성합니다. 나머지는 Visual Studio Code에서 Aggrega 사용하기에서 다룹니다.

실행하기

ghcr.io/example/notes-api:2.3.0은 자체 API의 이미지를 나타냅니다. 이는 자리 표시자이며, Docker Compose는 여기서 Error Head "https://ghcr.io/v2/example/notes-api/manifests/2.3.0": denied와 함께 중지됩니다. release.yaml에서 api의 infra.image에 자체 API의 이미지를 지정하십시오. API가 준비될 때까지는 포트 8080에서 HTTP로 응답하는 이미지로 대신할 수 있습니다. 아래 실행에서는 mendhak/http-https-echo:39를 사용했으며, 이 이미지는 모든 요청에 받은 요청의 설명으로 응답합니다:

api:
infra:
image: "mendhak/http-https-echo:39"
port: 8080

변경 사항을 적용해 다시 빌드합니다. Release가 가져오기가 쓴 release.lock과 더 이상 일치하지 않으므로, 빌드에는 이를 다시 해석하는 --auto-pull이 필요합니다. 이 옵션이 없으면 빌드가 멈추고 aggrega pull을 지목합니다. Docker Compose는 두 ${POSTGRES_PASSWORD} 참조를 셸에서 채우므로, 스택을 시작하기 전에 암호를 설정하십시오. 설정하지 않으면 Compose는 The "POSTGRES_PASSWORD" variable is not set. Defaulting to a blank string.라고 경고하고 그 자리에 빈 값을 씁니다.

Terminal window
aggrega build --release release.yaml --auto-pull
export POSTGRES_PASSWORD='a password of your own'
docker compose -p notes -f dist/compose/docker-compose.yaml up -d --wait

-p는 가져오기 실행 방식의 실행 단계에서 설명하듯이 프로젝트 이름을 지정합니다. --wait는 데이터베이스와 캐시가 빌드가 부여한 상태 검사를 통과하고 API의 컨테이너가 실행 중이 되면 반환됩니다. 빌드는 API에 상태 검사를 부여하지 않습니다.

테스트하기

published_port가 게시하는 주소인 http://127.0.0.1:8080에서 API에 요청합니다.

Terminal window
curl -sS http://127.0.0.1:8080/notes
{
"path": "/notes",
"headers": {
"host": "127.0.0.1:8080",
[… omitted: the user agent and the media types the client sent]
},
"method": "GET",
[… omitted: the rest of the request as the stand-in received it, the client's address and the container's host name]
}

연결이 전달하는 값은 API 서비스의 환경에, API가 읽는 이름으로 들어 있습니다:

Terminal window
docker compose -p notes -f dist/compose/docker-compose.yaml exec api printenv DATABASE_HOST DATABASE_USER DATABASE_NAME CACHE_HOST
db
notes
notes
cache

다음 명령으로 스택을 중지합니다:

Terminal window
docker compose -p notes -f dist/compose/docker-compose.yaml down

Kubernetes에서

같은 프로젝트를 --target helm으로 Kubernetes용으로 가져올 수 있으며, 가져오기는 Secret의 이름 notes-db-password를 위의 답변 파일에서 읽습니다. Docker Compose용 초안은 이미 source에 있으므로, 이 초안은 별도의 폴더에 작성하고 Docker Compose와 마찬가지로 그 release.yaml에 API의 이미지를 적은 뒤 그 폴더에서 빌드합니다.

Terminal window
aggrega import compose.yaml --target helm --output-dir helm
cd helm
aggrega build --release release.yaml --auto-pull

빌드는 작업 공간 루트 source의 dist/helm/ 아래에 일반 Kubernetes 매니페스트를 작성하며, 이는 helm에서 보면 ../dist/helm/입니다. 적용할 네임스페이스에 데이터 키 value 아래에 비밀번호를 담은 Secret notes-db-password를 만들고, 가져오기 실행 방식의 실행 단계에서 설명하는 대로 폴더를 적용합니다. API의 Service는 api-default입니다. 로컬 포트를 그쪽으로 포워딩하고 명령을 실행 상태로 둡니다.

Terminal window
kubectl port-forward -n <namespace> svc/api-default 8080:8080

다른 터미널에서 위의 요청은 변경 없이 같은 주소의 API에 도달하며, 대체 이미지도 같은 방식으로 "host": "127.0.0.1:8080"이라고 응답합니다. 연결은 Service의 이름을 전달합니다. kubectl exec -n <namespace> deploy/api -- printenv DATABASE_HOST DATABASE_USER DATABASE_NAME CACHE_HOST는 db-default, notes, notes, cache-default를 출력합니다. Kubernetes에서는 API가 아직 데이터베이스 비밀번호를 받지 않습니다. Secret notes-db-password는 데이터베이스에만 도달하므로, api 컨테이너에는 DATABASE_PASSWORD가 설정되지 않습니다.

Compose 파일이 변경될 때

.aggrega-import.json을 초안 옆에 보관하고, Compose 파일이 변경된 후 다음을 실행합니다:

Terminal window
aggrega import compose.yaml --sync

이 명령은 가져오기가 쓴 것만 변경하며, 같은 응답 파일을 읽습니다. 소스가 건드리지 않은 부분은 편집 여부와 관계없이 디스크에 있는 그대로 유지됩니다. 소스가 사용자가 편집한 부분을 변경한 경우에는 멈추고, 그 부분을 지목하고, 아무것도 쓰지 않으므로 직접 조정해야 합니다. aggrega import에 규칙과 모든 플래그가 자세히 설명되어 있습니다.