Top Cloud Deploy Features - 2022

Stenal P Jolly
Google Cloud - Community
4 min readOct 19, 2022

Google Cloud Deploy itself is relatively a new product to Google Cloud Platform(GCP). Let’s start with why we need Google Cloud Deploy and what problems Cloud Deploy can help us with.

Overview of Google Cloud Deploy (Skip this if you are already familiar with Cloud Deploy)

You have written the code and containerized the application. Now the missing piece is how we can deploy the application. Cloud Deploy is a fully managed continuous delivery solution for GKE / Anthos which can help you.

What is “Skaffold”?

Skaffold is a Google Open Sourced command-line tool, which facilitates continuous development for Kubernetes-native applications. Skaffold handles the workflow for building, pushing, and deploying your application, and provides building blocks for creating CI/CD pipelines.

Problem 1: Where can I deploy my application using Cloud Deploy?

Google Cloud Deploy to get your application into your intended target runtime environments. A runtime defines the compute resources and how they are managed. You can deploy your container images and manifests using a skaffold.yaml configuration file.

Google Cloud Deploy can deploy your application to any of the following runtime environments:

  • GKE
    Google Cloud Deploy allows you to deploy your container-based workloads to any Google Kubernetes Engine cluster. All Google Cloud Deploy features are supported when you deploy to GKE targets.
  • Anthos
    Google Cloud Deploy allows you to deploy your container-based workloads to any Anthos user cluster that you can access using Connect gateway.
  • Cloud Run (Pre-GA)
    Google Cloud Deploy allows you to deploy your container-based workloads to any Cloud Run service. All Google Cloud Deploy features are supported when you deploy to Cloud Run targets.

Problem 2: How do I check the sanity of my deployment? Can I run tests automatically after deployment?

Now you can run verification tests on the deployment using your own testing image. After the skaffold applyexecution is finished successfully, Cloud Deploy runs the “skaffold verify” command in its own execution environment. Verification steps should be defined in the “skaffold.yaml” along with the deployment itself. Enabling deployment verification for a Google Cloud Deploy target consists of adding a verify: true property to a given target (or targets) in a delivery pipeline progression.

apiVersion: deploy.cloud.google.com/v1
kind: DeliveryPipeline
metadata:
name: my-demo-app
description: main application pipeline
serialPipeline:
stages:
- targetId: dev
profiles: []
strategy:
standard:
verify: true
- targetId: prod
profiles: []
strategy:
standard:
verify: false

In this configuration, deployment verification is enabled on the dev target, but not on the prod target. Note that verify: false is equivalent to omitting the verify property or the entire strategy stanza.

The following is an example skaffold.yaml that includes a verify stanza

apiVersion: skaffold/v3alpha1
kind: Config
build:
artifacts:
- image: integration-test
context: integration-test
manifests:
rawYaml:
- kubernetes.yaml
deploy:
kubectl: {}
verify:
- name: verify-integration-test
container:
name: integration-test
image: integration-test
command: ["./test-systems.sh"]
- name: verify-endpoint-test
container:
name: alpine
image: alpine
command: ["/bin/sh"]
args: ["-c", "wget $ENDPOINT_URL"]

Problem 3: Can I use terraform to manage Cloud Deploy service?

Apart from the console and gcloud methods, Cloud Deploy resources have been added to the Google Terraform Provider.

  • google_cloud_deploy_delivery_pipeline
    A delivery pipeline defines a pipeline through which a skaffold configuration can progress.
resource "google_cloud_deploy_delivery_pipeline" "pipeline" {
name = "dev-${local.name_suffix}"
description = "Dev Pipeline"
serial_pipeline {
stages {
target_id = "dev"
}
}
annotations = {
generated-by = "magic-modules"
}
labels = {
env = "dev"
}
region = "us-central1"
}
  • google_cloud_deploy_target
    A target defines a location to which a skaffold configuration can be deployed.
resource "google_cloud_deploy_target" "pipeline" {
name = "tf-test-tf-test%{random_suffix}"
description = "Target Prod Cluster"
annotations = {
generated-by = "magic-modules"
another = "one"
}
labels = {
env = "prod"
}
gke {
cluster = "projects/%{project}/locations/us-central1/clusters/prod"
}
execution_configs {
usages = ["RENDER"]
service_account = data.google_compute_default_service_account.default.email
}
execution_configs {
usages = ["DEPLOY"]
service_account = "example@appspot.gserviceaccount.com"
}
}
data "google_compute_default_service_account" "default" {

}

Other worthy features

  • You can configure the timeout for Cloud Build operations using Cloud Deploy.
  • Cloud Deploy can auto-generate a “skaffold.yaml” file if you create a release using Kubernetes manifest for every release.
  • Now you can compare the difference between different Kubernetes and Skaffold configuration files for releases.
  • Suspend or Abandoning a release is now supported.

References

--

--