Using Google’s Cloud Code In VS Code For Code Completion

At Google Cloud Next 2019, Google introduced a new developer tool referred to as Cloud Code. With Cloud Code, developers got a set of plugins for development environments like JetBrains IntelliJ Idea IDE and Microsoft's Visual Studio Code editor.

Google’s intention with Cloud Code is to accelerate the development lifecycle of programs within the cloud. Therefore, Google’s focus is to make it simpler to develop applications that run on Kubernetes, including the Google Kubernetes Engine (GKE). 

Cloud Code with VS Code; Source: YouTube

With Cloud Code, developers get a chain of open-source command-line box tools such as Kubectl, the command-line tools for working with the Kubernetes API; Jib, for constructing packing containers for Java applications; and Skaffold, for installing the non-stop deploying pipeline for Kubernetes programs. Furthermore, developers get constant comments on their projects when building them. The plugins enlarge the local edit-compile-debug loop to any remote or local Kubernetes environment. Also, both plugins support Java, Node.js, Go, Python, and .NET Core.

Cloud Code for VS Code brings the power and convenience of IDEs to cloud-local software development. Cloud Code integrates with Google Cloud services like Google Kubernetes Engine, Cloud Run, Cloud APIs, and Secret Manager and makes you feel like you're working with local code.

Cloud Code works with Google’s command-line container tools like Skaffold, Minikube, and Kubectl beneath the hood, presenting local, continuous comments on your project as you build, edit, run, and deploy your programs locally or inside the cloud. Cloud Code additionally deeply integrates with the Cloud SDK to offer a unified authentication experience while you develop with Google Cloud Services.

Key Features

Cloud extension in VS Code; Source: Mete Atamel

Supporting your development workflow

You can get run-ready sample applications, out-of-the-box configuration snippets, support for key Google Cloud Services like Cloud APIs and Google Cloud Build, Cloud Native Buildpacks, Secrets Manager, one-click on deployment, a tailor-made debugging experience, an iterative run/debug experience, and lots more. Cloud Code makes developing with Kubernetes and Cloud Run a whole lot less difficult.

Kubernetes development

Kubernetes developers can create and run a brand new app in minutes with Cloud Code’s Kubernetes help. They can also work on current software, customize its YAML with Cloud Code’s intelligent authoring support, debug it relentlessly with the setup-free debugger, and run it on any of their Kubernetes clusters. Whatever their workflow is, Cloud Code allows them to spend much less time on configuration and context-switching, so they can focus on growing their app.

Cloud-run development

You can create and install a new service in minutes with Cloud Code’s equally strong Cloud Run assist, tracking your carrier’s progress with the Cloud Run Explorer and carrier logs reachable within the Log Viewer. If you pick a nearby development workflow, you can additionally increase and debug a provider locally with the integrated Cloud Run emulator.

Containerization made easy

You can create steady, production-ready container images from source code while not having to worry about a Dockerfile with Cloud Code’s built-in help for Google Cloud Buildpacks. You get to focus on building your application, not containerizing it.

Integrated Secret Manager support 

You can protect sensitive information and keep your app safe with Cloud Code’s incorporated Secret Manager support. You can create, view, update, and use secrets in the Secret Manager view without having them in your codebase. 

Google Cloud APIs at your fingertip

You can browse available cloud APIs, permit offerings, and set up and discover ways to integrate purchaser libraries in your app without leaving your IDE and breaking your development flow, all with the API library browser. 

Develop using Compute Engine Virtual Machines

You can browse Compute Engine Virtual Machines and their applicable properties without leaving your IDE. Easily SSH into your VM using the terminal window and transfer files from your local environment to your virtual system, all with the Cloud Code Guide for Compute Engine. 

Develop Cloud Functions locally

With Google's cloud code, you can view, download, install, and take a look at cloud functions without delay from Cloud Code. Leverage the power of the VS Code IDE to make modifications to your cloud functions without ever needing to go away from Cloud Code. 

Develop APIs with Apigee

You can develop your API proxies and verify the functionality via unit and guide, trying out the usage of the Apigee Emulator (local runtime). Quickly iterate through the construct and take a look at cycles without affecting established programs.

How to set up

How to set up cloud code; Source: Google Cloud

Before you start:

Before you install the cloud code, confirm that the following tools are set up and installed on your system.

  • Install and set up Visual Studio Code on your device.
  • Install and configure language support.
  • The Cloud Code extension works well with these languages:
    • NodeJS (integrated support; no action required)
    • Go
    • Python
    • Java
    • .NET
  • Install Git. Git is needed for copying samples to your device.
  • Install the Docker client and add it to the PATH environment variable:
    • If you're constructing exclusively using Cloud Build or Jib, you could skip installing Docker.
    • If you're using Windows Home, for steps to set up your Docker client, see the Docker Desktop for Windows Home guide.
    • If you are using WSL but cannot deploy Docker for Desktop, use Minikube instead for local development with Cloud Code.
    • If you're using Google Cloud, create a Google Cloud task, after then, allow billing.

Projects will let you collect the related assets for a single piece of software in a single place, control APIs, permit Google Cloud services, upload and dispose of collaborators, and manipulate permissions for Google Cloud resources.

Install the cloud code.

Install the Google Cloud Code extension from the Visual Studio Code Marketplace.

Alternatively, you can open the Extensions view in VS Code:

  • Click Extensions or press Ctrl/Cmd Shift X.
  • Search for Google Cloud Code.
  • Click Install.
  • If asked, restart VS Code.
  • After the extension has successfully installed, the Cloud Code icon is added to the activity bar and geared up for use. You can in addition configure your Cloud Code setup by specifying your preferences using the top application taskbar: Code > Preferences > Settings > Extensions > Cloud Code.

How to connect with your project

Google Cloud in VS Code; Source: The New Stack

To connect the cloud code with your project in VS Code:

Step 1: Install the "Remote - SSH" extension

Step 2: Populate SSH configuration documents

Run the following command to populate SSH configuration documents with host entries for every VM instance you have.

$ gcloud compute config-ssh

Step 3: Connect to the host

If the preceding step is completed efficiently, you ought to see the running VMs inside the Remote Explorer of VS Code, and ought to be capable of opening a new session to dispose of VMs.

Note that the SSH configuration may change if you restart your VM. In this situation, you'll have to re-configure (re-run step 2 above).

Is Google's cloud code free?

Cloud Code is available to all Google Cloud clients free of charge. New customers get $300 in free credit to fully discover and conduct an evaluation of Google Cloud. You won’t be charged until you upgrade.

Conclusion

A central tenet of DevOps is to use "infrastructure as code," wherein all surrounding configurations are managed as source code in a repository. This makes environments reproducible and helps find errors faster. Cloud Code make editing, reviewing, testing, and applying changes to a Kubernetes config convenient and easy. Cloud Code presents templates, linting, and error highlighting for Kubernetes YAML files. Of course, Cloud Code additionally supports logging, so you can view application logs from any environment directly from your IDE.

While some aspects of the plugins are supportive of Google Cloud services, consisting of automatic library and dependency management, Cloud Code is specifically designed to work with Kubernetes, no matter your company. Google has even provided tools for effortlessly creating new Kubernetes clusters on services from competitors like AWS and Azure. This has been an ordinary subject at this year’s Cloud Next, as different services like Cloud Run have also been designed to be easily moved to another provider.

Anyone who wishes to get started with development with Kubernetes can download one of the Cloud Code plugins from Google Cloud or your IDE’s extensions market. Developers can now begin using Cloud Code and get the plugins from Google Cloud or the IDE’s extensions marketplace.



How much is a great User Experience worth to you?


Browsee helps you understand your user's behaviour on your site. It's the next best thing to talking to them.

Browsee Product