spring-gumball ci/cd example

Just a repository to test CI/CD for my CMPE 172 lab. All code is authored by Professor Paul Nguyen. All documentation of process can be found in the README.md in my lab repository under Lab10.

Submission

  • We were asked to submit a link to our personal "public" GitHub Repo for Lab #10, which is this.
  • I have also linked my class lab repository here and the lab10 folder here for ease of access to my README.md. Note that it is a private repository, since it is for the class only.
  • I will also include my lab notes here for ease of access.

CMPE 172 - Lab #10 Notes

Use the provided starter code from Professor Nguyen here and create a personal repo named spring-gumball. We will then use it to work through the lab. The personal repo can be found here justin-zhu1018/spring-gumball.

CI Workflow

  1. Create a new Workflow with template Java with Gradle under Actions tab. It is no longer there, so I am just going to use the code snippet provided by Professor Nguyen. This is essentially the manual way of doing it. CI-1

  2. Commit the code to the main branch to trigger the action. Take screenshots of the result after it runs. CI-2 CI-3 CI-4 CI-5 CI-6

CD Workflow

  1. Create a new Workflow build with template 'Build and Deploy to GKE' under Actions tab. I will once again be using a code snippet provided by Professor Nguyen for the sake of accuracy to ensure that I can get the lab running properly. CD-2

  2. Reduce number of replicas from 4 to 2 in deployment.yaml. Downsizing as requested by Professor Nguyen to hopefully make things run smoother on GKE (was using too many resources). Also, ensure kustomization.yml, deployment.yaml, service.yaml are in the repo as well. CD-1

  3. Create a GKE cluster with name: cmpe172 and region: us-central1-c. Size will be default to maximize resources. CD-6

  4. Set up secrets in the workspace. GKE_PROJECT with name of project and GKE_SA_KEY with Base64 encoded JSON service account key.

    • To create service account, go to IAM & Admin tab in GCP side nav, then to Service Accounts, Create Service Account with spring-gumball in required fields.
    • Then click on the created account and go to the Keys tab to create a new JSON key.
    • The service account needs to have owner access to the project. CD-3 CD-4 CD-5
  5. Go to GitHub Settings and Secrets tab to create secrets GKE_PROJECT and GKE_SA_KEY for GitHub to access them. GKE_PROJECT is project id and GKE_SA_KEY is the key generated in Step 3. The GKE_SA_KEY must be encoded with Base64 first. Do this by changing directory to the .json file downloaded and running key_file_name.json | base64. CD-A-9

  6. We will now need to trigger the CD deployment by creating a new GitHub Release. I will be using version 1.0 tag. This should automatically deploy our app to our GCP GKE cluster. Focus on release 1.1.2. I had errors in prior versions that I ended up fixing after redoing the secrets part. CD-7 CD-8 CD-9-1 CD-9-2

  7. Manually create load balancer. Go to Services & Ingress, select the service, Create Ingress, External HTTP/S load balancer, spring-gumball-lb, make sure backend is selected, and everything else should be default, then click create. CD-A-1 CD-A-2 CD-A-3 CD-A-4 CD-A-5 CD-A-6 CD-A-7

  8. Test the page by going to the frontend created by the load balancer after the load balancer is finished creating. CD-A-8