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.
- 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.
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.
-
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. -
Commit the code to the
main
branch to trigger the action. Take screenshots of the result after it runs.
-
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.
-
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. -
Create a GKE cluster with name:
cmpe172
and region:us-central1-c
. Size will be default to maximize resources. -
Set up secrets in the workspace.
GKE_PROJECT
with name of project andGKE_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.
-
Go to GitHub Settings and Secrets tab to create secrets
GKE_PROJECT
andGKE_SA_KEY
for GitHub to access them.GKE_PROJECT
is project id andGKE_SA_KEY
is the key generated in Step 3. TheGKE_SA_KEY
must be encoded with Base64 first. Do this by changing directory to the .json file downloaded and runningkey_file_name.json | base64
. -
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.
-
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.
-
Test the page by going to the frontend created by the load balancer after the load balancer is finished creating.