To run or debug an application on Kubernetes, you'll need to set your preference for how your container image is built by configuring it in the Develop on Kubernetes run configuration.
In a project that doesn't contain a skaffold.yaml
file at the root or doesn't
reference skaffold.yaml
you can use the Cloud Code UI to choose
a builder and build environment.
Building locally is free of charge since it uses your own resources. Building with Cloud Build is good for slower machines or machines that don't match the processor architecture of the target cluster. For information about the cost of building your application using Cloud Build, see Cloud Build Pricing.
Specify how your images are built
Cloud Code supports Docker, Jib, and Buildpacks artifact types.
Without a skaffold.yaml
When importing an existing application without a skaffold.yaml
file or running
an application that doesn't have a skaffold.yaml
, you're prompted to specify
settings when initializing.
If you're using one of the Cloud Code sample applications, to use
the UI, delete the skaffold.yaml
file before running a build action. For steps
to choose a builder and build environment without the UI, see
Manually creating a Skaffold configuration.
- In a project without a
skaffold.yaml
file, open the command palette (pressCtrl
/Cmd
+Shift
+P
or click View > Command Palette) and then run Cloud Code: Run on Kubernetes or Cloud Code: Debug on Kubernetes. - In the Build environment section, choose a build environment.
- In the Deploy settings section, if you chose Cloud Build, specify the image registry you want Cloud Build to push images to.
- In the Build settings section, specify a builder (Docker, Jib, or buildpacks) for each image and its settings.
- Select or clear any of the configuration options and then click Debug or Run.
The options you choose are saved to a
skaffold.yaml
file that you can
edit directly for further customization.
With an existing skaffold.yaml
For a project with an existingskaffold.yaml
file, you need to manually edit
your build options. Cloud Code provides snippets for common YAML
schema viewable by pressing Command/Ctrl + Space
. See the the
Skaffold Build documentation
for more details.
Use Skaffold profiles in Cloud Code
Cloud Code uses the Skaffold tool under the hood to power Cloud Code's build functionality. To configure Cloud Code for different build or deploy environments such as local or remote builds, Skaffold profiles are usedCreate a new skaffold profile
If you'd like to define build, test and deployment configurations for different contexts, you can have different Skaffold profiles.
The following sample shows a profile namedcloudbuild
used to to build images
with Cloud Build:
profiles:
# use the cloudbuild profile to build images using Google Cloud Build
- name: cloudbuild
build:
googleCloudBuild: {}
launch.json
file.
For more information on Skaffold profiles, see the
Skaffold profiles documentation
What's next
- Use file sync and hot reloading to speed up development.
- Learn more about Cloud Native Buildpacks.
- Read about the benefits of Cloud Build.