Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Crea un'app con dipendenze di configurazione
In questa guida rapida, configurerai un'applicazione con dipendenze di configurazione
in base a un'applicazione di esempio e poi eseguirai il deployment delle parti dell'app separatamente.
Prima di iniziare
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Per aprire lo spazio di lavoro basato su Bank of Anthos, in VS Code, fai clic su File >
Apri cartella e poi vai alla cartella in cui è stato clonato il repository.
Fai doppio clic sul file skaffold.yaml.
Il file contiene più configurazioni, separate da separatori di documenti YAML (---). Ogni configurazione può essere implementata o a cui si può fare riferimento come
dipendenza separatamente.
---apiVersion:skaffold/v2beta18kind:Config
Le configurazioni con un nome specificato sono note come moduli Skaffold.
Il seguente estratto definisce il modulo frontend.
metadata:name:frontend# module defining frontend service
Le dipendenze tra le configurazioni vengono specificate utilizzando il tag configs. Le configurazioni richieste devono essere implementate prima di quella attuale. L'esempio mostra una dipendenza definita nello stesso
file. Il tag configs può fare riferimento anche ad altri file skaffold.yaml nel progetto attuale.
requires:-configs:[db]
Deployment dei moduli
Apri la tavolozza dei comandi (Ctrl/Cmd+Shift+P) e poi esegui
Cloud Code: Run on Kubernetes.
Fai clic su Seleziona moduli.
Scegli i moduli di cui vuoi eseguire il deployment e poi fai clic su Ok.
Se fai clic su db, vengono create la configurazione db e la configurazione setup che richiede.
Quando richiesto, scegli un registro delle immagini e premi Enter.
Pulizia
Dopo aver terminato l'applicazione, tutte le risorse Kubernetes di cui è stato eseguito il deployment durante l'esecuzione vengono eliminate automaticamente.
Per evitare che al tuo account vengano addebitati costi relativi ad altre risorse utilizzate in questa guida rapida, assicurati di eliminare il cluster e il progetto che hai creato.
Se utilizzi Google Cloud e vuoi eliminare solo il cluster, puoi farlo seguendo questi passaggi:
Fai clic su Cloud Code ed espandi Explorer di Kubernetes.
Tieni il puntatore sopra il nome del cluster e poi fai clic su
open_in_newApri nella console Google Cloud .
Fai clic su Elimina e quindi su Elimina.
Per eliminare il progetto (e le risorse associate, inclusi eventuali cluster):
Vai alla pagina Progetti nella console Google Cloud :
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis guide demonstrates how to set up an application with configuration dependencies and deploy parts of it separately using Skaffold modules.\u003c/p\u003e\n"],["\u003cp\u003eSkaffold modules, defined by a name within the \u003ccode\u003eskaffold.yaml\u003c/code\u003e file, allow for the separate deployment of configurations, including defining dependencies via the \u003ccode\u003econfigs\u003c/code\u003e tag.\u003c/p\u003e\n"],["\u003cp\u003eTo deploy selected modules, use the "Cloud Code: Run on Kubernetes" command in VS Code, and select the desired modules.\u003c/p\u003e\n"],["\u003cp\u003eThe guide highlights the cleanup process, including the automatic deletion of Kubernetes resources after application termination and instructions for manually deleting the cluster or project in Google Cloud.\u003c/p\u003e\n"],["\u003cp\u003eThe guide directs to further resources such as learning about Skaffold modules, language specific debugging, and configuring settings.\u003c/p\u003e\n"]]],[],null,["# Create an app with configuration dependencies\n=============================================\n\nIn this quickstart, you set up an application with configuration dependencies\nbased on a sample application and then deploy parts of the app separately.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Google Kubernetes Engine API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Google Kubernetes Engine API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n\n1. Install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). Git is required for copying samples to your machine.\n2. Install the [Cloud Code plugin](/code/docs/vscode/install#installing) if you haven't already.\n\nCreating an application\n-----------------------\n\n1. Clone the Bank of Anthos repository:\n\n 1. In the top menu bar, click **Terminal** \\\u003e **New Terminal**.\n 2. Clone the Bank of Anthos repository:\n\n git clone https://github.com/GoogleCloudPlatform/bank-of-anthos.git\n\n2. To open the workspace based on Bank of Anthos, in VS Code, click **File** \\\u003e\n **Open folder** and then navigate to the folder where the repository was\n cloned.\n\n3. Double-click the `skaffold.yaml` file.\n\n 1. The file contains multiple configurations, separated by YAML document\n separators (`---`). Each configuration can be deployed or referenced as a\n dependency separately.\n\n ---\n apiVersion: skaffold/v2beta18\n kind: Config\n\n 2. Configurations with a name specified are known as *Skaffold modules* .\n The following excerpt defines the `frontend` module.\n\n metadata:\n name: frontend # module defining frontend service\n\n 3. Dependencies between configurations are specified using the `configs`\n tag. Required configurations must be deployed before the current\n configuration. The sample shows a dependency that's defined in the same\n file. The `configs` tag can also reference other `skaffold.yaml` files in\n the current project.\n\n requires:\n - configs: [db]\n\nDeploying modules\n-----------------\n\n1. Open the Command Palette (`Ctrl`/`Cmd`+`Shift`+`P`) and then run **Cloud Code: Run on Kubernetes**.\n2. Click **Select modules**.\n3. Choose the modules that you want to deploy and then click **OK**.\n\n If you click **db** , the **db** config and the **setup** config that it\n requires are built.\n4. When prompted, choose an image registry and then press `Enter`.\n\nCleaning up\n-----------\n\nAfter you terminate your application, all Kubernetes resources deployed during\nthe run are deleted automatically.\n\nTo avoid incurring charges to your account for other resources used in this\nquickstart, be sure to delete the cluster and project you created.\n\nIf you're using Google Cloud and would like to delete just your cluster, you\ncan do so by following these steps:\n\n1. Click **Cloud Code** and then expand the **Kubernetes** explorer.\n2. Hold the pointer over your cluster name and then click open_in_new **Open in Google Cloud console**.\n3. Click **Delete** and then click **Delete**.\n\nTo delete your project (and associated resources, including any clusters):\n\n1. Go to the Projects page in the Google Cloud console:\n\n [Go to the Projects page](https://console.cloud.google.com/project)\n2. Select the project that you created for this quickstart and then click\n **Delete**.\n\n3. Type the project ID to confirm and then click **Shut down**.\n\n This shuts down the project and schedules it for deletion.\n\nWhat's next\n-----------\n\n- Learn more about [Skaffold modules](/code/docs/vscode/skaffold-modules).\n- Learn about the language-specific [debugging support](/code/docs/vscode/debug) in Cloud Code.\n- Customize your Cloud Code experience by configuring [settings](/code/docs/vscode/configuring-settings)."]]