Slides to accompany the basic demo: https://docs.google.com/presentation/d/1PlgcayXFV7-qaGWFoYw7uzbY8QpIjTPOcTwZ57s0NGc/edit#slide=id.g7864721daf_0_0
Clone the repo, remove the slides link and this section, push to a new repo and make the repo publc.
- Create a new public repo on github
- git clone https://github.com/untitledteamuk/nodejs-cr-helloworld.git
- cd nodejs-cr-helloworld/
- git push https://new-repo.git
- remove the old repo: cd .. && rm -rf nodejs-cr-helloworld/
- git clone https://new-repo.git
- 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.
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.
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.
Once the deployment is completed press the URL to show it's worked.
- [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
- Select Set Up Continuous Deployment
- Configure the source repositry (this uses Cloud Build)
- Set the Branch to use and the buildtype (I use a Dockerfile here and Buildpacks for CRfA), press save.
- 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.
- 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.
- Click into the build and talk through the steps.
- 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.
- reenforce all of this was done automatically form Cloud Run
-
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'.
-
Select the Cluster that will be used for deployment, the namespace and giuve the service a name. press 'next'.
-
in the next section select 'Continuously deploy new revisions from a source repository' and 'Set Up With Cloud Build'.
-
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.
-
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.
- Go to Cloud Build and Triggers in the console and press 'RUN' on the trigger.
- 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
- Go back to the main CRfA page and select 'Manage Custom Domains'.
- Select 'Add Mapping' > 'Add Service Domain Mapping'.
- 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.
- 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.