You can develop and debug parts of your application independently by splitting your application into Skaffold modules. For a sample Skaffold.yaml file with Skaffold modules and dependencies defined, see the Skaffold.yaml file in the Bank of Anthos sample.
Defining Skaffold modules and configuration dependencies
To define Skaffold modules and configuration dependencies:
- Open the project where you want to define the modules.
- Open the
skaffold.yaml
file. - If your
skaffold.yaml
file has multiple configurations, to make a configuration a Skaffold module, specify the following line:metadata: name: MODULE_NAME_1
- For configurations that rely on another configuration being deployed before the current
configuration can be deployed, define dependencies. To specify a dependency, use the
configs
tag. The following sample shows a dependency that's defined in the same file. Theconfigs
tag can also reference other skaffold.yaml files in the current project.requires: - configs: [DEPENDENCY_NAME]
- Test your configuration dependencies by building each of the Skaffold modules separately to make sure that they're deployed with their dependencies by following the steps in Building select Skaffold modules and their dependencies.
Building select Skaffold modules and their dependencies
If your project doesn't have a launch.json
file defined, when you run
Cloud Code: Run on Kubernetes or Cloud Code: Debug on Kubernetes, you're prompted
to select the modules to build:
- Open the Command Palette
(
Ctrl
/Cmd
+Shift
+P
) and then run Cloud Code: Run on Kubernetes. - Click Select modules.
- Choose the modules that you want to deploy and then click OK. Each module is built with its dependencies.
- When prompted, choose an image registry and then press
Enter
.
If your project has a launch.json
, follow these steps to
choose the Skaffold modules to build:
- Open your project's
launch.json
file. - Edit the launch configuration to add the
skaffoldFlags
option with a comma-delimited list ofmodules
to build. IfskaffoldFlags
is omitted, all modules are built.{ "name": "Run on Kubernetes", "type": "cloudcode.kubernetes", "request": "launch", "skaffoldConfig": "${workspaceFolder}/skaffold.yaml", "skaffoldFlags": { "modules": ["MODULE_NAME_2,MODULE_NAME_2"] } }
- Run the launch configuration you edited.