Compose प्रोजेक्ट इम्पोर्ट करें
यह वॉकथ्रू एक छोटे Compose प्रोजेक्ट को इम्पोर्ट करता है — एक API, वह PostgreSQL डेटाबेस जिसमें वह अपने नोट्स रखता है, और एक Redis कैश — और परिणाम को Docker Compose के लिए बिल्ड करता है। इम्पोर्ट हर वह फ़ाइल ड्राफ़्ट करता है जिसे बिल्ड पढ़ता है, और Compose फ़ाइल जो बताती है उसे आगे ले जाता है: डेटाबेस और कैश से API के कनेक्शन, डेटाबेस का उपयोगकर्ता और नाम, वेरिएबल संदर्भ के रूप में पासवर्ड, और हर इमेज का टैग। नीचे की हर फ़ाइल और आउटपुट का हर ब्लॉक एक वास्तविक रन से आता है; प्रोजेक्ट और वॉकथ्रू का हर चरण import-compose उदाहरण में है, जहाँ एक चेक स्क्रिप्ट इम्पोर्ट को फिर से चलाती है, वह जो लिखता है, जो प्रिंट करता है और यह पेज जिन ब्लॉकों को उद्धृत करता है, उनकी तुलना वहाँ रखी फ़ाइलों से करती है, और इम्पोर्ट द्वारा लिखी गई चीज़ों को वैलिडेट और बिल्ड करती है।
उदाहरण ड्राफ़्ट करें
आप यह इम्पोर्ट इस पेज के कमांडों से चला सकते हैं, या इसे अपने AI असिस्टेंट से चलवा सकते हैं।
उदाहरण को उसी के नाम वाले एक नए फ़ोल्डर में लिखें:
aggrega draft --example import-composeफिर यह आगे चलाने के लिए कमांड प्रिंट करता है। पहला कमांड नए फ़ोल्डर में ले जाता है; उसके बाद वाला, नीचे दिया गया, उसके source फ़ोल्डर में ले जाता है, जिसमें वह है जिसे यह पेज इम्पोर्ट करता है और जहाँ इम्पोर्ट चलता है:
cd import-compose
प्रोजेक्ट
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 फ़ाइल न बताती हो, इसलिए यह इम्पोर्ट कुछ नहीं पूछता। उसी प्रोजेक्ट का Kubernetes के लिए बिल्ड, --target helm के साथ, एक ऐसे मान की आवश्यकता रखता है जो किसी Compose फ़ाइल में नहीं होता: उस Kubernetes Secret का नाम जिससे डेटाबेस का पासवर्ड पढ़ा जाता है, क्योंकि Kubernetes बिल्ड पासवर्ड आपके शेल से नहीं बल्कि किसी Secret से पढ़ता है। उदाहरण वह उत्तर import-answers.yaml में, compose.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 में जाएँ:
cd sourceइम्पोर्ट चलाएं
aggrega import compose.yaml --target composeस्टैंडर्ड आउटपुट पर यह सूची देता है कि इसने क्या लिखा:
wrote aggregate.yamlwrote release.yamlwrote manifest.yamlwrote .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 emptywarn: 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 emptymapped api (ghcr.io/example/notes-api) to core/compute/server as a reference, NONEmapped db (postgres) to core/datastore/postgres as a reference, HIGH at 0.9mapped cache (redis) to core/datastore/redis as a reference, HIGH at 0.9Pull complete: <workspace>/release.lock (entities=10, source_artifacts=0, external_inputs=0)
warnपंक्तियाँ हर उस मान का नाम देती हैं जिसे ड्राफ़्ट जैसा लिखा है वैसा ही आगे ले जाते हैं, उसकी सेवा और उसके वेरिएबल से और कभी उसके मान से नहीं: Compose किसी मान को क्रेडेंशियल के रूप में चिह्नित नहीं करता, और उनमें से कोई भी एक क्रेडेंशियल रख सकता है। यहाँ कोई नहीं रखता। जो वेरिएबल API किसी दूसरी सेवा से पढ़ता है, वे मानों के रूप में बिल्कुल आगे नहीं ले जाए जाते — कनेक्शन उन्हें पहुँचाते हैं — और जो दो वेरिएबल${POSTGRES_PASSWORD}पढ़ते हैं, वे केवल एक वेरिएबल संदर्भ हैं और कुछ नहीं, इसलिए कोई चेतावनी उनका नाम नहीं देती।mappedपंक्तियाँ बताती हैं कि हर सेवा क्या बनी।apiअपनी स्वयं की इमेज चलाता है, इसलिए वह स्टैंडर्ड लाइब्रेरी के सामान्य सर्वर,core/compute/server, का एक इंस्टेंस है।dbऔरcacheवे इमेज चलाते हैं जिन्हें स्टैंडर्ड लाइब्रेरी के Compose Recipescore/datastore/postgresऔरcore/datastore/redisके लिए चलाते हैं; हर एक ने उस Component से उच्च स्तर में, 0.9 पर, मैच किया, और ड्राफ़्ट उसका संदर्भ देते हैं।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/v1beta1kind: Aggregatemetadata: 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/redisAPI का हर वेरिएबल जो किसी दूसरी सेवा का नाम देता है, उस कनेक्शन का inject ब्लॉक बन जाता है: Compose फ़ाइल ने DATABASE_HOST को db पर सेट किया, और कनेक्शन डेटाबेस का प्रकाशित host उसी नाम के अंतर्गत पहुँचाता है, इसलिए वह कॉपी होने के बजाय किसी भी लक्ष्य पर डेटाबेस का अनुसरण करता है। DATABASE_USER और DATABASE_NAME उस उपयोगकर्ता और डेटाबेस से मैच हुए जिनके साथ PostgreSQL सेवा बनाई जाती है, इसलिए वे भी उसी से पहुँचाए जाते हैं जो वह प्रकाशित करती है, और वे दो मान डेटाबेस के अपने values बन जाते हैं। हर पासवर्ड एक core/secret-value अटैचमेंट बन जाता है, जो उस कुंजी के साथ घोषित होता है जिसके अंतर्गत उसका वेरिएबल पढ़ा जाता है।
release.yaml — एनवायरनमेंट, API की इमेज और पोर्ट, हर डेटास्टोर का इंजन संस्करण, और हर पासवर्ड कहाँ से आता है:
apiVersion: aggrega.ai/v1beta1kind: Releasemetadata: 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 प्रविष्टि प्रकाशित करती है, दोनों 8080, जैसा Compose फ़ाइल उन्हें बताती है; जैसा उसकी टिप्पणी कहती है, इस मशीन का कोई भी प्रोसेस API तक http://127.0.0.1:8080 पर पहुँचता है और कोई और नहीं पहुँच सकता, और पंक्ति हटाने पर वह केवल स्टैक के नेटवर्क पर रहता है। जिसे कोई कुंजी नहीं लेती, वह अपनी प्रविष्टि के ऊपर एक टिप्पणी बनकर रहता है: स्रोत की ports प्रविष्टि, जिसे port और published_port पहले से वहन करते हैं, और डेटाबेस का नामित वॉल्यूम।
manifest.yaml — हर घटक प्रकार का Compose Recipe, और वह रियलाइज़ेशन जो किसी पासवर्ड के वेरिएबल संदर्भ को Compose फ़ाइल में जैसा लिखा है वैसा ही लिखता है:
apiVersion: aggrega.ai/v1beta1kind: Manifestmetadata: name: imported/notes version: 0.1.0spec: 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-secretrelease.lock उन कैटलॉग एंटिटी को, डाइजेस्ट के साथ, रिकॉर्ड करता है जिन पर Release रिज़ॉल्व हुआ, और .aggrega-import.json इस बात का रिकॉर्ड है कि इम्पोर्ट ने क्या लिखा, जिसे बाद में कोई aggrega import --sync पढ़ता है।
वैलिडेट और बिल्ड करें
aggrega validate --release release.yamlaggrega build --release release.yaml

वैलिडेशन प्रिंट करता है:
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>/distnotice पंक्ति सलाहकारी है: पासवर्ड Feature अपना origin Aggregate के values से या Release के infra से स्वीकार करता है, और नोटिस बताता है कि एक लीफ़ दोनों में घोषित है। यह कोई निर्णय नहीं बदलती।
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` फ़ोल्डर नहीं है, तो `draft` टूल को एक बार कॉल करें, `example` को `import-compose` पर सेट करके और बिना `dir` के: यह उदाहरण को एक नए `import-compose` फ़ोल्डर में लिखता है, जिसके `source` फ़ोल्डर में वह है जिसे यह पेज इम्पोर्ट करता है। फिर `import` टूल को कॉल करें, `workspace_root` को `import-compose/source` पर, `source` को `compose.yaml` पर और `target` को `compose` पर सेट करके: यह जिन उत्तरों की आवश्यकता है उन्हें `compose.yaml` के बगल में `import-answers.yaml` से पढ़ता है, अपने ड्राफ़्ट `import-compose/source` में लिखता है और जो उन्हें चाहिए उसे पुल करता है। फिर `validate` टूल को कॉल करें, `workspace_root` को `import-compose/source` पर और `release` को `release.yaml` पर सेट करके, और `build` टूल को, `workspace_root` को `import-compose/source` पर, `release` को `release.yaml` पर और `write` को true पर सेट करके। मुझे बताएं कि बिल्ड ने कौन-सी फ़ाइलें लिखीं; वे `import-compose/source/dist/` के अंतर्गत हैं।इसे VS Code में खोलें
Visual Studio Code के लिए Aggrega एक्सटेंशन इंस्टॉल होने पर, VS Code में फ़ोल्डर import-compose/source खोलें, जहाँ इम्पोर्ट ने अपने ड्राफ़्ट लिखे। फ़ोल्डर में एक Release है, ड्राफ़्ट किया गया release.yaml, इसलिए एडिटर उसे आपके लिए चुन लेता है, और जब आप ड्राफ़्ट संपादित करते हैं तो वह उन्हें उस Release के विरुद्ध जाँचता है, और जो कुछ उसे मिलता है उसे फ़ाइल में और Problems पैनल में चिह्नित करता है। कमांड पैलेट में 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 के साथ रुक जाता है। अपने API की इमेज का नाम release.yaml में api के infra.image में दें। जब तक आपका 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. और उसके स्थान पर एक खाली मान लिखता है।
aggrega build --release release.yaml --auto-pullexport POSTGRES_PASSWORD='a password of your own'docker compose -p notes -f dist/compose/docker-compose.yaml up -d --wait-p प्रोजेक्ट का नाम देता है, जैसा इम्पोर्ट कैसे चलता है का रन चरण बताता है। --wait तब लौटता है जब डेटाबेस और कैश उन हेल्थ चेक को पास कर लेते हैं जो बिल्ड उन्हें देता है और API का कंटेनर चल रहा होता है: बिल्ड API को कोई हेल्थ चेक नहीं देता।
इसे जाँचें
API से http://127.0.0.1:8080 पर पूछें, वह पता जिसे published_port प्रकाशित करता है:
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 पढ़ता है:
docker compose -p notes -f dist/compose/docker-compose.yaml exec api printenv DATABASE_HOST DATABASE_USER DATABASE_NAME CACHE_HOSTdbnotesnotescacheस्टैक को इससे रोकें:
docker compose -p notes -f dist/compose/docker-compose.yaml downKubernetes पर
वही प्रोजेक्ट --target helm के साथ Kubernetes के लिए इम्पोर्ट होता है, और इम्पोर्ट Secret का नाम, notes-db-password, ऊपर की उत्तर फ़ाइल से पढ़ता है। Docker Compose के लिए ड्राफ़्ट पहले से source में हैं, इसलिए इन्हें एक अलग फ़ोल्डर में ड्राफ़्ट करें, उसकी release.yaml में API की इमेज का नाम वैसे ही दें जैसे Docker Compose के लिए, और उसी से बिल्ड करें:
aggrega import compose.yaml --target helm --output-dir helmcd helmaggrega build --release release.yaml --auto-pullबिल्ड सामान्य Kubernetes मैनिफ़ेस्ट वर्कस्पेस रूट, source, पर dist/helm/ के अंतर्गत लिखता है, जो helm से ../dist/helm/ है। जिस नेमस्पेस में आप लागू करते हैं उसमें Secret notes-db-password बनाएं, जिसमें पासवर्ड डेटा कुंजी value के अंतर्गत हो, और फ़ोल्डर को वैसे लागू करें जैसा इम्पोर्ट कैसे चलता है का रन चरण बताता है। API की Service api-default है: एक लोकल पोर्ट को उस पर फ़ॉरवर्ड करें, और कमांड को चलता छोड़ दें:
kubectl port-forward -n <namespace> svc/api-default 8080:8080किसी दूसरे टर्मिनल से, ऊपर का अनुरोध API तक उसी पते पर, बिना बदले, पहुँचता है, और स्टैंड-इन उसी तरह उत्तर देता है, "host": "127.0.0.1:8080"। कनेक्शन Services के नाम पहुँचाते हैं: 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 फ़ाइल बदलने के बाद चलाएं:
aggrega import compose.yaml --syncयह केवल वही बदलता है जो इम्पोर्ट ने लिखा था, और वही उत्तर फ़ाइल पढ़ता है। जिस भाग को स्रोत ने नहीं छुआ, वह डिस्क पर जैसा है वैसा ही रहता है, संपादित हो या न हो; जहाँ स्रोत ने आपके द्वारा संपादित किसी भाग को बदला, वहाँ यह रुक जाता है, उस भाग का नाम देता है, और कुछ नहीं लिखता, ताकि आप उसे हाथ से सुलझाएं। aggrega import नियमों और हर फ़्लैग का पूरा वर्णन करता है।