Creating a Cloud Run Service with VS Code
Start course

In this course, we will explore some of the tools available to build and manage development environments intended for deployment on Google Cloud Platform products. We will also demonstrate how to easily push builds from our local machine to Google-hosted services.

We will start the course by covering the different types of development environments and their purposes. We will touch briefly on popular software methodologies and frameworks as they relate to choices in number and type of development environments.

This course will focus on container-based application development environments, tools, and services. We will first walk through installing and using Docker and Kubernetes on your local machine. Then we will explore how to push projects to Google Cloud Run and Google Kubernetes Engine.

Writing applications using Kubernetes or Cloud Run can be further streamlined with Google Cloud Code, which provides direct IDE support for development on these platforms. We will examine how to install and use Google Cloud Code with Visual Studio Code.

Learning Objectives

  • Understand the types of development environments and when to use them
  • Install a container-based local development environment
  • Add Google Cloud Code support to VS Code
  • Push code from a local development environment and run on Google Cloud Platform using:
    • Google Cloud Run
    • Google Kubernetes Engine
    • Google Deployment Manager

Intended Audience

  • Programmers interested in developing containerized applications on Google Cloud Platform
  • Solo developers new to working on a development team
  • Anyone preparing for the Google Professional Cloud DevOps Engineer certification


To get the most out of this course, you should:

  • Have a Google Cloud Platform account
  • Have Google Cloud SDK installed and initialized
  • Be familiar with IAM role management for GCP resources
  • Have Visual Studio Code, Python 3, and Git installed

Knowledge of Python would also be beneficial for scripting with GCP, but it's not essential.



In the last video, we integrated deployment to kubernetes-based development and staging environments directly into our IDE with the help of Google Cloud Code for Visual Studio Code.  Now let’s try the same thing for a development workflow deploying to Google Cloud Run instead.

Let’s click on “Cloud Code” at the bottom like last time, click “New Application”, and this time we’ll select “Cloud Run application”. There are some starting samples for a few different languages available. Let’s pick the Python Flask sample, give it a few moments to process, and now we can see the project files for our new Cloud Run app.

There’s just a very basic file running our Flask application here. Let’s try testing it locally with the Cloud Run Emulator. We can see a few basic settings we can assign our service here. Notice how we also have Buildpacks as an available option in our Build Settings here, as we installed the Pack tool earlier. Let’s test our deployment out using buildpacks.

As our application deploys here, we can see that it’s using minikube behind the scenes to emulate our Cloud Run service locally.  This is because Cloud Run also uses containers, but handles all the orchestration and management behind the scenes for us. This can make it even easier to deploy certain types of containerized applications, but does come with some restrictions and limitations on the environment. For full control, we would still want to deploy our own GKE cluster.

Give our Cloud Run Emulator a few minutes to spin up, then it will return a localhost URL where we can see our Cloud Run service running.  Notice that our minikube emulator doesn’t show up in the Cloud Run Explorer as an actual Cloud Run Service here. 

If we open the URL in our browser though, we’ll find our service running. Once again we can make a quick change to the source code in our python file, and watch them get immediately deployed. If we refresh our browser, we’ll see our changes are already live.

Now that we have tested our Cloud Run service in development, let’s deploy it to a staging environment on Google Cloud Run instead of using a locally hosted emulator. Just click Cloud Code on the bottom again, and select “Deploy to Cloud Run”. We again have some settings to choose before deploying our service, but with some more deployment options to go through this time. 

Let’s again use buildpacks to deploy our service. It will take a few minutes longer this time to deploy, but when it’s done we’ll see our new deployment is now found in the Cloud Run Explorer in VS Code. We can click on the service URL output in the console after our deployment completed, and see our app now running from a web accessible URL.

We have now learned how to work through our development and staging environments without even leaving Visual Studio Code. In the final lecture group, we’ll step back outside of the IDE a bit and learn how to take our project to production.


About the Author

Arthur spent seven years managing the IT infrastructure for a large entertainment complex in Arizona where he oversaw all network and server equipment and updated many on-premise systems to cloud-based solutions with Google Cloud Platform. Arthur is also a PHP and Python developer who specializes in database and API integrations. He has written several WordPress plugins, created an SDK for the Infusionsoft API, and built a custom digital signage management system powered by Raspberry Pis. Most recently, Arthur has been building Discord bots and attempting to teach a Python AI program how to compose music.