Create a CI/CD Pipeline on Google Cloud with Spinnaker

1.5 hours
  • 3 Learning Objectives

About this Hands-on Lab

This lab will guide you through the steps to create a fully automated, end-to-end CI/CD pipeline on Google Cloud using Spinnaker as our Continuous Delivery application.

This lab will have three main parts:

1. Create the Spinnaker deployment on GKE using guided Google-maintained scripts and Cloud Shell guides.
2. Create the rest of our CI/CD environment using a secondary script (or optionally, going through the piece-by-piece deployment we will use in our lab).
3. Push new commits to a custom application and manage staging and production pipelines in Spinnaker.

At the end of this lab, you will learn how to build your own CI/CD pipeline for Kubernetes applications that allows for complex deployment models (in this case, a blue/green or staging/production model). These skills are vital for any Google Cloud professional who will need to create and maintain DevOps pipelines for reliable application delivery.

This is considered to be an expert level lab. Though the steps are largely automated via scripts, it will assume that you have some familiarity with container management, deployment to Kubernetes, and managing application code via a git repository.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install Spinnaker environment using Google’s recommended guided process
  • In a new tab, navigate to the Spinnaker solution marketplace page at this link:

https://console.cloud.google.com/marketplace/details/google-cloud-platform/spinnaker

  • Click the link labeled: GO TO SPINNAKER FOR GOOGLE CLOUD PLATFORM
  • Click Confirm on the prompt to clone the GitHub repo
  • The Cloud Shell tutorial for installing Spinnaker should appear on the right
  • Note: If Cloud Shell is not associated with your project, please do so before continuing
  • From the right side guided setup:
    • Select your current project
    • Configure Git
    • Configure the environment (will create a ‘properties’ file)
  • Before proceeding with the install, we need to modify 3 items in two files
    • In the properties file:
      • Change the export GKE_MACHINE_TYPE= to n1-standard-1
      • Change the cluster name to world-gift-art
    • In the setup.sh file:
      • On line 164, add the datastore.owner role to the list of K8S_REQUIRED_ROLES
  • Begin the installation of the Spinnaker environment. This will take about 10-15 minutes to complete
  • When installation is complete, enable port forwarding to gain access to Spinnaker’s web interface, and launch in Cloud Shell’s web preview on port 8080
Create the rest of the CI/CD pipeline
  • Set your Cloud Datastore region to us-east-1
  • Download the script we will reference for creating the rest of the pipeline:

wget https://raw.githubusercontent.com/linuxacademy/content-gcpro-devops-engineer/master/scripts/create_app_and_pipelines.sh

  • Optional: If you wish, you can simply execute the script in cloud shell to build out the rest of the pipeline
  • Create the remainder of the pipeline, using the script as a guide. Steps include:
    • Sync environment variables to the same properties files used by the Spinnaker installation
    • Create Cloud Storage bucket for our application’s image assets, and assign public read access
    • Create a Cloud Source Repository, and clone it to Cloud Shell
    • Pull our application’s GitHub assets into the Cloud Source Repository location
    • Prepare cloudbuild.yaml and our Kuberenetes ReplicaSet files to align with our project’s resources
    • Substitute your project ID and app Cloud Storage bucket in the config.py file
    • Create Spinnaker application and pipelines
    • Push codebase into Cloud Source Repository
    • Create Cloud Build trigger to automatically start new builds on each new code commit
Push application commits into CI/CD pipeline
  • Update the application’s base.html file
  • Commit the changes to git and push into Cloud Source Repository
  • In Spinnaker, entre the world-gift-art application, and view your pipelines
  • Once the staging pipeline is complete, view the application under the Load Balancers menu, and open the staging load balancer’s address in a new tab. Notice that the plus button in the top right does not work
  • Cancel the promotion to production pipeline
  • Back in your application code, fix the broken link in the base.heml file to use an href link of /artworks/add
  • Push the new update to Cloud Course Repository
  • Back in Spinnaker, after the new image is deployed, test the staging load balancer to make sure the plus button works
  • Promote the application to the production pipeline, and view the production load balancer (in the same manner as the staging load balancer) once the pipeline is complete

Additional Resources

Your company, World Gift Art, is launching its initial public website: an online repository of customers' favorite artwork from around the world. World Gift Art wants to adopt best practices for rapid and reliable application deployment. As such, you need to implement a fully automated CI/CD pipeline using Spinnaker to facilitate rapid improvements to your website. Once the pipeline is automated, we will deploy the initial versions of our website and even fix some errors along the way.

This lab will accomplish the following steps.

  1. Launch Google's recommended guided Spinnaker installation solution, which is comprised of a Google-maintained GitHub repo that uses a guided Cloud Shell tutorial.
  2. Go through the Spinnaker environment installation steps, modify a few key options in the process, and then begin the installation.
  3. Create the remainder of the CI/CD pipeline, including our codebase in a Cloud Source Repository, Cloud Build triggers, stateful backends, and configuration of our Spinnaker pipelines.
  4. Once our pipeline is complete, we will commit changes to our repo, which will automatically package and push our application into GKE.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?