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
Prerequisites
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.
Resources
At this point, we’ve learned how to integrate containers into our development workflow, and have automated the build process for our app through each of our development environments. This could be entirely sufficient enough for many projects, but what if our app spans across multiple GCP products?
We might have a GKE cluster running our main application, but maybe it uses a Google Cloud SQL instance for database storage, stores files in a Google Cloud Storage bucket, and maybe we have also created some Google Cloud Functions as an API endpoint for our app. Suddenly we have a whole mess of services to manage all over again.
Google Cloud Deployment Manager lets us combine all of these Google resources together into a single unit, which as you may have guessed is called a Deployment. This is accomplished by creating yet another YAML file for our project to define all the GCP resources our app needs.
Let’s try an example from the deploymentmanager-samples repository from the GoogleCloudPlatform GitHub page here. I have already pulled a copy into VS Code for us to look at. This yaml file has a resources section with two resources named here, each representing a type of compute instance.
When we deploy using this file, Deployment Manager will use these as instructions to deploy not one but two virtual machines for us. We just have to replace the “MY_PROJECT” bits in the sample with our actual project name. We can then use the gcloud deployment-manager deployments create
command and point it to our YAML file to deploy both VMs.
We can take this even a step further, by creating reusable templates to use with our deployment configuration. These templates are written in Python, which allow us to add logic based on deployment-specific environment variables, and pass custom template properties into our deployment configuration at runtime. This way we can make the zone our app is deployed in a variable for example, allowing us to easily deploy it to a specific region as we are creating it, instead of having this information hard coded into the deployment configuration.
We can also combine multiple templates together in a modular fashion. Let’s take a look at another slightly more complex example here. This yaml file looks quite different from our first example. It only imports a bunch of python scripts, and then declares one of them as a resource.
If we look at that compute-engine-template python script, we can see it creates four more resources for us, by calling the other four python scripts. We can take a quick look at each of these scripts, and see some more complex configuration examples for two virtual machines, and both a network and firewall resource for them to utilize. We can then deploy our yaml file in exactly the same way as the first example, and see it create both our virtual machines, and our network and firewall resources on GCP for us.
Since we can so easily combine templates together like this, I strongly encourage using the templates found in the Cloud Foundation Toolkit as a starting point for your Deployment Manager configurations. CFT templates are available for most GCP products and services and they already observe best practices for you, so you can start your deployment off on the right foot.
We have only scratched the surface of Cloud Deployment Manager here, but you should have a basic idea of how we can use it to combine multiple GCP products together in our own applications now. You can see literally thousands of other examples of applications that can be deployed using Cloud Deployment Manager on the GCP Marketplace.
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.