Operation
Using Google Cloud Deploy and Skaffold for effortless CI/CD
Although 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 high-quality software faster and more reliably on GCP.
As a developer or organisation, you can leverage the Google Cloud Deploy service alongside Skaffold to overcome these challenges. In this post, we delve into the transformative power of using Google Cloud Deploy with Skaffold to automate the deployment of containerised apps to GKE.
What is Google Cloud Deploy?
Google Cloud Deploy, or simply Cloud Deploy, is a fully managed continuous delivery service that automates the deployment of your applications to GKE and Cloud Run. It enables you to do this by creating a continuous delivery (CD) pipeline that manages the entire lifecycle of your GKE deployments.
Cloud Deploy makes creating a CD pipeline as simple as possible. All you need to do is provide the following information in the pipeline's YAML configuration file:
Pipeline details – such as name, description, etc.
Targets – These are the various environments where you want to deploy your app, i.e. the GKE clusters on which your app will be deployed.
Promotion sequence – This is the order your deployments follow as they move from development to production (for example, Development → Staging → Production).
Once you register your CD pipeline with the Cloud Deploy service, it manages deployments to the targets you specified according to your defined promotion sequence.
What role does Cloud Deploy play in managing and automating GKE deployments?
The CD pipeline you set up automates the entire deployment process. You do not need to start the pipeline manually. The output of your Continuous Integration (CI) process invokes Cloud Deploy to initiate it.
NOTE: One of the most common outcomes of your CI process is when Cloud Build creates a container image and pushes it to Artifact Registry.
[caption id="" align="alignnone" width="741"]

Source: GKE Documentation [/caption]
Once the pipeline is triggered, Cloud Deploy automatically creates a rollout resource to orchestrate the deployment process. Next, it creates a release resource based on this rollout. This is like a blueprint for a new version of your app, guiding Cloud Deploy on how to deploy it.
This rollout is deployed to the first target, usually a development cluster. After meeting specified criteria, Cloud Deploy creates a new rollout to deploy it to the next target. This process of release creation and promotion continues through all the targets in your promotion sequence, right up to the last one (usually production).
When you want to update the app, simply push your code to GitHub (or your preferred version control system). Assuming you have a CI pipeline set up 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. You can specify the conditions that must be met for a release to be promoted, for example:
It should pass all tests and health checks.
It should meet specific performance metrics.
Approval gates for specific release promotions
You might want a product manager or team lead to manually approve a release before it is rolled out to users in production. Cloud Deploy allows you to configure a target to require approval before a release is deployed there. Integration with IAM allows you to define roles for who can approve which releases.
Simplified CI/CD pipelines
As mentioned earlier, Cloud Deploy makes creating your pipelines easy. You can do this declaratively via a YAML configuration file or by using the web console. Cloud Deploy also provides a centralised view of all your pipelines and their deployment progress.
You will receive Pub/Sub notifications when deployment for each pipeline starts, succeeds, or fails. These notifications keep you informed and make pipeline management straightforward.
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 concurrently, speeding up the deployment process.
In addition, Cloud Deploy supports multiple rollout strategies such as standard and canary. In particular, canary deployments ensure that your release can reliably serve a portion of your traffic before all your users are exposed to it.
Improved developer productivity
Cloud Deploy CD pipelines automate release promotion and deployments to GKE for developers. This frees them up to focus on what really matters – writing code.
Like other services on GCP, Cloud Deploy is fully managed. This means developers do not need to spend time provisioning infrastructure.
Increased scalability and flexibility
Cloud Deploy automatically scales your continuous delivery process based on your organisation's needs. This helps optimise your GCP costs when traffic decreases. Should your deployment have a critical bug or vulnerability, 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 of this, it must be used together with Skaffold.
Use Skaffold with Cloud Deploy for streamlined development
Skaffold is a command-line tool that integrates well with GKE and Cloud Run to automate the deployment of your apps to GKE. It is perfect for developers looking to simplify building, pushing, and deploying apps to GKE, as well as getting rapid feedback to understand the results of their code changes. Once set up, it automatically detects changes to your code, builds a new image based on those changes, and deploys it to GKE.
How Cloud Deploy uses Skaffold
Cloud Deploy leverages Skaffold to render and apply your manifests. When you configure your Cloud Deploy YAML file, you also create a YAML file for Skaffold. Therefore, when Cloud Deploy triggers a release version, it calls Skaffold to render your manifests.
Additionally, during deployment, Cloud Deploy invokes Skaffold again to apply these manifests and deploy your app to each target. Following deployment, Skaffold performs health checks to monitor the target for a successful deployment.
Why is the Cloud Deploy-Skaffold integration important for GKE deployments?
Using Skaffold in this way decouples your rendering tools from the delivery pipeline. Your delivery pipeline controls your app's progress from one target to the next, while your Skaffold configuration handles rendering. This makes manifest rendering flexible – you can experiment with it without impacting 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 deployment down.
Use Skaffold profiles to define manifest customisations for different targets
Since we are deploying across different environments, do we need to create different skaffold.yaml files? No, we simply need to configure different profiles for different targets. This means you can have separate profiles for GKE clusters in development, staging, and production.
For instance, you can configure the development profile to push the Docker image to a local development Docker registry. The production profile will then do the same for a production registry.
This allows you to switch between different deployment configurations without modifying the main Skaffold configuration file. Consequently, managing deployments across various environments becomes much easier.
Summary
When Google Cloud Deploy and Skaffold are used together, they streamline GKE deployments and enable users to deliver high-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 decouples your deployment from rendering and streamlines your CI/CD pipelines.



