Work in progress

Slides to accompany the basic demo: https://docs.google.com/presentation/d/1PlgcayXFV7-qaGWFoYw7uzbY8QpIjTPOcTwZ57s0NGc/edit#slide=id.g7864721daf_0_0

Note: This only works on a public repo

Clone the repo, remove the slides link and this section, push to a new repo and make the repo publc.

  1. Create a new public repo on github
  2. git clone https://github.com/untitledteamuk/nodejs-cr-helloworld.git
  3. cd nodejs-cr-helloworld/
  4. git push https://new-repo.git
  5. remove the old repo: cd .. && rm -rf nodejs-cr-helloworld/
  6. git clone https://new-repo.git

Pre Reqs

  • If you are going to demo step 3 you will need a GKE cluster configured with cloud run for anthos.
  • If you are going to demo step 4 you will need a GCE instance that you can RDP into, which also has access to the Cloud Run Service.//will add detail and image later.
  • If you are going to demo step 5 you will need a IDE compatible with CloudCode (VSCode or IntelliJ) as well as a device capable of running MiniKube.
  • If you are going to demo step 6 you will need to have pre-prepared the Wagtail imgae. //will add detail later.

Cloud Run Hello World Sample

Run on Google Cloud

This sample shows how to deploy a Hello World application to Cloud Run using the Deploy to Cloud Run Button - we then expand on this to set up Continuous deployment on cloud run.

You will need to configure GKE with Cloud Run for Anthos.

Step 1

Press the Button (hold ctrl and press to open a new tab or you leave the repo):

Run on Google Cloud

image

Once cloud shell opens talk through the process on Cloud Shell, building container using Cloud Build,pushing the deployment to GCR then deploying to CR.

Screenshot from 2021-08-09 15-58-59

Once the deployment is completed press the URL to show it's worked.

Screenshot from 2021-08-09 15-59-29

Step 2

Set Up Continuous Deployment

image

  • [go to the Google cloud console] (https://console.cloud.google.com/)
  • Select Cloud Run under the Serverless options
  • here you will see the deployment from step one, click into it Screenshot from 2021-08-10 15-12-46
  • Select Set Up Continuous Deployment Screenshot from 2021-08-10 15-15-45
  • Configure the source repositry (this uses Cloud Build) Screenshot from 2021-08-10 15-20-40
  • Set the Branch to use and the buildtype (I use a Dockerfile here and Buildpacks for CRfA), press save. Screenshot from 2021-08-10 15-24-43
  • The Cloud Build Trigger is now being created - I use this as an oppurunity to talk through the CR dashboards and logs as well as showing the YAML section. One completed you will see a build history at the top of the dashboard. Ctrl and Click into this for a new tab. Screenshot from 2021-08-10 15-28-34
  • Make a cahnge to in the index.js file, commit and push the change.
  • In the Cloud Build Tab you will now see the build process start - highlight the commit ID on the build reference to help with debugging/auditing of a change if needed. Screenshot from 2021-08-10 15-32-13
  • Click into the build and talk through the steps. Screenshot from 2021-08-10 15-32-03
  • once the build is showing as complete, highlight the time taken and go to the page opened at the end of step 1 and refresh the page to show the change. Screenshot from 2021-08-10 15-36-16
  • reenforce all of this was done automatically form Cloud Run

Step 3

Deploy on CRfA setp continuous Deployment with buildpacks

image

  • An Anthos GKE Cluster with Cloud Run for Anthos is required to be pre configured. this can take upto 15 minutes to create

  • Run through this once before demoing as we need to set up a Custom DNS Map more detail hereyou cannot access the CRfA service on http://IP alone

  • Go to the cloud run for Anthos page on Google Cloud Console and select 'Create Service'. Screenshot from 2021-08-10 16-10-01

  • Select the Cluster that will be used for deployment, the namespace and giuve the service a name. press 'next'. Screenshot from 2021-08-10 16-13-34

  • in the next section select 'Continuously deploy new revisions from a source repository' and 'Set Up With Cloud Build'. Screenshot from 2021-08-10 16-15-55

  • As in step 2 select the repository however this time choose the 'Build Type' as buildpacks and press 'Save' then 'Next'. Make sure the Source Branch is '^main$' or similair CRfA sets this to '^master$' by default which doesn't work unless you rename the branch. Screenshot from 2021-08-10 16-16-39

  • Leave 'Connectivity' as 'External' and press 'Create'.

  • Go to revisions on the Console and you will see a placeholder service we now have two options to to deploy the service.

  1. Go to Cloud Build and Triggers in the console and press 'RUN' on the trigger. Screenshot from 2021-08-10 20-14-27
  2. make a change to the index.js file then commit and push the code - remember this will also trigger the pipeline we set up in step 2.

** Set Up Custom DNS Mapping **

  • Go into the Service running on CRfA and press the Little i at the side of the URL (This URL does not work extrernally), in the side menu you will a curl command, at the end of this you will see the services IP address NOTE THIS DOWN Screenshot from 2021-08-10 20-30-34 Screenshot from 2021-08-10 20-30-56
  • Go back to the main CRfA page and select 'Manage Custom Domains'. Screenshot from 2021-08-10 20-27-41
  • Select 'Add Mapping' > 'Add Service Domain Mapping'. Screenshot from 2021-08-10 20-38-18
  • Select the service to map to from the drop down list and in the domain name enter the '$IP.nip.io' where the IP is what was noted down above. Screenshot from 2021-08-10 20-39-25
  • press 'Done', open a new tab and enter the Domain and you should have access to the service.

If you are demoing this I would suggest removing the Cloud Build Trigger created, so you can show the creation process again during the demo, however as the service is already pre deployed you don't need to redo the DNS Mapping as it's already there.

Step 4

all private (Need a GCE instance with RDP access)

image

Step 5

CloudCode Goodness

image

Step 6

Using other cloud services.

image