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.
To set or edit build options, navigate to the Run/Debug configuration selector in the Navigation bar or the top-level main menu: Run > Edit Configurations > Develop on Kubernetes and then click the Build/Deploy tab.
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.
- Navigate to the Run/Debug configuration selector in the Navigation bar or the top-level main menu: Run > Edit Configurations > Develop on Kubernetes and click the Build/Deploy tab.
- Click Initialize.
- In the Initialize Kubernetes project with Cloud Code dialog under Build settings, select the image you want to build, and then click the Edit icon or press Enter.
Select the builder that you want to use and then click Okay.
The builder and settings you specify are stored in your Skaffold configuration as your default build preference.
To return to your Run Configuration dialog with your new settings, click Initialize.
With an existing skaffold.yaml
On the Build/Deploy tab of your Run configuration settings, you can configure the build settings for your default profile.
You can also view the image name, builder, and builder arguments for all your existing images.
Use Skaffold profiles in Cloud Code
Cloud Code uses the Skaffold tool under the hood to power the functionality in the Build/Deploy tab. To configure Cloud Code for different build or deploy environments such as local or remote builds, Skaffold profiles are used.Create a new skaffold profile
If you'd like to define build, test and deployment configurations for different contexts, you can have different Skaffold profiles.
1. To create a new profile, navigate to Run > Edit Configurations > Develop on Kubernetes and choose the Build/Deploy tab.In the Deployment profile box, click + Add Skaffold profile.
In the Create a new profile dialog, enter a profile name, select the build environment, and then click OK.
After you've created the new profile, it will be automatically selected in the Deployment profile combo box in the run configuration panel.
You can also add profiles by editing your skaffold.yaml
file manually.
The following sample shows a profile named cloudbuild
used to to build images
with Cloud Build:
profiles:
# use the cloudbuild profile to build images using Google Cloud Build
- name: cloudbuild
build:
googleCloudBuild: {}
Filter profiles by build environment
Using the Build environment filter input in the Cloud Code: Kubernetes run configuration panel, you can filter your skaffold profiles based on the build environment you're interested in.
Navigate to the Run/Debug configuration selector in the Navigation bar or the top-level main menu: Run > Edit Configurations > Develop on Kubernetes and click the Build/Deploy tab.
By default, Any build environment will be selected. This filter shows all skaffold profiles in the selected skaffold profile.
In the Build environment filter drop-down menu, select the build environment you want to see.
Profiles matching your build environment selection are available in the Deployment profile drop down. If you select a build environment that has no available profiles, you may be prompted to create a profile.
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.