Harnessing Google Cloud Deploy and Skaffold for Effortless CI/CD

While GKE simplifies most of the complexities of running Kubernetes clusters, GKE deployments can still be complex, especially when you have numerous pipelines across multiple environments. Setting them up and managing them could easily prevent you from delivering quality software faster and more reliably in GCP.

As a developer or organization, you can use the Google Cloud Deploy service together with Skaffold to overcome these challenges. In this post, we’ll dive into the transformative power of using Google Cloud Deploy with Skaffold to automate deploying containerized apps on GKE.

What is Google Cloud Deploy?

Google Cloud Deploy, or simply Cloud Deploy, is a fully managed continuous delivery service that automates the delivery of your applications on GKE and Cloud Run. It allows you to do this by creating a continuous delivery (CD) pipeline that will manage the entire lifecycle of your GKE deployments.

Cloud Deploy makes creating a CD pipeline as easy as it gets. All you have to do is provide the following information in the pipeline’s YAML configuration file:

  • The pipeline’s details - such as the name, description, etc.

  • Targets - These are the different environments in which you intend to deploy your app, i.e., the GKE clusters on which your app will be deployed.

  • Promotion sequence - This is the order your deployments will follow as they move from development to production (for example, Development Staging Production).

After you register your CD pipeline with the Cloud Deploy service, it manages deployments to the targets you’ve specified according to your defined promotion sequence.

What is Cloud Deploy’s role in managing and automating GKE deployments?

The CD pipeline you set up will automate the entire deployment process. You don’t have to initiate the pipeline manually. The output of your continuous integration (CI) process will call to Cloud Deploy to initiate it.

NOTE: One of the common outputs of your CI process is when Cloud Build creates a container image and pushes it to the Artifact Registry.

Once the pipeline is initiated, Cloud Deploy will automatically create a rollout resource to orchestrate the deployment process. Subsequently, it will create a release resource based on that rollout. This is like a blueprint for a new version of your app which guides Cloud Deploy on how to deploy it.

This rollout will be deployed to the first target, usually a dev cluster. After it meets a set criteria, Cloud Deploy will create a new rollout to deploy it to the next target. This release creation and promotion process continues through all the targets in your promotion sequence, until the last one (usually, production).

If you want to update the app, simply push your code to GitHub (or your preferred version control system). Provided you’ve set up a CI pipeline with Cloud Build, you can perform GKE deployments hands-free.

The Benefits of Using Google Cloud Deploy for GKE Deployments

Automated release promotions

With Cloud Deploy, you can automatically move your release from one deployment environment to the next one. You can specify the conditions that must be met for a release to be promoted, for example:

  • It should pass all the tests and health checks.

  • It should meet specific performance metrics.

Approval gates for specific release promotions

You might want a product manager or team leader to approve a release manually before it rolls out to production for users to enjoy. Cloud Deploy allows you to set a target to require approval before a release is deployed to it. Its integration with IAM allows you to set roles for who can approve which releases.

Simplified CI/CD pipelines

As aforementioned, Cloud Deploy makes creating your pipelines easy. You can do it declaratively via a YAML configuration file or use the web console. Cloud Deploy also provides a centralized view of all your pipelines and how they’re progressing against their deployments. 

You’ll receive Pub/Sub notifications when the deployment starts, succeeds, or fails for each pipeline. These notifications keep you up-to-date, making pipeline management simple.

Faster and more reliable deployments

Cloud Deploy automates release creation and promotion, allowing your rollouts to move quickly through different targets. You can also deploy to multiple targets at the same time, and this accelerates the deployment process.

In addition, Cloud Deploy supports multiple rollout strategies such as Standard and Canary. Canary deployment, specifically, ensures your release can reliably serve a portion of your traffic before all of your users are exposed to it.

Improved developer productivity

Cloud Deploy CD pipelines automate the release promotion and deployments to GKE for developers. This frees them to focus on what really matters – writing code. 

Like other services on GCP, Cloud Deploy is fully managed. This means developers won’t need to spend time provisioning infrastructure.

Enhanced scalability and flexibility

Cloud Deploy automatically scales your continuous delivery process depending on your organization’s needs. This helps to optimize your GCP costs when traffic goes down. Suppose your deployment has a critical bug or data breach, you can easily roll it back, fix the issue, and create a new release. 

Cloud Deploy does so much to streamline deployments on GKE. To achieve all this it needs to be used together with Skaffold.

Leveraging Skaffold with Cloud Deploy for Streamlined Development

Skaffold is a command-line tool that integrates well with GKE and Cloud Run to help automate the deployment of your apps to GKE. It is perfect for developers who want to simplify building, pushing, and deploying apps to GKE and get rapid feedback to understand the results of their code changes. Once you set it up, it automatically detects changes in your code, builds a new image based on these changes, and deploys it to GKE.

How Cloud Deploy uses Skaffold?

Cloud Deploy uses Skaffold for rendering and applying your manifests. When configuring your Cloud Deploy YAML file, you’ll also create a YAML file for Skaffold. So that when Cloud Deploy triggers a release, it calls Skaffold to render your manifests.

Also, when deploying, Cloud Deploy will call Skaffold again to apply those manifests and deploy your app to each target. Post-deployment, Skaffold performs health checks to monitor the target for a successful deployment.

Why is the Cloud Deploy-Skaffold integration important in GKE deployments?

Using Skaffold this way separates your rendering tools from the delivery pipeline. Your delivery pipeline will handle your app’s progression from one target to the next as your Skaffold configuration handles rendering. This makes manifest rendering flexible – you can experiment with it without affecting your CD pipeline.

Separating your rendering tools from the delivery pipeline also helps you avoid slow deployment times. This is because rendering can be a resource-intensive process that slows down deployment.

Use Skaffold profiles to define manifest customizations for different targets

Since we’ll deploy to different environments, do we need to create different skaffold.yaml files? No, we just need to configure different profiles for different targets. This means you can have different profiles for the development, staging, and production GKE clusters.

For example, you can have the development profile specifying that the Docker image here will be pushed to a local dev Docker registry. Then the production profile does the same to a production registry.

This allows you to switch between different deployment configurations without modifying the main Skaffold configuration file. As a result, managing deployments to different environments will be easier.

Summary

When used together, Google Cloud Deploy and Skaffold streamline GKE deployments, allowing users to deliver quality software faster and more reliably on GCP. Cloud Deploy allows you to easily create CD pipelines, deploy new releases, and manage your deployments across multiple environments.

Cloud Deploy then calls Skaffold to handle rendering during deployments. This separates your deployment from rendering and optimizes your CI/CD pipelines.


Next
Next

Build your own Google Cloud Expert from scratch