Work with Google Cloud and Kubernetes YAML files in Cloud Code for IntelliJ

Cloud Code is designed to help with editing Google Cloud and Kubernetes-related configuration files, including schema based validation, diagnostics, and quick documentation.

Supported YAML configuration files

Additionally, Cloud Code also supports popular Kubernetes CRDs, like Kubeflow, out-of-the-box.

Using custom schema

Additionally, with Cloud Code, you can provide your own CRD schema with IntelliJ settings (File > Settings > Tools > Cloud Code > Kubernetes or for Mac OS X, IntelliJ IDEA > Preferences > Tools > Cloud Code > Kubernetes and navigate to the CRD Schema Locations section).

You can point to either a local file or a URL. URLs pointing to github.com are automatically converted to raw.githubusercontent.com.

Pulling schema from a cluster

When you switch to a cluster running Kubernetes v1.16 and above in the Kubernetes Explorer, Cloud Code automatically pulls the schema of all installed CRDs.

Additional Skaffold support

Skaffold is the underlying engine that powers Cloud Code, helping you build, push, and deploy your application as well as providing support for creating CI/CD pipelines.

Cloud Code comes with additional support for managing Skaffold configuration files. On opening a project, Cloud Code detects Skaffold schemas that aren't up-to-date and prompts you (via the Event Log) when a Skaffold schema version upgrade is available for your existing Skaffold YAML configuration files.

Notification in the Event log prompting user to upgrade their Skaffold schema version because their existing Skaffold YAML files are not of the latest version

Alternatively, you can navigate to Tools > Cloud Code > Kubernetes and select Check for Skaffold Schemas Upgrades to check for available schema upgrades.

Configuring with snippets

Out-of-the-box snippets for common YAML schema (using Ctrl+Space to view options) make it easy to start a new YAML file or add to an existing one without errors, while still following best practices. Additionally, it's easier to work with repetitive fields; fill in one and Cloud Code fills out the remaining instances.

Using snippets with repetitive fields

Currently, the following snippets are offered:

  • Cloud Build - Cloud Run deployment
  • Cloud Build - Docker container build
  • Cloud Build - GKE deployment
  • Cloud Build - GKE Skaffold deployment
  • Cloud Build - Go build
  • Cloud Build - Terraform plan + apply
  • Config Connector - BigQueryDataset
  • Config Connector - BigQueryTable
  • Config Connector - BigtableCluster
  • Config Connector - BigtableInstance
  • Config Connector - PubSubSubscription
  • Config Connector - PubSubTopic
  • Config Connector - RedisInstance
  • Config Connector - SpannerInstance
  • Kubernetes - ConfigMap
  • Kubernetes - Deployment
  • Kubernetes - Ingress
  • Kubernetes - Pod
  • Kubernetes - Service
  • Migrate to Containers - Export
  • Migrate to Containers - PersistentVolumeClaim
  • Migrate to Containers - StatefulSet
  • Skaffold - Bazel
  • Skaffold - Getting-started
  • Skaffold - Helm deployment
  • Skaffold - Kaniko

Completing with context

Based on the current schema, Cloud Code will provide contextual completions to help you choose the right option.

Context completions for Kubernetes schema

Validating YAML schema

Cloud Code offers schema validation support by flagging invalid tags and values in your YAML files and suggesting fixes when possible.

Value of name field red-underlined to highlight an invalid value of 1234; hover text states: Incorrect type. Expected string.

Validating Skaffold YAML files

Cloud Code provides additional Skaffold configuration file editing support and smart templates allowing you to easily validate your skaffold.yaml files. Refer to this guide on using an existing app with Cloud Code.

Skaffold yaml templates

Completing Skaffold configuration files with context

Based on the current schema, Cloud Code will provide contextual completions and relevant docs to help you choose the right option.

Skaffold completions

Discovering definitions using quick documentation

Cloud Code surfaces relevant documentation for a resource when you highlight a line in your configuration file and access View > Quick Documentation.

Quick documentation

Linting YAML for structural and validity issues

Cloud Code provides linting support around common schema issues and provides descriptive errors.

Linting YAML files

Applying a YAML file

To run kubectl apply -f to apply a configuration change using the current file, you can use the kubectl actions icon kubectl actions icon, available in the gutter of your IDE and select Apply. This brings up a diff view for you to review changes before clicking Apply.

Apply option highlighted in the kubectl action list

Diffing between YAML files

If you'd like to view the differences between a YAML file in source control and a deployed YAML file, you can use the kubectl actions icon kubectl actions icon available in the gutter of your editor. Choose the Diff option to bring up a diff view for you to compare and contrast two schema files.

Diff option highlighted in the kubectl action list

Performing a dry-run of a YAML file

To perform a dry run of your file and check its validity, you can use the kubectl actions icon kubectl actions icon, available in the gutter of your IDE, to select Dry-run on Server or Dry-run on Client. This runs kubectl apply -f dry-run=server (or kubectl apply -f dry-run=client, for the Client option) and notifies you if your file can successfully be created in your Terminal window.

Dry-run on Server option highlighted in the kubectl action list

What's next

Get support

To submit feedback or report an issue in your IntelliJ IDE, go to Tools > Cloud Code > Help / About > Submit feedback or report an issue to report an issue on GitHub, or ask a question on Stack Overflow.