Deploying Google Kubernetes Engine Rolling Updates

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:30:00

Difficulty

Beginner

Updating your applications is a fact of life, and there are a number of deployment strategies. The rolling update is one of the most common because it allows an update to take place with zero downtime. In this lab, we’ll create a new Kubernetes Engine cluster and then deploy an existing containerized app via a YAML configuration file. Then, we’ll initiate an update and review the Kubernetes Engine process.

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.

Deploying Google Kubernetes Engine Rolling Updates

Introduction

In this hands-on lab, we'll create a new Kubernetes Engine cluster and then deploy an existing containerized app via a YAML configuration file. Then, we'll initiate an update and review the Kubernetes Engine process.

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.

Solution

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-02

Create the Kubernetes Engine cluster.

  1. In the Cloud Shell, configure the zone we'll use:

    gcloud config set compute/zone us-central1-a
  2. Create the four-node 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 app via a YAML config file.

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

  2. Navigate to content-gc-essentials > gke-lab-02, and open the deploy-rolling.yaml file.

  3. Review the file, noting the image parameter.

  4. In the Cloud Shell, enter the following command:

    kubectl create -f deploy-rolling.yaml
  5. Note updating pods in the Workloads section of the console.

  6. Expose the deployment:

    kubectl expose deployment rolling --type=LoadBalancer --name=rolling-service --port=80 --target-port=80
    kubectl get services rolling-service
  7. Confirm the exposed service in the console in the Services section.

  8. Click the endpoint link to review application output.

Initiate rolling update.

  1. In the deploy-rolling.yaml file, change the image parameter to the following value:

    linuxacademycontent/content-gcp-labs:rolling-v2
  2. Click File > Save.

  3. In the Cloud Shell, enter the following command:

    kubectl apply -f deploy-rolling.yaml
  4. On the console Workloads page, click the deployment name.

  5. Review the number of pods, and refresh the page until four pods are shown.

  6. Go to the browser tab showing the application output, and refresh the page.

Review pods and output.

  1. From the console, visit the Workloads section.
  2. Click the existing workload.
  3. View the number of pods created.
  4. In a moment, refresh the page.
  5. Copy the external URL link, and paste it in a new browser tab.

Conclusion

Congratulations on completing this hands-on lab!