GCP Resources - vidyasekaran/GCP GitHub Wiki

NOTE: Important note

https://spring.io/projects/spring-cloud-gcp

Spring Cloud GCP is no longer part of the Spring Cloud release train. The new repository location is https://github.com/GoogleCloudPlatform/spring-cloud-gcp. Check out the migration guide to upgrade from version 1.x to 2.0.0.

Architecting Systems in the Cloud

https://www.roitraining.com/course-838-architecting-systems-in-the-cloud/

Create Architecture diagrams using draw.io

https://www.youtube.com/watch?v=N_tFyuQw0Ws

Login using gmail account and access below url

https://cloud.google.com/icons/ (click on draw.io at the bottom which opens draw.io in screen) https://app.diagrams.net/?splash=0&libs=gcp

  • drag /drop and create the diagram and export it as pdf, png, jpeg etc...

draw.io code and windows/linux installers (you can install in windows as desktop version) https://github.com/jgraph/drawio-desktop

Good SpringBoot GCP tutorials -

https://codelabs.developers.google.com/spring?hl=en

Features Spring Cloud GCP offers a wide collection of libraries that make it easier to use Google Cloud Platform from Spring Framework applications.

https://spring.io/projects/spring-cloud-gcp

Spring Framework Support

https://cloud.google.com/products/tools

The repository also contains code samples to help you develop your application. https://github.com/GoogleCloudPlatform/spring-cloud-gcp/tree/main/spring-cloud-gcp-samples

Tutorials

https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app#cloud-shell_1

GKE key components

https://youtu.be/lbCn0EGZ9Io

Create give cluster and deploy sample website

https://youtu.be/vIKy3pDz3jM

Deploy Spring Boot App in AppEngine

Downloaded App Engine and installed - https://cloud.google.com/sdk/docs/install youtube link follwed - https://www.youtube.com/watch?v=0zJUK-SwPqQ

The gcloud tool cheat sheet

https://cloud.google.com/sdk/docs/cheatsheet

Upload a file to Google Cloud Storage (Java)

https://github.com/GoogleCloudPlatform/spring-cloud-gcp/tree/main/spring-cloud-gcp-data-datastore https://stackoverflow.com/questions/51358617/upload-a-file-to-google-cloud-storage-java

Spring Cloud Code Samples for all GCP Services

https://github.com/GoogleCloudPlatform/spring-cloud-gcp

https://github.com/spring-cloud/spring-cloud-gcp

Scripting with gcloud: a beginner’s guide to automating GCP tasks

https://cloud.google.com/blog/products/management-tools/scripting-with-gcloud-a-beginners-guide-to-automating-gcp-tasks

@ShellComponent - That informs Spring that we want to use this class as a source for CLI commands. The methods annotated with @ShellMethod will be exposed as CLI commands in our application.

https://codelabs.developers.google.com/codelabs/cloud-spring-datastore?hl=en&continue=https%3A%2F%2Fcodelabs.developers.google.com%2Fspring%3Fhl%3Den#7

Example Code:

@ShellComponent @SpringBootApplication public class DemoApplication {

@ShellMethod("Saves a book to Cloud Datastore: save-book <title> ") public String saveBook(String title, String author, int year) { Book savedBook = this.bookRepository.save(new Book(title, author, year)); return savedBook.toString(); }

When you run the code you will get Shell

$ ./mvnw spring-boot:run

shell:>

shell:> help (list all commands for the java source code) find-all-books: Loads all books find-by-author: Loads books by author: find-by-author find-by-author-year: Loads books by author and year: find-by-author-year find-by-year-after: Loads books published after a given year: find-by-year-after remove-all-books: Removes all books save-book: Saves a book to Cloud Datastore: save-book <title>

Retrieving Credentials/Secrets from Secret Manager with Spring Boot

https://codelabs.developers.google.com/codelabs/cloud-spring-cloud-gcp-secret-manager?hl=en&continue=https%3A%2F%2Fcodelabs.developers.google.com%2Fspring%3Fhl%3Den#0

Cache data from a Spring Boot app with Memorystore

https://codelabs.developers.google.com/codelabs/cloud-spring-cache-memorystore?hl=en&continue=https%3A%2F%2Fcodelabs.developers.google.com%2Fspring%3Fhl%3Den%230#0

Distributed tracing with Spring Cloud Sleuth and Cloud Trace

https://codelabs.developers.google.com/codelabs/cloud-spring-cloud-gcp-trace?hl=en&continue=https%3A%2F%2Fcodelabs.developers.google.com%2Fspring%3Fhl%3Den%230#0

Deploy a Spring Boot Java app to Kubernetes on Google Kubernetes Engine

Use Jib to create the container image and push it to the Container Registry

./mvnw -DskipTests com.google.cloud.tools:jib-maven-plugin:build -Dimage=gcr.io/$GOOGLE_CLOUD_PROJECT/hello-java:v1

Deploy a Spring Boot Java app to Kubernetes on Google Kubernetes Engine

https://codelabs.developers.google.com/codelabs/cloud-springboot-kubernetes?hl=en&continue=https%3A%2F%2Fcodelabs.developers.google.com%2Fspring%3Fhl%3Den%230#11

Spring Boot application with Cloud Spanner

For all Spring Cloud reference

https://github.com/spring-cloud

Examples with Documentation https://github.com/GoogleCloudPlatform/spring-cloud-gcp/tree/main/spring-cloud-gcp-samples/spring-cloud-gcp-storage-resource-sample

https://codelabs.developers.google.com/codelabs/cloud-spring-spanner?hl=en&continue=https%3A%2F%2Fcodelabs.developers.google.com%2Fspring%3Fhl%3Den%230#0

use service account in spring boot app to access gcp resources

This link has better explanation about using service account https://dzone.com/articles/bootiful-gcp-to-production-88

https://docs.spring.io/spring-cloud-gcp/docs/1.0.0.M1/reference/htmlsingle/

https://cloud.google.com/docs/authentication/production#auth-cloud-explicit-java

https://github.com/spring-cloud/spring-cloud-gcp/blob/main/spring-cloud-gcp-samples/spring-cloud-gcp-config-sample/src/main/resources/bootstrap.properties

https://stackoverflow.com/questions/60762324/how-to-specify-the-gcp-credential-location-in-application-properties-file-for-u

https://github.com/spring-cloud/spring-cloud-gcp/tree/main/spring-cloud-gcp-samples/spring-cloud-gcp-secretmanager-sample

complete gcp spring documentation

https://docs.spring.io/spring-cloud-gcp/docs/1.0.0.M1/reference/htmlsingle/

Create new workspace in local and How to Checkin project pulled from git and push it to gcp

  1. Create a repository and also setup ssh in gcp refer : https://cloud.google.com/source-repositories/docs/authentication#generate_a_key_pair

  2. Add a new repository myrepo in local E:\workspace\myrepo and from gcp - https://source.cloud.google.com/repos

  3. You will be show below steps Refer *notes

  4. open 2 command prompt 1 for git clone from git example : https://github.com/vidyasekaran/spring-cloud-gcp-1 and another to git clone ssh://duvarakan1948@[email protected]:2022/p/iaptest-328809/r/myrepo

  5. copy the folder you cloned from git (E:\workspace\new-gcp-repository\spring-cloud-gcp-1) and paste it in E:\workspace\myrepo

  6. now from E:\workspace\myrepo do

git remote show origin (to see origin points to GCR)

git add .

git status

E:\workspace\myrepo>git commit -m "test"

E:\workspace\myrepo>git push -u origin master

  1. Now setup this project in STS E:\workspace\myrepo\spring-cloud-gcp-storage

*notes

Clone this repository to a local Git repository: Clone with command line $ git clone ssh://duvarakan1948@[email protected]:2022/p/iaptest-328809/r/myrepo

Or clone with VS Code Clone Note: This may display the following message that is safe to ignore: "warning: You appear to have cloned an empty repository." Switch to your new local Git repository: $ cd myrepo

After you've committed code to your local Git repository, push it to this repository: $ git push -u origin master

Helpful sites

https://github.com/vidyasekaran/spring-cloud-gcp-1

https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr

https://xenovation.com/blog/source-control-management/git/how-to-change-remote-git-repository

https://git-scm.com/docs/git-push

For Google Cloud Repository related refer below

https://cloud.google.com/source-repositories/docs

Adding a repository as a remote

https://cloud.google.com/source-repositories/docs/adding-repositories-as-remotes#windows

OR in cloudshell you can git clone from git:url

⚠️ **GitHub.com Fallback** ⚠️