Skip to main content

Implementing a Google Kubernetes Engine Canary Deployment

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:30:00

Difficulty

Beginner

Let’s say you have a new version of an application with added features you want to roll out, but you want to give it a bit of a trial run with just a percentage of your users. Such a scenario calls for a canary deployment where a limited number of pods run the updated app while, at the same time, the majority of pods run the current or stable app. In this hands-on lab, we’ll set up the YAML files for both stable and canary deployments with Google Kubernetes Engine and spin up a load balancer that targets both deployments at the same time.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Implementing a Google Kubernetes Engine Canary Deployment

Introduction

In this hands-on lab, we’ll set up the YAML files for both stable and canary deployments with Google Kubernetes Engine and spin up a load balancer that targets both deployments at the same time.

How to Log in to Google Lab Accounts

On the lab page, right-click Open GCP Console and select the option to open it in a new private browser window (this option will read differently depending on your browser — e.g., in Chrome, it says "Open Link in Incognito Window"). Then, sign in to Google Cloud Platform using the credentials provided on the lab page.

On the Welcome to your new account screen, review the text, and click Accept. In the "Welcome L.A.!" pop-up once you're signed in, check to agree to the terms of service, choose your country of residence, and click Agree and Continue.

Implementing a Google Kubernetes Engine Canary Deployment

Now, on to the lab!

Clone the repo to retrieve the files.

  1. Navigate to Kubernetes Engine > Clusters.

  2. Activate the Cloud Shell by clicking the icon in the top row.

  3. Clone the GitHub repository:

    git clone https://github.com/linuxacademy/content-gc-essentials
  4. Change directory:

    cd content-gc-essentials/gke-lab-03

Create the Kubernetes Engine cluster.

  1. In the Cloud Shell, set the compute zone:

    gcloud config set compute/zone us-central1-a
  2. Create the cluster:

    gcloud container clusters create la-gke-1 --num-nodes=4
  3. Set up Cloud Shell to use kubectl commands for the new cluster:

    gcloud container clusters get-credentials la-gke-1

Deploy the stable and canary apps via YAML files.

  1. Open the Cloud Shell Editor by clicking the pencil icon.

  2. Navigate to content-gc-essentials > gke-lab-03, and open the deploy-stable.yaml, deploy-canary.yaml, and lb-stable-canary.yaml files.

  3. Review the files, noting the labels and selector sections.

  4. In the Cloud Shell, enter the following commands to create the deployments:

    kubectl create -f deploy-stable.yaml
    kubectl create -f deploy-canary.yaml
  5. In the console, visit the Kubernetes Engine > Workloads section to confirm the deployments.

  6. In the Cloud Shell, expose the deployment:

    kubectl apply -f lb-stable-canary.yaml
  7. In the console, visit the Kubernetes Engine > Services section to confirm the operation.

  8. Click the Endpoints link to review the application output.

  9. Refresh the browser multiple times to view the different deployments.

Conclusion

Congratulations on completing this lab!